How to Get YouTube Video Metadata: Views, Likes, Tags
Get the title, description, views, likes, comment count, upload date, tags, categories and chapters of any YouTube video as JSON, with curl, Python or JS.
To get the metadata of a YouTube video, call an endpoint with the video's 11-character ID and read the JSON: title, description, channel, duration, views, likes, comment count, upload date, thumbnail, tags and categories, plus the chapters with their timestamps. This guide shows the exact fields, working code in curl, Python and JavaScript, how to handle missing values, and when the official YouTube Data API is the better tool.
What "video metadata" includes
Metadata is everything about a video except the video itself. For most projects that means:
| Field | Type | Example | Notes |
|---|---|---|---|
video_id | string | dQw4w9WgXcQ | The 11-character ID |
title | string | Rick Astley - Never Gonna Give You Up | |
description | string or null | Full text | The whole description, links included |
channel_id | string or null | UCuAXFkgsw1L7xaCfnd5JJOw | Stable, unlike the channel name |
channel_name | string or null | Rick Astley | |
duration | integer or null | 213 | Seconds |
view_count | integer or null | 1700000000 | |
like_count | integer or null | 18000000 | Null when the owner hides likes |
comment_count | integer or null | 2400000 | Replies included |
upload_date | string or null | "20091025" | YYYYMMDD, not ISO |
thumbnail_url | string or null | URL | The video's thumbnail image |
tags | list of strings | ["rick astley", ...] | Often empty: many creators set none |
categories | list of strings | ["Music"] |
Two traps catch most people. First, upload_date is a YYYYMMDD string such as "20091025", not an ISO date: parse it explicitly. Second, counts can be null. A creator can hide the like count, a live stream may not have a final view count, and comments can be off. Write your code so a null never crashes a batch.
The quickest way: one HTTP request
Get an API key by signing up (100 free calls a month), then:
curl -H "X-API-Key: yt_your_api_key" \
"https://api.fetchtranscript.com/v1/videos/dQw4w9WgXcQ"{
"video_id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up (Official Video)",
"description": "The official video for “Never Gonna Give You Up” by Rick Astley...",
"channel_id": "UCuAXFkgsw1L7xaCfnd5JJOw",
"channel_name": "Rick Astley",
"duration": 213,
"view_count": 1700000000,
"like_count": 18000000,
"comment_count": 2400000,
"upload_date": "20091025",
"thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
"tags": ["rick astley", "never gonna give you up"],
"categories": ["Music"]
}Each successful call costs one credit, and the X-Credits-Used and X-Credits-Remaining headers tell you where you stand. Failed calls cost nothing. You can also try the metadata endpoint in your browser without an account.
Get YouTube video metadata with Python
import datetime
import requests
API_KEY = "yt_your_api_key"
def video_metadata(video_id):
response = requests.get(
f"https://api.fetchtranscript.com/v1/videos/{video_id}",
headers={"X-API-Key": API_KEY},
timeout=30,
)
if response.status_code == 404:
detail = response.json()["detail"]
raise LookupError(f"{video_id}: {detail['error']}") # video_not_found
response.raise_for_status()
data = response.json()
if data["upload_date"]:
data["upload_date"] = datetime.datetime.strptime(data["upload_date"], "%Y%m%d").date()
return data
meta = video_metadata("dQw4w9WgXcQ")
print(meta["title"], meta["upload_date"], meta["view_count"])video_not_found means the video cannot be read: it does not exist, or it is private, removed by the uploader or on a terminated channel. It is final and free, so do not retry it.
With the Python SDK (pip install fetchtranscript) the call is client.videos.get_metadata("dQw4w9WgXcQ").
Get YouTube video metadata with JavaScript
// Node 18+ as an ES module (a .mjs file, or "type": "module"), for the top-level await
const API_KEY = 'yt_your_api_key';
async function videoMetadata(videoId) {
const res = await fetch(`https://api.fetchtranscript.com/v1/videos/${videoId}`, {
headers: { 'X-API-Key': API_KEY },
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.detail.error}: ${body.detail.message}`);
const d = body.upload_date;
body.uploaded = d ? new Date(`${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6, 8)}T00:00:00Z`) : null;
return body;
}
const meta = await videoMetadata('dQw4w9WgXcQ');
console.log(meta.title, meta.uploaded?.toISOString().slice(0, 10), meta.like_count ?? 'hidden');Chapters: the timestamps in the description
Chapters are the sections a creator defines (a tutorial is the typical case, so replace VIDEO_ID with one) with timestamps in the description (or that YouTube generates automatically). They are returned by a separate endpoint:
curl -H "X-API-Key: yt_your_api_key" \
"https://api.fetchtranscript.com/v1/videos/VIDEO_ID/chapters"{
"video_id": "VIDEO_ID",
"has_chapters": true,
"chapters": [
{ "title": "Intro", "start_time": 0, "end_time": 42 },
{ "title": "Setting up the project", "start_time": 42, "end_time": 315 }
]
}Check has_chapters before you read the list: most videos have none. Times are in seconds, and end_time can be null. Chapters are very useful together with the transcript: you can cut a long video's text into its own sections instead of arbitrary chunks, which is exactly what you want for summaries and retrieval-augmented generation.
Metadata for many videos
Real projects rarely need one video. To build a dataset, first collect the IDs, then fetch the metadata in parallel with a small pool:
from concurrent.futures import ThreadPoolExecutor
video_ids = ["dQw4w9WgXcQ", "9bZkp7q19f0", "kJQP7kiw5Fk"]
def safe(video_id):
try:
return video_metadata(video_id)
except LookupError as e:
return {"video_id": video_id, "error": str(e)}
with ThreadPoolExecutor(max_workers=8) as pool:
rows = list(pool.map(safe, video_ids))Eight workers stay comfortably under the limit of 500 requests per minute. If you do hit it, the API answers 429 rate_limit_exceeded with a Retry-After header: sleep that long and retry.
Where do the IDs come from? From a channel (how to list every video of a channel), a playlist (export a playlist) or a keyword search (search YouTube without quota). Note that those listings already include title, duration and views for each video, so you only need this endpoint for the fields they do not carry: the full description, likes, comment count, exact upload date, tags and categories.
Keeping metadata fresh
Most fields of a video never change after upload: ID, channel, duration, upload date. Titles, descriptions, tags and thumbnails change occasionally, when a creator optimises an old video. Counts change all the time. Plan your storage around that:
- Store the stable fields once, keyed by
video_id, and never refetch them. - Store counts as snapshots with the time you read them (
video_id,read_at,view_count,like_count,comment_count), not as columns you overwrite. A time series of snapshots is what lets you compute growth, which is usually the real question. - Refresh young videos often and old ones rarely. A video gets most of its views in its first days, so a schedule such as every few hours in week one, daily in the first month and weekly afterwards captures the curve at a fraction of the calls.
- Keep the
channel_idrather than thechannel_name: channels rename themselves, IDs stay.
Counts are also rounded or delayed by YouTube itself at times, for example right after a viral spike, so treat small differences between two reads as noise rather than a signal.
The alternatives, honestly
YouTube Data API v3. The official videos.list method costs 1 unit per call and accepts up to 50 IDs at once, against a default quota of 10,000 units a day per project. For metadata alone that is generous, and the data is first-party. Its drawbacks are the Google Cloud setup, the quota ceiling when you also need search (100 units per search), and the fact that it does not give transcripts of other people's videos. If metadata is all you need and your volume fits, it is a fine choice.
yt-dlp. yt-dlp --dump-json --skip-download URL prints a very rich JSON for one video. It is free and excellent on a laptop. On servers it tends to get blocked or challenged by YouTube, each call downloads hundreds of kilobytes, and you maintain the updates when YouTube changes.
Scraping the watch page yourself. Possible, but the data sits in large embedded JSON blobs whose structure changes. Unless this is your core product, it is the most expensive option in maintenance.
A hosted API makes sense when you want metadata, transcripts, comments, channels and search behind one key, with failed calls not billed and no proxies to run. Compare the plans on the pricing page.
Ideas for what to build
- Engagement ratios: likes and comments per thousand views tell you more than raw views.
- Content audits of a channel: durations, upload frequency, categories and tags over time.
- Thumbnails and titles datasets for A/B testing research.
- Chapter-aware summaries: combine
/chapterswith the transcript to summarise each section.
Frequently asked questions
What format is upload_date in?
A string in YYYYMMDD form, for example "20091025". Parse it with strptime(value, "%Y%m%d") in Python or slice it into year, month and day in JavaScript.
Why is like_count null?
The owner can hide the like count, and some videos (live streams, premieres) have no final numbers yet. Treat every count as optional.
Can I get the metadata of a private video?
No. Only public data is read: a private video answers 404 video_not_found, and the call costs nothing.
How do I get chapters?
Call GET /v1/videos/{video_id}/chapters and check has_chapters. Each chapter has title, start_time and end_time in seconds. See the API reference.
How much does it cost?
One credit per successful call: 100 free calls every month, then $1 per 1,000 calls. Errors are never billed.
Why are the tags empty for some videos?
Tags are optional and hidden from viewers, so many creators never set any. An empty tags list is normal; use the title, description and categories for topic analysis instead.
Try it on your own videos
100 free calls every month, no credit card. Then $1 per 1,000 calls, only for the calls that succeed.
Related guides
- How to Get All Videos from a YouTube Channel
List every video of a YouTube channel by @handle, page by page with a cursor, export it to CSV, with or without Shorts, and get the transcripts of a channel.
- How to Scrape YouTube Comments (Python and JavaScript)
Export the comments of a YouTube video to JSON or CSV with authors, likes, dates and replies, without a browser or quota. Code in curl, Python and JavaScript.
- YouTube Search API Without Quota Limits
The YouTube Data API allows about 100 searches a day. How its quota works, what it costs to go beyond it, and how to search YouTube from code without units.