| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| README.md | < 14 hours ago | 6.9 kB | |
| self-hosted-video-widget-v1.0.1.zip | < 14 hours ago | 605.2 kB | |
| Totals: 2 Items | 612.0 kB | 0 |
YT Widget β Unofficial Self-Hosted Video Feed & Embed Script
An independent, open-source, self-hosted video gallery and channel embed script for any website.
Drop one <div> and one <script> tag into any HTML page to render a responsive video feed, channel stats card, playlist grid, or single video player using your own API credentials.
Disclaimer: This is an independent, unofficial open-source project and is not affiliated with, endorsed by, or sponsored by YouTube or Google LLC. "YouTube" is a registered trademark of Google LLC.
π Quick Start
Step 1 β Create a Data API Key (Free Tier)
- Open Google Cloud Console
- Create a new project (or select an existing one)
- Navigate to APIs & Services β Library
- Search for and enable YouTube Data API v3
- Go to APIs & Services β Credentials β Create Credentials β API Key
- Restrict your key to your domain under Website restrictions for security
β‘ Quota Note: The free tier includes 10,000 units/day, and each widget page load uses roughly 3β5 units.
Step 2 β Find Your Channel ID
- Open YouTube Studio β Settings β Channel β Advanced settings
- Copy the Channel ID (starts with
UC) - Alternatively, grab the
UC...identifier from the end of a channel's/channel/UCxxxxxxxxxxxxxxxxxxxxxxpath
Step 3 β Add the Widget to Your Page
Copy yt-widget.js to your server, then paste this snippet into any HTML page:
<!-- Place this where you want the widget to appear -->
<div
data-yt-widget
data-channel-id="UCxxxxxxxxxxxxxxxxxxxxxx"
data-api-key="YOUR_API_KEY"
data-layout="grid"
data-theme="dark"
data-max-results="9">
</div>
<!-- Place this before </body> -->
<script src="/path/to/yt-widget.js"></script>
ποΈ Configuration Options
All options are configured via data-* attributes on the widget container:
| Attribute | Values | Default | Description |
|---|---|---|---|
data-api-key |
string | required | Your Data API v3 key |
data-channel-id |
UCxxxxx... |
required* | Target channel ID |
data-video-id |
xxxxxxxxxxx |
required* | Target video ID (for type=single) |
data-playlist-id |
PLxxxxx... |
required* | Target playlist ID (for type=playlist) |
data-type |
feed | stats | single | playlist |
feed |
Widget display mode |
data-layout |
grid | list |
grid |
Card layout style |
data-theme |
dark | light |
dark |
Color theme |
data-accent-color |
any CSS color | #ff0033 |
Accent and highlight color |
data-max-results |
1β50 |
9 |
Number of videos to display |
data-show-channel-info |
true | false |
true |
Show channel header with avatar and subscribe button |
*Required fields depend on the selected widget type.
π¬ Widget Types
feed β Latest Video Grid or List
Displays the most recent uploads from a channel:
<div data-yt-widget
data-channel-id="UCxxxxxx"
data-api-key="YOUR_API_KEY"
data-type="feed"
data-layout="grid"
data-max-results="9">
</div>
stats β Channel Statistics
Displays subscriber count, total views, and video count:
<div data-yt-widget
data-channel-id="UCxxxxxx"
data-api-key="YOUR_API_KEY"
data-type="stats">
</div>
single β Single Video Player
Embeds a specific video with metadata:
<div data-yt-widget
data-video-id="dQw4w9WgXcQ"
data-api-key="YOUR_API_KEY"
data-type="single">
</div>
playlist β Playlist Grid
Displays videos from a specific playlist:
<div data-yt-widget
data-channel-id="UCxxxxxx"
data-playlist-id="PLxxxxxx"
data-api-key="YOUR_API_KEY"
data-type="playlist"
data-max-results="12">
</div>
π¨ Theming & Customization
Dark Theme (Default)
<div data-yt-widget data-theme="dark" ...></div>
Light Theme
<div data-yt-widget data-theme="light" ...></div>
Custom Accent Color
<div data-yt-widget data-accent-color="#7c3aed" ...></div>
CSS Variable Overrides
Override any CSS custom property on the widget container after render:
#my-widget {
--ytw-radius: 8px;
--ytw-bg: transparent;
}
π¦ Multiple Widgets on One Page
Place multiple data-yt-widget containers on the same page β each initializes independently:
<!-- Feed widget -->
<div data-yt-widget data-channel-id="UC111" data-api-key="YOUR_API_KEY" data-type="feed"></div>
<!-- Stats widget for a different channel -->
<div data-yt-widget data-channel-id="UC222" data-api-key="YOUR_API_KEY" data-type="stats"></div>
π§ JavaScript API
The script exposes a global YTWidget object:
// Re-initialize all widgets on the page (useful after dynamic DOM changes)
YTWidget.reinit();
// Initialize a specific element manually
const el = document.querySelector('#my-widget');
YTWidget.init(el);
// Check the current version
console.log(YTWidget.version); // "1.0.0"
ποΈ File Structure
yt-widget/
βββ yt-widget.js β Injectable widget script (deploy this file to your server)
βββ index.html β Visual builder and preview dashboard
βββ demo.html β Sample site with embedded widget
βββ styles.css β Builder dashboard styles (not required for the widget itself)
βββ README.md β Documentation
Deployment Note: Only
yt-widget.jsis required on your production server; the remaining files are for local building and previewing.
β οΈ Security & Quota Notes
API Key Security
- When used client-side, the API key is visible in page source, so always restrict your key in Google Cloud Console using HTTP referrer (website) restrictions.
- Monitor quota usage in Cloud Console to catch unexpected spikes.
- For server-side key protection, route requests through a backend proxy rather than exposing credentials in HTML attributes.
API Quota
- Free tier limit: 10,000 units/day
- Approximate cost per widget load:
- Feed widget: ~4 units (
channels.list+playlistItems.list+videos.list) - Stats widget: ~1 unit (
channels.list) - Single video: ~1 unit (
videos.list) - For high-traffic pages, cache responses on your server to minimize API calls.
βοΈ Disclaimer
This project is an independent, unofficial open-source software tool built to interact with public data endpoints. It is not affiliated with, maintained, authorized, endorsed, or sponsored by YouTube or Google LLC. All product names, trademarks, and registered trademarks are the property of their respective owners.
π License
MIT License β free for personal and commercial use.