Official Python SDK
YouTube transcripts in Python
The getyoutubetranscript package wraps the REST API for Python 3.9+. It returns the transcript, title and word count in one call, adds per-line timestamps on request, and covers YouTube search, channels and playlists. It works the same from a laptop, a server or a notebook, because YouTube never sees your IP.
Set it up
- 1
Install
Python 3.9 or newer:
pip install getyoutubetranscript - 2
Get an API key
Sign in at getyoutubetranscript.com and create a key on the developers page (100 free credits, no card). Keys start with sk_live_.
Get a transcript
from getyoutubetranscript import Client
client = Client(api_key="sk_live_...")
transcript = client.get_transcript("https://www.youtube.com/watch?v=jNQXAC9IVRw")
print(transcript["title"], transcript["word_count"])
print(transcript["transcript"])What you can do
- client.get_transcript("jNQXAC9IVRw", language="en", timestamps=True) adds a segments list with start and duration.
- Search YouTube, list a channel's or playlist's videos, and page through with continuation tokens.
- Errors raise GetYouTubeTranscriptError with the API's code, so you can skip videos without captions.
Links
Questions about Python
Why not use youtube-transcript-api?
That library scrapes YouTube from your machine, which YouTube blocks on most cloud servers. This SDK calls a hosted API that fetches captions server-side.
What does it cost?
Each transcript, search or channel page uses one credit from your account, and failed requests are not charged. New accounts get 100 free credits, no card, and paid plans add more credits each month.