Skip to main content

Python client for the ScrapingBee YouTube API: search, video metadata, and subtitles as structured JSON

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube_scraper_api-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

youtube_scraper_api-0.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file youtube_scraper_api-0.0.1.tar.gz.

File metadata

  • Download URL: youtube_scraper_api-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for youtube_scraper_api-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9d8d00d8f94c5ba02f4e1e36dabe0f58a67d6c3162152804059be86ef044c4be
MD5 203070dde7e05e29c2067e0ce1613e3b
BLAKE2b-256 7cc4164624744ed60c38075a845ad037f6466035b8cd6ccd25625453a15470a6

See more details on using hashes here.

File details

Details for the file youtube_scraper_api-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_scraper_api-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0bda623e22a3c83e64f1961cc5aa679aa5d7978447e794d61ff9cebb12289b1
MD5 060af74ba37fd7112789df6eee094982
BLAKE2b-256 26aec64f02c1223ca6610b2f85b90ace6b016e890525c3248d0eb2f4733cebda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page