Skip to content

YouTube Widget ​

Subscriber count, total views and video count for one or more YouTube channels, optionally with each channel's most recent uploads and their view, like and comment counts.

Requirements ​

A YouTube Data API v3 key.

Getting an API key ​

  1. Go to console.cloud.google.com
  2. Create a project (or select an existing one)
  3. Enable the YouTube Data API v3
  4. Go to Credentials → Create Credentials → API Key
  5. Copy the key (optionally restrict it to the YouTube Data API)

The key is stored encrypted and is never sent back to the browser — see Security. Once saved, the field shows as saved rather than displaying the key.

Configuration ​

KeyTypeDefaultDescription
apiKeystring—YouTube Data API v3 key
channels{ id: string }[][]Channels to show, up to 3
showRecentVideosbooleanfalseShow each channel's latest uploads
recentVideoCountnumber3How many uploads per channel (1–10)
videoRefreshMinutesnumber60How often video stats are refetched (minimum 10)
refreshIntervalnumber300000Widget poll interval in ms, for channel totals

Latest videos ​

With Show latest videos enabled, each channel lists its most recent uploads with:

  • Thumbnail, title and how long ago it was published
  • Duration, or a LIVE badge for an in-progress stream
  • View count, like count, comment count

Likes and comments are omitted for videos where the creator has hidden likes or turned comments off. That is deliberate — the API returns no figure at all in those cases, and showing 0 would be inventing one.

Quota ​

The free allowance is 10,000 units a day. Every list call costs 1 unit no matter how many channels or fields it asks for, so what matters is the number of calls:

WhatCallsWhen
Channel totals1 (all channels batched)Every refreshInterval
Latest videos1 per channel, plus 1 sharedEvery videoRefreshMinutes

Video stats are cached on the server, so videoRefreshMinutes — not the widget's own refresh rate, and not how many browser tabs you have open — is what governs API usage.

A typical setup of three channels, five-minute widget refresh and hourly video refresh costs about 384 units a day, under 4% of the allowance:

channel totals   288 refreshes × 1 unit  = 288
latest videos     24 refreshes × 4 units =  96

Why not search.list?

Finding a channel's recent uploads via search.list is the obvious approach and costs 100 units per call — hourly that is 2,400 units a day, and at the widget's normal refresh rate it would exhaust the quota before lunch. This widget reads the channel's uploads playlist instead, which gives the same answer for 1 unit.

Finding a channel ID ​

A channel ID looks like UCxxxxxxxxxxxxxxxxxxxxxxxx. To find it:

  • Go to the channel page on YouTube
  • The ID is in the URL: youtube.com/channel/UC...
  • For custom URLs (youtube.com/@handle), view the page source and search for channelId, or use a lookup tool

Notes ​

Subscriber counts are rounded. Above 1,000 subscribers YouTube reports only three significant figures, so a channel on 123,456 shows as 123,000 and will not appear to change until it crosses 124,000. Below 1,000 the figure is exact. This is an API limitation, not a display choice.

Hidden subscriber counts read as 0; the widget knows the difference and does not treat it as a real figure.

Example config ​

json
{
  "apiKey": "YOUR_KEY_HERE",
  "channels": [
    { "id": "UCVls1GmFKf6WlTraIb_IaJg" },
    { "id": "UC9-y-6csu5WGm29I7JiwpnA" }
  ],
  "showRecentVideos": true,
  "recentVideoCount": 3,
  "videoRefreshMinutes": 60
}

Personal Homepage Dashboard