Python YouTube Data API Wrapper

0.9.8 · active · verified Thu Apr 16

A Python wrapper around for YouTube Data API. It provides an easy way to interact with YouTube Data API V3, covering all resource methods like `insert` and `update`. The library is actively developed, with version 0.9.8 released on August 22, 2025, and maintains a consistent release cadence with several updates in 2024 and 2025.

Common errors

Warnings

Install

Imports

Quickstart

Initialize the client with an API key and fetch public channel details. For operations requiring user authorization (like accessing private data or uploading videos), an OAuth 2.0 access token is required.

import os
from pyyoutube import Client

# Get your API key from Google Cloud Console and enable YouTube Data API v3
# Set it as an environment variable or replace 'YOUR_API_KEY'
API_KEY = os.environ.get('YOUTUBE_API_KEY', 'YOUR_API_KEY')

if API_KEY == 'YOUR_API_KEY':
    print("Warning: Please set the YOUTUBE_API_KEY environment variable or replace 'YOUR_API_KEY' with your actual YouTube Data API Key.")
else:
    try:
        client = Client(api_key=API_KEY)
        
        # Fetch information about a public YouTube channel (e.g., GoogleDevelopers)
        channel_by_id = client.channels.list(channel_id="UC_x5XG1OV2P6uZZ5FSM9Ttw")
        
        if channel_by_id.items:
            channel_title = channel_by_id.items[0].snippet.title
            print(f"Channel Title: {channel_title}")
        else:
            print("Channel not found or API key is invalid.")

    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →