ytscrape hides YouTube’s continuation tokens behind plain Python iterators. The two paginated result types —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.
SearchResults (from yt.search()) and CommentThread (from yt.comments()) — share the same interface: iterate over them and pages load on demand; call fetch_next_page() when you want explicit control.
Automatic iteration
The simplest way to consume results is afor loop. The first page is fetched when you call search() or comments(), and subsequent pages are fetched automatically as your loop consumes items beyond the current buffer.
Capping results with max_results
Pass max_results to stop after a fixed number of items. The iterator returns cleanly once the cap is reached, even when more pages are available on YouTube’s side. Omit it entirely to exhaust every page.
CommentThread, max_results counts replies too when include_replies=True.
Manual paging with fetch_next_page() and has_more
Both SearchResults and CommentThread expose two members for explicit page control:
fetch_next_page()— loads the next page from YouTube, buffers the new items, and returns them as a list. Returns an empty list when no more pages are available.has_more—Trueas long as a continuation token is available.
Manual paging for comments
CommentThread.fetch_next_page() works identically and returns the comments (and any expanded replies) from the next page:
Collecting everything at once
Materialise the entire result set into a list by wrapping the iterable withlist(). All pages are fetched synchronously before list() returns.