API Directory › 🎬 Movies, TV & Music › YouTube Data API
API KeyHTTPSCORS

YouTube Data API

Search videos, channels and playlists and read YouTube metadata.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open YouTube Data API docs ↗

What it does

The YouTube Data API (v3) reads and manages YouTube resources: search for videos, channels and playlists; fetch video metadata, statistics and captions; read comment threads; and (with OAuth) upload videos, manage playlists and moderate comments.

Base URL

https://www.googleapis.com/youtube/v3

Authentication

Enable the API in Google Cloud and use an API key (?key=YOUR_KEY) for public read-only calls. Anything user-specific or write requires OAuth 2.0 with the relevant youtube scope.

Code examples

curl
curl -s "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics"\
"&id=dQw4w9WgXcQ&key=$YT_API_KEY"
Python (search)
import requests

r = requests.get("https://www.googleapis.com/youtube/v3/search", params={
    "part": "snippet", "q": "lo-fi beats", "type": "video",
    "maxResults": 5, "key": KEY}, timeout=10)
for item in r.json()["items"]:
    print(item["id"]["videoId"], item["snippet"]["title"])

Rate limits & quotas

Every project gets 10,000 quota units/day by default (request more via a form). Costs are per operation, not per request: a read is typically 1 unit, search.list is 100 units, and writes are ~50. That is only ~100 searches/day on the default quota — cache and avoid search.list where a cheaper endpoint works.

Key response fields

items[].id.videoIdVideo ID (from search results)
items[].snippet.title / channelTitle / publishedAtBasic metadata
items[].statistics.viewCount / likeCountCounters (request part=statistics)
nextPageTokenPass as pageToken for the next page
pageInfo.totalResultsApproximate total matches

Common errors

403 quotaExceededDaily 10,000-unit quota used up — resets at midnight Pacific.
403 keyInvalid / ipRefererBlockedBad key or key restrictions block your origin.
400 missingRequiredParameterYou forgot part= — it is mandatory.
404Video/channel ID does not exist or is private.

When to use it (and alternatives)

Necessary for anything reading real YouTube data. Budget the quota carefully — search.list is expensive. For simple ‘embed this video’ use cases the oEmbed endpoint (https://www.youtube.com/oembed?url=) is free and quota-less.

FAQ

Why do I run out of quota so fast?

search.list costs 100 units, so the default 10,000/day is only 100 searches. Use videos.list/channels.list/playlistItems.list (1 unit each) whenever you already know the IDs, and cache results.

Can I get a video's full view count history?

No — the API only returns current totals. Historical analytics require the separate YouTube Analytics API and ownership of the channel.

Do I need OAuth to read public videos?

No, an API key is enough for public reads. OAuth is only for uploads, playlist edits, and reading a signed-in user’s private data.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

JSON Formatter

Related Movies, TV & Music APIs

← Back

More Movies, TV & Music APIs · All 196 APIs