This guide walks you through installing ytscrape and using its three most common features: searching YouTube for videos, fetching detailed metadata for a single video, and collecting comments. By the end you will have working Python snippets you can run immediately and adapt for your own projects.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.
Install ytscrape
ytscrape is published on PyPI and requires Python 3.10 or newer. Install it with your preferred package manager:Verify the installation by importing the package and checking its version:
Search for videos
Use Each
YouTube.search() with SearchFilter.VIDEOS to find videos matching a query. The result is a lazy, paginated object — iterating it loads more pages on demand. The max_results argument caps how many items are consumed.video in the loop is a typed Video dataclass. Its most useful fields are video_id, title, channel, channel_id, duration, views, published, thumbnail, and url.Fetch video details
Call
YouTube.video() with a video id or any YouTube URL to retrieve a VideoDetails object packed with rich metadata. The watch?v=, youtu.be/, /shorts/, and /embed/ URL formats are all accepted.VideoDetails fields include video_id, title, description, channel, channel_id, length_seconds (int), views (int), keywords, is_live, thumbnail, and url.Collect comments
YouTube.comments() returns a lazy CommentThread iterable. Use include_replies=True to collect threaded replies alongside top-level comments — each reply arrives right after its parent and has is_reply=True.Pass sort=CommentSort.NEWEST to ensure every comment is returned. YouTube’s default "top" order silently omits less-relevant comments and potential spam, so NEWEST is the right choice whenever completeness matters.Next Steps
- Installation — Python version requirements, all runtime dependencies, and how to install from source.
- Guides — Deep dives into search filters, language and region localisation, transparent pagination, channel metadata, transcripts, error handling, and advanced configuration (proxies, retries, custom sessions).