ytscrape is a free, open-source Python library that lets you search YouTube, extract video and channel metadata, collect comments and replies, and fetch transcripts — all without an API key, a quota, or a headless browser. It communicates directly with YouTube’s internal InnerTube API (the same private endpoints the YouTube web app itself uses) through plain HTTP requests, parses the responses into fully-typed, frozen dataclasses, and handles pagination for you automatically.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vsmutok/ytscrape/llms.txt
Use this file to discover all available pages before exploring further.
Features
No API Key Required
ytscrape uses YouTube’s internal InnerTube endpoints — no Google Cloud project, no credential management, and no quota to exhaust.
No Browser Needed
Pure HTTP only. No Selenium, no Playwright, no headless Chrome. Install it and start scraping immediately.
Search YouTube
Search for videos, channels, playlists, Shorts, and movies using
SearchFilter. Pass a max_results cap or iterate indefinitely.Video & Channel Metadata
Fetch rich details via
yt.video() and yt.channel(). Typed models surface every field — views, duration, subscribers, join date, links, and more.Comments & Replies
Collect every comment with
yt.comments(). Include threaded replies with include_replies=True, and use CommentSort.NEWEST to ensure no comment is skipped.Transcripts & Subtitles
List available caption tracks with
yt.transcripts() and download a preferred one with yt.transcript(). Manual captions are automatically preferred over auto-generated ones.How ytscrape Compares
| ytscrape | YouTube Data API | yt-dlp | Browser automation | |
|---|---|---|---|---|
| API key required | ❌ | ✅ | ❌ | ❌ |
| Daily quota | ❌ | ✅ | ❌ | ❌ |
| Browser / driver needed | ❌ | ❌ | ❌ | ✅ |
| Search | ✅ | ✅ | ✅ | ✅ |
| Video metadata | ✅ | ✅ | ✅ | ✅ |
| Comments + replies | ✅ | ✅ (quota) | ✅ | ✅ |
| Typed Python models | ✅ | ❌ | ❌ | ❌ |
| Downloads media | ❌ | ❌ | ✅ | ✅ |
| Install size | tiny | medium | large | huge |
yt-dlp when you need to download media, the official Data API when you need guaranteed, ToS-blessed access, and ytscrape when you need fast, key-less access to YouTube metadata and comments from Python.
How It Works
ytscrape speaks YouTube’s private InnerTube API directly, with no browser in the loop:-
Context extraction. On first use, ytscrape fetches
youtube.comonce and extracts the InnerTube context — the API key, client version, and visitor data — embedded in the page’s initial JavaScript. -
POST requests. Every subsequent call POSTs to one of YouTube’s internal JSON endpoints —
youtubei/v1/search,youtubei/v1/player,youtubei/v1/browse, oryoutubei/v1/next— with that context attached as the request body. -
Typed parsing. Responses are parsed from deeply-nested JSON into small, frozen dataclasses (
Video,Channel,VideoDetails,Comment, etc.) with full type hints. The package shipspy.typed, so mypy and pyright see every field. - Transparent pagination. Continuation tokens returned by YouTube are stored internally. Iterating the result object automatically fires the next page request whenever you exhaust the current batch — you never handle tokens manually.
ytscrape accesses YouTube’s private, undocumented endpoints. The API contracts and internal
params values may change without notice. Use this library responsibly, respect YouTube’s Terms of Service, and avoid aggressive request rates. It is provided for research and educational purposes — you are responsible for your usage.