Skip to main content

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.

ytscrape ships a built-in command-line interface that is available in two equivalent forms: as the ytscrape console script registered automatically when you install the package with pip, and as the python -m ytscrape module invocation. Both entry points share the same parser and produce identical output, so you can use whichever fits your workflow.

Global options

These flags apply to every subcommand and must be placed before the subcommand name.
FlagMetavarDefaultDescription
--languageHLenInterface language sent as the hl parameter, e.g. en, uk, de.
--regionGLUSContent region sent as the gl parameter, e.g. US, UA, DE.
--versionPrint the installed ytscrape version and exit.
# Print the installed version
ytscrape --version

# All subcommands accept --language and --region before the subcommand name
ytscrape --language uk --region UA search "музика" --max 5

Search YouTube and print matching results to stdout, one per line, in the format <title>\t<url>.
ytscrape search <query> [--filter FILTER] [--max N]
Argument / FlagTypeDefaultDescription
querypositional stringThe search query.
--filterchoiceallNarrow results by type. Accepted values: all, videos, channels, playlists, shorts, movies.
--maxinteger10Maximum number of results to print.
# Search for videos — return up to 10 results (default)
ytscrape search "python tutorial" --filter videos

# Search for channels and return up to 25 results
ytscrape search "python" --filter channels --max 25

# Search for playlists with no result cap
ytscrape search "lofi study" --filter playlists --max 50

# Localised search — Ukrainian interface and region
ytscrape --language uk --region UA search "музика" --max 10

video

Fetch and print metadata for a single YouTube video. Accepts either a bare video ID or any recognised YouTube URL (watch?v=, youtu.be/, /shorts/, /embed/).
ytscrape video <video>
ArgumentTypeDescription
videopositional stringVideo ID or URL.
The command prints the following fields:
FieldDescription
TitleVideo title.
ChannelUploader channel name.
ViewsTotal view count.
LengthDuration in seconds (printed with an s suffix, e.g. 213s).
URLCanonical watch URL.
# Fetch by full URL
ytscrape video https://www.youtube.com/watch?v=dQw4w9WgXcQ

# Fetch by bare video ID
ytscrape video dQw4w9WgXcQ

# Short URL form also works
ytscrape video https://youtu.be/dQw4w9WgXcQ

channel

Fetch and print metadata for a single YouTube channel. Accepts a bare channel ID (UC…), an @handle, or any recognised channel URL (/@handle, /channel/UC…, /c/…, /user/…).
ytscrape channel <channel>
ArgumentTypeDescription
channelpositional stringChannel ID, @handle, or URL.
The command prints the following fields (conditional fields are omitted when empty):
FieldDescription
TitleChannel display name.
Handle@handle of the channel.
SubscribersSubscriber count.
VideosTotal number of uploaded videos.
ViewsTotal channel view count.
CountryCountry set on the channel.
JoinedChannel creation date.
PhotoURL of the channel avatar.
BannerURL of the channel banner image.
Channel idInternal UC… channel identifier.
URLCanonical channel URL.
Vanity URLCustom /c/… URL, if set.
LinksExternal links listed on the channel.
# Fetch by @handle
ytscrape channel @RickAstleyYT

# Fetch by channel ID
ytscrape channel UCuAXFkgsw1L7xaCfnd5JJOw

# Fetch by full URL
ytscrape channel https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw

comments

Collect and print comments for a YouTube video. Each line is printed in the format <author>: <text>; replies are indented with a prefix.
ytscrape comments <video> [--max N] [--replies] [--sort top|newest]
Argument / FlagTypeDefaultDescription
videopositional stringVideo ID or URL.
--maxinteger20Maximum number of comments to print. Pass 0 for no limit.
--repliesflagoffAlso collect replies to every top-level comment.
--sortchoicetopSort order. Accepted values: top, newest.
# Fetch the top 20 comments (default)
ytscrape comments https://www.youtube.com/watch?v=dQw4w9WgXcQ

# Fetch up to 100 comments, including replies
ytscrape comments dQw4w9WgXcQ --max 100 --replies

# Fetch comments in newest-first order (no limit)
ytscrape comments dQw4w9WgXcQ --max 0 --sort newest
YouTube’s default “Top comments” view silently hides low-relevance comments and suspected spam, so a --sort top run will appear to skip some comments. Use --sort newest to collect every comment in reverse-chronological order — this is the only sort order that guarantees complete coverage.

transcript

Fetch and print the caption transcript for a YouTube video. Before the transcript lines, a summary header is printed in the form # <video_id> | <language_code> | generated=<bool> | snippets=<count>. Each subsequent line is printed with its timestamp offset and duration: [ 12.40 + 4.20] Hello world.
ytscrape transcript <video> [--lang CODE ...] [--list] [--preserve-formatting]
Argument / FlagTypeDefaultDescription
videopositional stringVideo ID or URL.
--lang CODErepeatable stringenPreferred language code. Repeat the flag to specify fallback languages tried in order.
--listflagoffList available caption tracks without downloading any transcript.
--preserve-formattingflagoffKeep basic HTML formatting tags (e.g. <b>, <i>) in snippet text.
# Fetch the English transcript (default)
ytscrape transcript dQw4w9WgXcQ

# Prefer Ukrainian, fall back to English if unavailable
ytscrape transcript dQw4w9WgXcQ --lang uk --lang en

# List all available caption tracks without downloading
ytscrape transcript dQw4w9WgXcQ --list

# Fetch English transcript, preserving HTML formatting tags
ytscrape transcript dQw4w9WgXcQ --lang en --preserve-formatting
Run --list first to discover which language codes are available for a video before fetching. Auto-generated tracks are clearly identified in the listing so you can choose between a human-edited caption and a machine-generated one.

Build docs developers (and LLMs) love