What if you could collect YouTube search results, videos, channels, comments, replies, and transcripts through one Python interface?
No browser automation.
No Selenium.
No Playwright.
No YouTube API key.
Just Python and HTTP.
ytscrape is an open-source Python library designed to make collecting YouTube data simple, fast, and consistent.
🚀 Get started
GitHub: https://github.com/vsmutok/ytscrape
PyPI: https://pypi.org/project/ytscrape/
pip install ytscrape
Then:
from ytscrape import YouTube
with YouTube() as yt:
# Search
videos = yt.search("python", max_results=10)
# Video
video = yt.video("dQw4w9WgXQ")
# Channel
channel = yt.channel("@SomeChannel")
# Comments + replies
comments = yt.comments(
"dQw4w9WgXQ",
include_replies=True,
sort="newest",
)
# Transcript
transcript = yt.transcript(
"dQw4w9WgXQ",
languages=["en"],
)
One client. One interface. Multiple types of YouTube data.
Why ytscrape?
Working with YouTube data usually means choosing between different approaches.
The official YouTube Data API requires an API key and has quota limits.
Browser automation requires Selenium, Playwright, or another browser stack.
Other tools are focused primarily on downloading media.
But many projects don't need any of that.
Sometimes you simply need the data:
YouTube
│
├── Search
├── Videos
├── Channels
├── Comments
├── Replies
└── Transcripts
And you want to access all of it from Python.
That's the problem ytscrape is trying to solve.
One Python interface for collecting YouTube data.
Everything starts with one client
The API is intentionally simple:
from ytscrape import YouTube
with YouTube() as yt:
...
The same client gives you access to different parts of YouTube.
Search
for video in yt.search("python", max_results=10):
print(video.title, video.url)
Video metadata
video = yt.video(video_url)
print(video.title)
print(video.views)
print(video.length_seconds)
Channel metadata
channel = yt.channel("@SomeChannel")
print(channel.title)
print(channel.subscribers)
print(channel.video_count)
Comments
for comment in yt.comments(
video_url,
sort="newest",
):
print(comment.author, comment.text)
Replies
for comment in yt.comments(
video_url,
include_replies=True,
):
print(comment.author, comment.text)
Transcripts
transcript = yt.transcript(
video_url,
languages=["en", "uk"],
)
for line in transcript[:5]:
print(line.text)
Different data — same interface.
Built for data collection
ytscrape is designed around a simple idea:
You shouldn't have to build a different scraper for every type of YouTube data.
You can combine different operations into a single pipeline.
For example, imagine building a dataset of Python-related YouTube videos.
with YouTube() as yt:
for video in yt.search(
"python programming",
max_results=100,
):
details = yt.video(video.video_id)
comments = yt.comments(
video.video_id,
sort="newest",
)
transcript = yt.transcript(
video.video_id,
languages=["en"],
)
Now you can combine:
search → video metadata → comments → transcript
without introducing another library or browser automation framework.
Fast because there is no browser
One of the main design goals is to keep the library lightweight.
There is no need to start:
- Chrome
- Chromium
- Selenium
- Playwright
- a headless browser
ytscrape communicates with YouTube through HTTP and parses the responses into Python objects.
Under the hood, it uses YouTube's internal InnerTube endpoints — the same family of endpoints used by the YouTube web application.
The basic flow is:
Python
↓
ytscrape
↓
YouTube InnerTube
↓
HTTP response
↓
Typed Python model
This makes it possible to work with YouTube data without rendering web pages.
No API key
There is also no need to create a Google Cloud project or configure a YouTube Data API key.
Install:
pip install ytscrape
Start using it:
from ytscrape import YouTube
with YouTube() as yt:
for video in yt.search("machine learning", max_results=5):
print(video.title)
There is no API key configuration in your application.
Of course, this comes with a trade-off: ytscrape relies on YouTube's internal endpoints, so those endpoints can change.
If you need an officially supported API, the official YouTube Data API is still the right choice.
Comments are a first-class feature
One particularly useful part of ytscrape is comment collection.
You can retrieve top-level comments:
for comment in yt.comments(video_url):
print(comment.text)
Or include replies:
for comment in yt.comments(
video_url,
include_replies=True,
):
print(comment.author, comment.text)
And if you need to collect comments using newest-first ordering:
for comment in yt.comments(
video_url,
sort="newest",
):
print(comment.author, comment.text)
This makes the library useful for:
- NLP
- sentiment analysis
- audience research
- content analysis
- building datasets
Transcripts and subtitles
Video metadata is only part of the data available around a YouTube video.
The actual content of the video can also be useful.
ytscrape supports transcript retrieval:
transcript = yt.transcript(
video_url,
languages=["en", "uk"],
)
for line in transcript:
print(line.start, line.text)
This means a single workflow can combine:
Video
├── Metadata
├── Comments
├── Replies
└── Transcript
Pagination is handled for you
YouTube results are paginated.
With ytscrape, you don't have to manually implement continuation-token handling.
results = yt.search("python")
for video in results:
print(video.title)
The library loads additional pages as you iterate.
The same idea is used for comment collection.
You can also limit the amount of data:
yt.search(
"python",
max_results=100,
)
Typed Python models
Another goal of the project is to provide a clean Python API instead of exposing raw, deeply nested YouTube JSON.
The library provides models such as:
VideoVideoDetailsChannelChannelDetailsPlaylistComment
For example:
video.title
video.views
video.channel
video.url
The package is typed and PEP 561 compliant, so tools such as mypy and pyright can understand the models.
What's already supported?
Today, ytscrape supports:
| Feature | Status |
|---|---|
| YouTube search | ✅ |
| Video metadata | ✅ |
| Channel metadata | ✅ |
| Playlist search | ✅ |
| Shorts / movies search | ✅ |
| Comments | ✅ |
| Comment replies | ✅ |
| Newest-first comments | ✅ |
| Transcripts / subtitles | ✅ |
| Pagination | ✅ |
| Language / region | ✅ |
| Typed models | ✅ |
| CLI | ✅ |
And this is only the beginning.
What's coming next?
The long-term goal is to make ytscrape a general-purpose Python interface for YouTube data.
Some things already planned:
- ⚡ Async API
- 📺 Channel videos, Shorts, live, playlists and About tabs
- 🎵 Playlist items
- 🔗 Related videos
- 🔥 Trending
- 🏠 Home feed
- 🗒️ Community posts
- 📚 Dedicated documentation and API reference
So the project is not intended to stop at search + metadata.
The idea is to gradually cover more of the data available through YouTube's web application while keeping the Python API consistent.
Who is it for?
ytscrape can be useful if you are building:
Data pipelines
Collect structured YouTube data for further processing.
NLP / AI projects
Combine transcripts and comments to create datasets for analysis and research.
Market research tools
Analyze videos, channels, and audience discussions.
Content research tools
Search YouTube and collect information about content at scale.
Internal tools
Add YouTube data collection without introducing a full browser automation stack.
Python experiments
Quickly retrieve YouTube data without setting up an API project.
ytscrape vs. other approaches
Different tools solve different problems.
| ytscrape | YouTube Data API | yt-dlp | Browser automation | |
|---|---|---|---|---|
| API key | ❌ | ✅ | ❌ | ❌ |
| Browser | ❌ | ❌ | ❌ | ✅ |
| Search | ✅ | ✅ | ✅ | ✅ |
| Video metadata | ✅ | ✅ | ✅ | ✅ |
| Channel metadata | ✅ | ✅ | — | ✅ |
| Comments | ✅ | ✅ | ✅ | ✅ |
| Transcripts | ✅ | — | ✅ | ✅ |
| Typed Python models | ✅ | — | — | — |
| Media downloads | ❌ | ❌ | ✅ | ✅ |
A simple rule:
Need media downloads? → yt-dlp
Need official API access? → YouTube Data API
Need browser automation? → Playwright / Selenium
Need one lightweight Python interface for YouTube data? → ytscrape
Get started
Install the package:
pip install ytscrape
Then:
from ytscrape import YouTube
with YouTube() as yt:
for video in yt.search(
"python",
max_results=5,
):
print(video.title, video.url)
🚀 Project
GitHub: https://github.com/vsmutok/ytscrape
PyPI: https://pypi.org/project/ytscrape/
If you work with YouTube data in Python, I'd love to hear what you would like to see next.
Issues, ideas, pull requests, and contributions are welcome.
Important note
ytscrape communicates with YouTube's internal InnerTube endpoints rather than the official YouTube Data API.
These endpoints may change over time, and YouTube may throttle aggressive traffic.
Always make sure your use of the library complies with YouTube's current Terms of Service and applicable laws.
The project is provided for research and educational purposes, and you are responsible for how you use it.
Top comments (0)