DEV Community

Cover image for Extracting Hidden YouTube Video Tags with an API
Axio Api
Axio Api

Posted on Originally published at axioapi.com

Extracting Hidden YouTube Video Tags with an API

YouTube removed visible tags from the watch page UI a while back, but creators and competitors still set them — they're just sitting in the page's <meta name="keywords"> tag and the embedded player JSON, invisible unless you view source. If you're doing competitive research on what tags a channel is targeting, you either inspect page source by hand or write a small scraper.

AxioAPI does the scraping and parsing for you and hands back structured JSON.

The endpoint

GET https://axioapi.com/api/v1/social/youtube/videos/{id}/tags
Enter fullscreen mode Exit fullscreen mode

{id} is the 11-character YouTube video ID (the part after v= in a watch URL, or after youtu.be/).

const API = 'https://axioapi.com/api/v1';
const headers = { Authorization: `Bearer ${process.env.AXIOAPI_KEY}`, Accept: 'application/json' };

async function getTags(videoId) {
  const res = await fetch(`${API}/social/youtube/videos/${videoId}/tags`, { headers });
  if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
  return (await res.json()).data;
}

getTags('dQw4w9WgXcQ').then(({ tags, title, view_count }) => {
  console.log(title, view_count);
  console.log(tags.join(', '));
});
Enter fullscreen mode Exit fullscreen mode

Response shape:

{
  "data": {
    "video_id": "dQw4w9WgXcQ",
    "title": "...",
    "description": "...",
    "view_count": 1000000000,
    "like_count": 12000000,
    "channel": "...",
    "tag_count": 14,
    "tags": ["rick astley", "never gonna give you up", "..."]
  }
}
Enter fullscreen mode Exit fullscreen mode

Not every video has tags — plenty of channels skip them entirely, in which case tags comes back empty and tag_count is 0.

Batch-checking a channel's recent uploads

If you're auditing tag usage across a channel, pair this with the video list you already have (from your own channel scrape or YouTube Data API) and fan out:

async function tagsForVideos(videoIds) {
  const results = await Promise.all(videoIds.map((id) => getTags(id).catch(() => null)));
  return videoIds.reduce((acc, id, i) => {
    acc[id] = results[i]?.tags ?? [];
    return acc;
  }, {});
}
Enter fullscreen mode Exit fullscreen mode

Keep the concurrency reasonable — this scrapes the real YouTube watch page per call, so hammering it with hundreds of parallel requests is more likely to get you rate-limited than a handful at a time with a short delay between batches.

Caching

Responses are cached server-side for 24 hours per video ID, so re-checking the same video repeatedly in one day doesn't cost extra. Current pricing is on the Social — YouTube API page.

Want to try it without writing code first? There's a free YouTube Tag Extractor tool — paste a video URL, get the tag list back.

Top comments (0)