Need video titles, channels, view counts, tags or thumbnails programmatically? Here are the three methods that actually work in 2026, with copy-paste Python for each — plus when to use which.
(Just need to check one video quickly? Use the YouTube metadata viewer — no code required.)
Method 1: yt-dlp — richest data, no API key
yt-dlp reads everything YouTube's own player receives: title, description, tags, view/like counts, chapters, formats, subtitles.
pip install yt-dlp
import yt_dlp
url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
with yt_dlp.YoutubeDL({"quiet": True}) as ydl:
info = ydl.extract_info(url, download=False)
print(info["title"])
print(info["channel"], info["channel_id"])
print(info["view_count"], "views")
print(info["upload_date"]) # YYYYMMDD
print(info["tags"])
print(info["duration"], "seconds")
Pros: no key, most complete fields. Cons: slower (~1–2 s/video), can break when YouTube changes internals (update often: pip install -U yt-dlp), and scraping sits in a grey zone of YouTube's ToS — fine for personal analysis, risky for products.
Method 2: YouTube Data API v3 — official and scalable
Get a free API key in Google Cloud Console (YouTube Data API v3 → enable → create key). Free quota is 10,000 units/day; a videos.list call costs 1 unit, so ~10k videos/day.
import requests
KEY = "YOUR_API_KEY"
video_id = "dQw4w9WgXcQ"
r = requests.get(
"https://www.googleapis.com/youtube/v3/videos",
params={"part": "snippet,statistics,contentDetails",
"id": video_id, "key": KEY},
timeout=10,
)
item = r.json()["items"][0]
snip, stats = item["snippet"], item["statistics"]
print(snip["title"], "|", snip["channelTitle"])
print(snip["publishedAt"], snip.get("tags", []))
print(stats["viewCount"], "views,", stats.get("likeCount"), "likes")
print(item["contentDetails"]["duration"]) # ISO 8601, e.g. PT3M33S
Pros: official, stable, fast, batched (50 ids per call). Cons: needs a key; description truncated to what the API returns; some fields (chapters) missing.
Method 3: oEmbed — zero setup, zero key
For just title/channel/thumbnail, YouTube's public oEmbed endpoint needs nothing at all:
import requests
video = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
r = requests.get("https://www.youtube.com/oembed",
params={"url": video, "format": "json"}, timeout=10)
data = r.json()
print(data["title"], "—", data["author_name"])
print(data["thumbnail_url"])
Thumbnails follow a predictable pattern you can build without any request:
https://i.ytimg.com/vi/<VIDEO_ID>/maxresdefault.jpg # highest
https://i.ytimg.com/vi/<VIDEO_ID>/hqdefault.jpg # always exists
Which method should you use?
| Need | Use |
|---|---|
| Everything about a few videos (tags, chapters, formats) | yt-dlp |
| Thousands of videos, production system | Data API v3 |
| Just title/channel/thumbnail, no setup | oEmbed |
| One-off check without writing code | YouTube metadata viewer |