# Research: Python Libraries for YouTube Read-Only Operations
## Overview
This document provides a comprehensive analysis of Python libraries available for interacting with YouTube in **read-only mode**. These libraries enable functionalities such as searching videos/channels, retrieving video metadata, fetching playlists, and extracting transcriptions—all without requiring video downloads.
---
## 1. Official YouTube Data API v3
### Description
Google's official YouTube Data API provides programmatic access to YouTube data including videos, playlists, channels, and search functionality.
### Installation
```bash
pip install google-api-python-client google-auth-oauthlib google-auth-httplib2
```
### Features
| Feature | Supported |
|---------|-----------|
| Search videos/channels/playlists | ✅ |
| Get video metadata | ✅ |
| Get channel information | ✅ |
| Get playlist contents | ✅ |
| Get comments | ✅ |
| Read-only scope available | ✅ |
### Read-Only Scope
```
https://www.googleapis.com/auth/youtube.readonly
```
### Pros
- Official and well-documented
- Reliable and maintained by Google
- Comprehensive data access
- Supports OAuth 2.0 and API keys
### Cons
- Requires API key (free tier has quotas)
- Rate limited (10,000 units/day default)
- Setup complexity with Google Cloud Console
### Example Usage
```python
from googleapiclient.discovery import build
youtube = build('youtube', 'v3', developerKey='YOUR_API_KEY')
# Search for videos
request = youtube.search().list(
part='snippet',
q='python tutorial',
type='video',
maxResults=10
)
response = request.execute()
```
### Links
- [Documentation](https://developers.google.com/youtube/v3)
- [Python Quickstart](https://developers.google.com/youtube/v3/quickstart/python)
---
## 2. youtube-transcript-api
### Description
A Python API to retrieve transcripts/subtitles for YouTube videos. Works with both manual and auto-generated subtitles without requiring a headless browser.
### Installation
```bash
pip install youtube-transcript-api
```
### Features
| Feature | Supported |
|---------|-----------|
| Fetch video transcripts | ✅ |
| Auto-generated subtitles | ✅ |
| Manual subtitles | ✅ |
| Multiple languages | ✅ |
| Translate transcripts | ✅ |
| List available transcripts | ✅ |
| CLI support | ✅ |
### Pros
- No API key required
- No selenium/browser needed
- Fast and lightweight
- Supports translation
- Well-maintained and actively developed
### Cons
- Only for transcripts (no video metadata)
- Depends on YouTube's internal structure
- May break if YouTube changes their page structure
### Example Usage
```python
from youtube_transcript_api import YouTubeTranscriptApi
# Get transcript for a video
transcript = YouTubeTranscriptApi.get_transcript('VIDEO_ID')
# Get transcript in specific language
transcript = YouTubeTranscriptApi.get_transcript('VIDEO_ID', languages=['de', 'en'])
# List available transcripts
transcript_list = YouTubeTranscriptApi.list_transcripts('VIDEO_ID')
for transcript in transcript_list:
print(f"{transcript.language_code}: {transcript.language}")
```
### Links
- [PyPI](https://pypi.org/project/youtube-transcript-api/)
- [GitHub](https://github.com/jdepoix/youtube-transcript-api)
---
## 3. youtube-search-python
### Description
Search for YouTube videos, channels, and playlists without the official YouTube API. Also provides video information retrieval and transcript access.
### Installation
```bash
pip install youtube-search-python
```
### Features
| Feature | Supported |
|---------|-----------|
| Search videos | ✅ |
| Search channels | ✅ |
| Search playlists | ✅ |
| Get video details | ✅ |
| Get channel videos | ✅ |
| Get playlist videos | ✅ |
| Get comments | ✅ |
| Get transcripts | ✅ |
| Pagination support | ✅ |
| Async support | ✅ |
### Pros
- No API key required
- Comprehensive feature set
- Async support available
- Active community
### Cons
- May break with YouTube changes
- Last updated June 2022 (check for maintenance)
### Example Usage
```python
from youtubesearchpython import VideosSearch, Video, Playlist, Channel
# Search for videos
search = VideosSearch('python programming', limit=10)
print(search.result())
# Get video information
video_info = Video.getInfo('https://youtube.com/watch?v=VIDEO_ID')
# Get playlist videos
playlist = Playlist('https://youtube.com/playlist?list=PLAYLIST_ID')
print(playlist.videos)
# Get channel videos
channel = Channel.get('CHANNEL_ID')
```
### Links
- [PyPI](https://pypi.org/project/youtube-search-python/)
- [GitHub](https://github.com/alexmercerind/youtube-search-python)
---
## 4. scrapetube
### Description
A lightweight YouTube scraper for getting videos from channels, playlists, and search results without the official API or Selenium.
### Installation
```bash
pip install scrapetube
```
### Features
| Feature | Supported |
|---------|-----------|
| Get channel videos | ✅ |
| Get playlist videos | ✅ |
| Search YouTube | ✅ |
| Sort results | ✅ |
| Content type filter (videos/shorts/streams) | ✅ |
| Proxy support | ✅ |
| Rate limiting protection | ✅ |
### Pros
- Very simple API
- No API key required
- No Selenium required
- Actively maintained (2025)
- Lightweight
### Cons
- Limited to listing videos (minimal metadata)
- No transcript support
- No detailed video info
### Example Usage
```python
import scrapetube
# Get all videos from a channel
videos = scrapetube.get_channel("UCCezIgC97PvUuR4_gbFUs5g")
for video in videos:
print(video['videoId'], video['title'])
# Get playlist videos
videos = scrapetube.get_playlist("PL-osiE80TeTt2d9bfVyTiXJA-UTHn6WwU")
# Search YouTube
videos = scrapetube.get_search("python tutorial", limit=20)
# Get channel videos sorted by popularity
videos = scrapetube.get_channel("CHANNEL_ID", sort_by="popular")
# Get only shorts
videos = scrapetube.get_channel("CHANNEL_ID", content_type="shorts")
```
### Links
- [PyPI](https://pypi.org/project/scrapetube/)
- [GitHub](https://github.com/dermasmid/scrapetube)
- [Documentation](https://scrapetube.readthedocs.io/)
---
## 5. yt-dlp
### Description
A feature-rich command-line audio/video downloader. While primarily for downloading, it excels at extracting metadata without downloading.
### Installation
```bash
pip install yt-dlp
```
### Features
| Feature | Supported |
|---------|-----------|
| Extract video metadata | ✅ |
| Get video info without download | ✅ |
| Playlist information | ✅ |
| Channel information | ✅ |
| Comments extraction | ✅ |
| Subtitle/transcript extraction | ✅ |
| Thumbnail extraction | ✅ |
| Format information | ✅ |
### Pros
- Extremely comprehensive metadata
- Supports thousands of sites
- Very actively maintained
- Robust error handling
- Highly configurable
### Cons
- Larger dependency
- Primarily designed for downloading
- Can be slower for simple metadata tasks
### Example Usage (Read-Only)
```python
import yt_dlp
# Extract info without downloading
ydl_opts = {
'quiet': True,
'no_warnings': True,
'extract_flat': True, # Don't download
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info('https://youtube.com/watch?v=VIDEO_ID', download=False)
print(f"Title: {info['title']}")
print(f"Duration: {info['duration']}")
print(f"View count: {info['view_count']}")
print(f"Channel: {info['channel']}")
print(f"Upload date: {info['upload_date']}")
# Get playlist info
with yt_dlp.YoutubeDL({'extract_flat': True}) as ydl:
playlist_info = ydl.extract_info('PLAYLIST_URL', download=False)
for entry in playlist_info['entries']:
print(entry['title'])
```
### Available Metadata Fields
- `title`, `description`, `duration`, `view_count`, `like_count`
- `channel`, `channel_id`, `channel_url`
- `upload_date`, `thumbnail`, `tags`, `categories`
- `formats`, `subtitles`, `automatic_captions`
### Links
- [PyPI](https://pypi.org/project/yt-dlp/)
- [GitHub](https://github.com/yt-dlp/yt-dlp)
---
## 6. pytube
### Description
A lightweight Python library for downloading YouTube videos. Also provides metadata access.
### Installation
```bash
pip install pytube
```
### Features
| Feature | Supported |
|---------|-----------|
| Video metadata | ✅ |
| Playlist access | ✅ |
| Channel access | ✅ |
| Caption/transcript access | ✅ |
| Stream information | ✅ |
### Pros
- Lightweight
- Simple API
- Good for basic metadata
### Cons
- Maintenance issues (frequent breaking)
- Less reliable than yt-dlp
- Limited error handling
### Example Usage
```python
from pytube import YouTube, Playlist, Channel
# Get video info
yt = YouTube('https://youtube.com/watch?v=VIDEO_ID')
print(f"Title: {yt.title}")
print(f"Views: {yt.views}")
print(f"Length: {yt.length}")
print(f"Author: {yt.author}")
# Get captions
captions = yt.captions
for caption in captions:
print(caption.code, caption.name)
# Get playlist videos
playlist = Playlist('PLAYLIST_URL')
for video in playlist.videos:
print(video.title)
```
### Links
- [PyPI](https://pypi.org/project/pytube/)
- [GitHub](https://github.com/pytube/pytube)
---
## 7. youtube-extract
### Description
Extracts metadata for all videos from a YouTube channel into CSV or XLSX format.
### Installation
```bash
pip install youtube_extract
```
### Features
| Feature | Supported |
|---------|-----------|
| Channel video extraction | ✅ |
| Export to CSV/XLSX | ✅ |
| Comprehensive metadata | ✅ |
### Extracted Fields
- `author`, `channel_url`, `title`, `webpage_url`
- `view_count`, `like_count`, `duration`, `upload_date`
- `tags`, `categories`, `description`, `thumbnail`
- `best_format`, `filesize_bytes`
### Example Usage
```bash
youtube_extract "CHANNEL_URL"
youtube_extract "CHANNEL_URL" -e xlsx
```
### Links
- [PyPI](https://pypi.org/project/youtube-extract/)
- [GitHub](https://github.com/dbeley/youtube_extract)
---
## Comparison Matrix
| Library | API Key | Search | Video Info | Playlists | Channels | Transcripts | Maintenance |
|---------|---------|--------|------------|-----------|----------|-------------|-------------|
| YouTube Data API v3 | Required | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ Official |
| youtube-transcript-api | No | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ Active |
| youtube-search-python | No | ✅ | ✅ | ✅ | ✅ | ✅ | ⚠️ 2022 |
| scrapetube | No | ✅ | ⚠️ Basic | ✅ | ✅ | ❌ | ✅ Active |
| yt-dlp | No | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ Active |
| pytube | No | ❌ | ✅ | ✅ | ✅ | ✅ | ⚠️ Unstable |
| youtube-extract | No | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ Active |
---
## Recommendations by Use Case
### 1. **Searching YouTube (videos, channels, playlists)**
**Primary:** `scrapetube` or `youtube-search-python`
- Simple, no API key needed
- Good for listing and basic info
### 2. **Detailed Video Metadata**
**Primary:** `yt-dlp`
- Most comprehensive metadata
- Reliable and well-maintained
### 3. **Fetching Transcripts/Subtitles**
**Primary:** `youtube-transcript-api`
- Purpose-built for transcripts
- Supports translation
- Very reliable
### 4. **Channel/Playlist Video Listing**
**Primary:** `scrapetube`
- Simple API
- Actively maintained
- No dependencies on browsers
### 5. **Production/Commercial Use**
**Primary:** `YouTube Data API v3`
- Official and supported
- Terms of service compliant
- Predictable quotas
### 6. **Comprehensive Solution (All Features)**
**Combined approach:**
```python
# Search and list videos
import scrapetube
# Get detailed metadata
import yt_dlp
# Get transcripts
from youtube_transcript_api import YouTubeTranscriptApi
```
---
## Best Practices
1. **Rate Limiting**: Always implement delays between requests to avoid being blocked
2. **Error Handling**: YouTube's structure changes; implement robust error handling
3. **Caching**: Cache results to minimize API calls
4. **Terms of Service**: Review YouTube's ToS before scraping
5. **Fallback Libraries**: Have backup libraries in case one breaks
---
## Conclusion
For building a read-only YouTube tool, the recommended stack is:
1. **scrapetube** - For searching and listing videos/channels/playlists
2. **yt-dlp** - For extracting comprehensive video metadata
3. **youtube-transcript-api** - For fetching transcripts
This combination provides complete coverage without requiring API keys while maintaining reliability through actively maintained libraries.
---
*Research conducted: January 2026*
*Last updated: January 2026*