Build the next generation of YouTube experiences
The YouTube API allows developers to add YouTube functionality to their applications, websites, and devices. With this API, you can search for videos, manage playlists, upload content, and interact with user accounts.
Note: To use the YouTube API, you need to obtain API credentials from the Google Developers Console. Make sure to review and comply with YouTube's API Terms of Service.
The YouTube API supports two types of authentication:
# Example OAuth flow using Python and google-auth-oauthlib
from google_auth_oauthlib.flow import Flow
flow = Flow.from_client_secrets_file(
'client_secret.json',
scopes=['https://www.googleapis.com/auth/youtube.force-ssl']
)
flow.run_local_server(port=8080, prompt='consent')
credentials = flow.credentials
Search for YouTube resources (videos, channels, playlists)
GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=cats&type=video&key=YOUR_API_KEY
Retrieve details about one or more videos
GET https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&id=VIDEO_ID&key=YOUR_API_KEY
Upload a video to YouTube
POST https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{
"snippet": {
"title": "My Awesome Video",
"description": "This is a great video I made",
"tags": ["awesome", "video", "example"],
"categoryId": "22"
},
"status": {
"privacyStatus": "private"
}
}
The YouTube API uses a quota system to ensure fair usage across all developers. Each API request consumes a certain number of quota units.
| Operation | Quota Cost |
|---|---|
| Read operations (e.g., search, list videos) | 1-5 units |
| Write operations (e.g., upload video, post comment) | 50-1600 units |
| Video upload | 1600 units |
Note: The default quota limit is 10,000 units per day. You can request a quota increase if needed. Monitor your quota usage in the Google Developers Console.