YouTube API Documentation

Build the next generation of YouTube experiences

Overview

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.

Key Features

Getting Started

  1. Create a Google account if you don't have one
  2. Go to the Google Developers Console and create a new project
  3. Enable the YouTube Data API v3 for your project
  4. Create credentials (API key or OAuth 2.0 client ID)
  5. Start making API calls!
Create API Credentials

Authentication

The YouTube API supports two types of authentication:

OAuth 2.0 Flow

  1. Obtain OAuth 2.0 credentials from the Google Developers Console
  2. Implement the OAuth 2.0 flow in your application
  3. Request user consent for the required scopes
  4. Receive an access token
  5. Use the access token to make API requests

# 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
    

Core API Endpoints

GET youtube/v3/search

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
      

GET youtube/v3/videos

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
      

POST youtube/v3/videos

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"
  }
}
      

Quotas and Limits

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.

Best Practices

Support and Resources