Answers
How can I get a YouTube video's tags and description with an API?
Short answer
YouTube video detail returns the uploader's tags in the hashtags field and the full description in text, for $0.004 per video. To study a niche, search first: one search page plus details for its top 20 videos costs $0.084.
YouTube hides a video's tags from viewers, which is why browser extensions that reveal them are so popular. If you are planning videos about home espresso and want to see which tags and description patterns the 20 most-viewed videos use, an extension means 20 clicks and a lot of copying. Two calls in a loop do it in seconds.
Where tags and descriptions live
YouTube video detail takes a link or an ID and returns:
hashtags: the tags the uploader set on the video (YouTube calls them keywords). Hashtags typed into the description stay part of the description text.text: the full description, including links, chapters and sponsor lines.title,published_at,metrics.views,metrics.likes,metrics.comments, and the channel's name and handle.- With
view=full:ext.genre(the category),ext.duration_msandext.is_paid_promotion.
Count the tags across a niche
import os, requests
from collections import Counter
API = "https://api.okdata.online/v1"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
def get(path, **params):
body = requests.get(f"{API}/{path}", headers=H, params=params, timeout=60).json()
if body["code"] != "ok":
raise RuntimeError(f"{body['code']}: {body['message']}")
return body["data"]
hits = get("youtube/videos/search", query="home espresso", sort="most_viewed")["items"][:20]
tags = Counter()
for v in hits:
video = get("youtube/videos/get", id=v["id"], fields="title,hashtags")["item"]
tags.update(t.lower() for t in (video["hashtags"] or []))
for tag, n in tags.most_common(25):
print(f"{n:>2} {tag}")
Cost
| Job | Calls | Cost |
|---|---|---|
| Tags of one video | 1 | $0.004 |
| Top 20 videos for one topic | 1 search + 20 | {{cost:youtube.videos.search1+youtube.videos.get20}} |
| Five topics, 20 videos each | 5 + 100 | {{cost:youtube.videos.search5+youtube.videos.get100}} |
Search results do not carry tags, so the detail call is the one that matters.
What to expect
- Plenty of popular videos have no tags at all, and
hashtagscomes back empty or null. YouTube itself says tags play a small role in discovery, so read them as a hint about how a creator thinks, not a ranking formula. - Descriptions often matter more: the first two lines, chapter markers and links are all in
text. - Channel subscriber counts are not returned.
- A deleted or private video returns
not_foundand costs nothing.
Alternatives
- Official Data API.
videos.listwithpart=snippetreturnstagsand the description for 1 quota unit per call of up to 50 videos. With a Google key and a list you already have, it is the cheaper route. - Tag-viewer extensions. Fine for checking a single video by eye.
- Reading the page source. It works until YouTube changes the markup, which is why scrapers like that break.
For broader topic research across YouTube and other platforms, see the content research solution page.
Updated