A YouTube captions API for any public video
You want the subtitles of a YouTube video in your code. The official API won't give them to you unless you own the video. Here's what works instead.
Why the YouTube Data API doesn't work for this
The YouTube Data API v3 has a captions resource, and it looks like the obvious answer. In practice:
captions.downloadneeds OAuth from the video's owner. An API key isn't enough, and for videos on someone else's channel the call is refused.- It is expensive in quota. Listing tracks costs 50 units and downloading one costs 200, out of a default 10,000 units a day.
- It's built for creators managing their own subtitles, not for reading what is said in public videos.
So most developers end up scraping the captions YouTube shows in the player, with a library like youtube-transcript-api or yt-dlp. That works on a laptop, but YouTube blocks most cloud server IPs (see RequestBlocked errors).
One request, any public video
curl -H "x-api-key: YOUR_KEY" \ "https://api.transkrio.com/v1/transcript?url=https://youtu.be/dQw4w9WgXcQ&format=srt"
Pick the output with format:
| format | You get |
|---|---|
json (default) | Segments with text, start, duration, plus the joined text, language and is_generated |
text | Plain text, ready for an LLM |
markdown | Paragraphs of about a minute with timestamp links |
srt / vtt | Subtitle files you can edit, translate or re-upload |
Add lang=es (or any ISO code) for a specific language. If the video has no captions at all, the audio is transcribed instead, for 1 credit per started minute. A video with captions costs 1 credit, and failed requests are free.
Code
Full examples with error handling: Python and Node.js. For a whole channel or playlist, see transcribe a YouTube channel. For a single video without code, use the free YouTube transcript generator.