youtube-scraper-api
Pull YouTube search results, video metadata, and subtitles as parsed JSON. A thin Python wrapper over the ScrapingBee YouTube scraper API that handles authentication, headless rendering, and proxies behind a single Bearer-token request.
pip install youtube-scraper-api
Covers the queries people reach for: youtube scraper, youtube scraping api, youtube video scraper, youtube scraper api, and youtube data scraper. Requires Python 3.8+ and requests. Built on the ScrapingBee YouTube API.
30-second example
from youtube_scraper_api import YouTubeScraper
yt = YouTubeScraper(api_key="YOUR_API_KEY")
# 1. find videos
hits = yt.search("python tutorial", type="video", sort_by="view_count")
video_id = hits["results"][0]["videoId"]
# 2. enrich one of them
details = yt.metadata(video_id)
# 3. grab its captions
captions = yt.subtitles(video_id, language="en")
Get a key first: ScrapingBee gives 1,000 credits with no card at scrapingbee.com.
The client
YouTubeScraper(api_key: str, timeout: int = 60)
Authentication is a Bearer token, set for you on every call. The client drops any None arguments before sending the request.
Methods
search(search, type=None, upload_date=None, duration=None, sort_by=None, hd=False, fourk=False, subtitles=False, creative_commons=False, live=False, tag=None, extra=None)
Query YouTube for videos, channels, or playlists. search is the only required argument.
| Argument | API parameter | Accepted values |
|---|---|---|
search |
search |
any query string |
type |
type |
video, channel, playlist, movie |
upload_date |
upload_date |
today, last_hour, this_week, this_month, this_year |
duration |
duration |
<4, 4-20, >20 |
sort_by |
sort_by |
rating, relevance, view_count, upload_date |
hd, fourk, subtitles, creative_commons, live |
hd, 4k, subtitles, creative_commons, live |
booleans |
tag |
tag |
custom id echoed back in the response |
extra |
(any) | dict for other documented flags: 360, 3d, hdr, vr180, location, purchased |
metadata(video_id)
Return full details for one video: duration, view count, like count, upload date, description, channel info, thumbnails, and available formats. This is the building block of a YouTube data scraper that enriches a list of ids.
subtitles(video_id, language=None, subtitle_origin=None)
Return timestamped caption segments. subtitle_origin selects auto-generated or uploader-provided captions when both exist.
Returned fields
search() returns a results list. Each item carries the fields YouTube rendered, commonly:
videoId, title, longBylineText, thumbnail, lengthText,
shortViewCountText, publishedTimeText
Not every field appears on every result, so use .get() rather than direct indexing.
Credits
ScrapingBee bills successful calls. search() is 5 credits per call. The cost for metadata() and subtitles() is shown in the dashboard request builder. Plan tiers: scrapingbee.com/pricing.
Notes
- A YouTube video scraper built this way needs no headless browser or proxy management on your side; ScrapingBee does both.
- Scrape public content only. ScrapingBee's terms prohibit scraping behind a login.
Links
License
MIT
Disclaimer
Unofficial Python client built on the ScrapingBee YouTube API. Not affiliated with ScrapingBee or YouTube. Comply with YouTube's terms of service and applicable law.
Metadata
Release files for youtube-scraper-api 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youtube_scraper_api-0.0.1.tar.gz | 4.9 kB | Without provenance | Details for youtube_scraper_api-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youtube_scraper_api-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for youtube_scraper_api-0.0.1-py3-none-any.whl |
Total release size: 10.2 kB
Release files / youtube_scraper_api-0.0.1.tar.gz
| Download URL | youtube_scraper_api-0.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d8d00d8f94c5ba02f4e1e36dabe0f58a67d6c3162152804059be86ef044c4be
|
|
BLAKE2b-256 checksum How to use checksums |
7cc4164624744ed60c38075a845ad037f6466035b8cd6ccd25625453a15470a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / youtube_scraper_api-0.0.1-py3-none-any.whl
| Download URL | youtube_scraper_api-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0bda623e22a3c83e64f1961cc5aa679aa5d7978447e794d61ff9cebb12289b1
|
|
BLAKE2b-256 checksum How to use checksums |
26aec64f02c1223ca6610b2f85b90ace6b016e890525c3248d0eb2f4733cebda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for youtube-scraper-api 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.