Registry / http-networking / python-youtube

python-youtube

JSON →
library0.9.9pypypi✓ verified 87d ago

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.

pip install python-youtube
INSTALL
IMPORT
SIG · PYTHON-YOUTUBE
P
python-youtube
http-networkingpythonv0.9.9
Install
2.8s avg
Import
960ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.016s · 25.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.8s · import 0.904s · 26MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from pyyoutube import Client
from python_youtube import Client
The PyPI package `python-youtube` exposes its main functionality via the `pyyoutube` top-level package.

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}")
Debug
Known issues
deprecatedThe `pyyoutube.Api` class represents an older client structure. While still supported for backward compatibility, the `pyyoutube.Client` class is the recommended and more feature-rich approach for interacting with the YouTube Data API.
fix
Migrate your code to use `from pyyoutube import Client` and its object-oriented method structure (e.g., `client.channels.list()`).
affects: >=0.9.0
deprecatedAs of version 0.9.2, some parameters or methods within the library have been marked as deprecated. Specific details are not always highlighted in release notes, but users should consult the latest official documentation to avoid using deprecated functionality.
fix
Always refer to the official `python-youtube` documentation or the YouTube Data API v3 documentation for the most current and supported parameters and methods.
affects: >=0.9.2
gotchaAuthentication for the YouTube Data API requires careful handling of API keys for public data access and OAuth 2.0 for user-authorized actions. Misconfiguring these can lead to authorization errors or unexpected behavior.
fix
Ensure you have obtained a valid API key from the Google Cloud Console for public data. For private or user-specific data, implement the OAuth 2.0 flow to acquire and manage access tokens. Always enable the YouTube Data API v3 in your Google Cloud project.
affects: *
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyyoutube'
The `python-youtube` package or its internal `pyyoutube` module is not installed in the current Python environment.
fix
Install the library using pip: `pip install python-youtube`.
pyyoutube.exceptions.PyYouTubeException: The request is missing a required API key.
The `api_key` parameter was either not provided to the `Client` constructor or the provided key is invalid/restricted. Also, the YouTube Data API v3 might not be enabled for your Google Cloud project.
fix
Obtain a valid API key from the Google Cloud Console, enable the YouTube Data API v3 for your project, and pass it correctly to `Client(api_key="YOUR_API_KEY")`.
pyyoutube.exceptions.PyYouTubeException: The request is not authorized.
You are attempting an operation that requires user authorization (OAuth 2.0 access token) with an invalid, expired, or missing access token, or with only an API key.
fix
For operations requiring user consent, you must implement the OAuth 2.0 flow to acquire and refresh access tokens. Initialize the client with `Client(access_token='YOUR_ACCESS_TOKEN')` for authorized requests.
AttributeError: 'ChannelsResource' object has no attribute 'get_channel_info'
You are trying to use an older method (e.g., `get_channel_info`) from the deprecated `pyyoutube.Api` class on an instance of the newer `pyyoutube.Client` class, which uses a different, structured interface.
fix
Refer to the latest documentation for `pyyoutube.Client`. For fetching channel info, use `client.channels.list(channel_id=...)` or similar structured calls instead.
Upgrade
Version history
0.9.9latest on PyPI · released Apr 17, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
python-youtube — pip install python-youtube · libregistry