How to Get a YouTube API Key (Data API v3, 2026 Guide)
To get a YouTube API key, create or pick a Google Cloud project, enable YouTube Data API v3 in the API Library, then go to Credentials, click Create credentials, choose API key and restrict it to the YouTube Data API. The key is free and reads public data within a default quota of 10,000 units a day, plus separate buckets of 100 search.list calls and 100 uploads a day since June 2026.
A YouTube API key is a string from Google Cloud that lets your code read public YouTube data: videos, channels, playlists, comments and search. It cannot act for a user. Uploading, rating or reading private data needs an OAuth client instead. For whether you will ever pay, see Is the YouTube API free?
API key or OAuth client?
| You want to | Credential |
|---|---|
| Read public videos, channels, playlists, comments, search | API key |
| Read a user's private playlists, subscriptions or analytics | OAuth client ID |
| Upload, update, delete, rate or comment | OAuth client ID; Google says writes always need user authorization |
How to get a YouTube API key, step by step
- Sign in to the Google Cloud console with a Google account.
- Pick a project. Use the project picker to create one or choose an existing project.
- Enable the API. Open APIs & Services > Library, search "YouTube Data API v3" and click Enable (Google's getting started).
- Create the key. Go to APIs & Services > Credentials, click Create credentials, choose API key. The "API key created" dialog shows the key (registering an application).
- Restrict it. Click Restrict key. Under API restrictions, select YouTube Data API v3. Under application restrictions, choose one type: Websites, IP addresses, Android apps or iOS apps. Google recommends setting both kinds (API key docs). Save.
- Store it in an environment variable or secret manager, not in a repo.
The same thing from the command line:
gcloud services enable youtube.googleapis.com
gcloud services api-keys create --display-name="youtube-key" \
--api-target=service=youtube.googleapis.com
Test your YouTube API key
curl "https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&part=snippet,statistics&key=YOUR_API_KEY"
A working key returns items[0].snippet.title and items[0].statistics.viewCount. Here is a Python script that lists a channel's latest uploads with view counts in 3 quota units:
import os
import requests
KEY = os.environ["YOUTUBE_API_KEY"]
API = "https://www.googleapis.com/youtube/v3"
def get(path, **params):
r = requests.get(f"{API}/{path}", params={**params, "key": KEY}, timeout=30)
if r.status_code == 403:
reason = r.json()["error"]["errors"][0]["reason"]
raise SystemExit(f"403 {reason}")
r.raise_for_status()
return r.json()
ch = get("channels", forHandle="@GoogleDevelopers", part="contentDetails") # 1 unit
uploads = ch["items"][0]["contentDetails"]["relatedPlaylists"]["uploads"]
pl = get("playlistItems", playlistId=uploads, part="contentDetails", maxResults=50) # 1 unit
ids = ",".join(i["contentDetails"]["videoId"] for i in pl["items"])
for v in get("videos", id=ids, part="snippet,statistics")["items"]: # 1 unit
print(v["statistics"].get("viewCount"), v["snippet"]["title"])
YouTube API quota: units per call
Every project gets a default daily quota, which resets at midnight Pacific time (quota costs). On 1 June 2026, Google moved search.list and videos.insert into their own buckets (revision history).
| Method | Cost | Default daily allowance |
|---|---|---|
search.list | 1 call in its own bucket | 100 calls |
videos.insert (upload) | 1 call in its own bucket | 100 calls |
videos.list, channels.list, playlistItems.list, commentThreads.list, comments.list | 1 unit | Shared 10,000 units |
captions.list | 50 units | Shared |
videos.update, videos.rate, most writes | 50 units | Shared |
Two rules catch people: every request costs at least 1 unit, even invalid ones, and every extra page costs the full price again. Many older guides still say a search costs 100 units; that changed in June 2026.
Worked budget. Tracking 200 channels daily with the script above is 600 units. Adding 50 keyword searches uses half of the separate search bucket. Pulling 100 comment pages adds 100 units. Total: 700 of 10,000 units and 50 of 100 searches, well inside the free default.
How to increase YouTube API quota
Above the default you must pass a compliance audit. Submit the YouTube API Services Audit and Quota Extension Form (form). Google reviews your use against its policies and replies "as soon as possible", with no fixed time (audits guide). Check usage first on the Quotas page in the console, and cache responses before you ask for more.
OAuth tokens for user data
For user actions, create an OAuth client ID (web, desktop, TV) under Create credentials. Request scopes such as https://www.googleapis.com/auth/youtube.readonly or youtube.upload, and add access_type=offline to get a refresh token, then refresh at https://oauth2.googleapis.com/token with grant_type=refresh_token (server-side guide). Access tokens are short-lived; read expires_in. Refresh tokens stop working if your consent screen is in Testing (7 days), after 6 months unused, if the user revokes access, or once an account has more than 100 refresh tokens for your client, when the oldest is dropped (Google OAuth).
Common YouTube API errors
| Status | Reason | Fix |
|---|---|---|
| 403 | quotaExceeded | Wait for midnight Pacific, cut pages, or apply for more |
| 403 | forbidden | Key restricted to another API or origin; check restrictions and that the API is enabled in the key's project |
| 403 | insufficientPermissions | OAuth token lacks the scope |
| 401 | authorizationRequired | You used mine=true with only a key; use OAuth |
| 400 | missingRequiredParameter, unknownPart | Add part; check spelling |
| 400 | invalidPageToken | Use the nextPageToken from the same query |
Reasons are from the Data API error reference.
If you just need public data
An API key covers most public reads cheaply. ScrapeIO helps when you hit the search bucket, need transcripts, or want YouTube in the same schema as TikTok and Instagram: the YouTube channel API, channel videos API, YouTube search API and transcript API, with no Cloud project. See YouTube Data API alternative and the YouTube MCP server.
curl "https://scrapeio.com/v1/youtube/channel?handle=@GoogleDevelopers" \
-H "x-api-key: YOUR_KEY"
FAQ
Is a YouTube API key free?
Yes. Google charges nothing for the key or the default quota; more quota requires an audit, not payment.
How many requests can I make with a YouTube API key?
By default 10,000 units a day for most methods, plus 100 searches and 100 uploads in their own buckets. A simple list call is 1 unit.
Why does my YouTube API key say quotaExceeded?
The project used its daily units or its 100 searches. It resets at midnight Pacific time.
Can I use one API key for several apps?
You can, but quota is per project, so one app can starve the others. Create a key per app and environment.
What should I do if my YouTube API key leaks?
Create a new key, switch your code to it, then delete the old one in Credentials. Restrictions limit the damage in the meantime.
Sources
Checked on 9 November 2026 from each vendor's own pages. Prices and limits change; follow the links before you decide.
- https://developers.google.com/youtube/v3/getting-started
- https://developers.google.com/youtube/registering_an_application
- https://docs.cloud.google.com/docs/authentication/api-keys
- https://developers.google.com/youtube/v3/determine_quota_cost
- https://developers.google.com/youtube/v3/revision_history
- https://developers.google.com/youtube/v3/guides/quota_and_compliance_audits
- https://support.google.com/youtube/contact/yt_api_form
- https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps
- https://developers.google.com/identity/protocols/oauth2
- https://developers.google.com/youtube/v3/docs/errors
100 free credits, no card. Credits never expire.
Get API key