Short answer: POST a video ID to /youtube/transcripts and you get the video's captions as JSON — one line per caption with its text, start time in seconds, duration and language.
The YouTube Data API only lets you download captions for videos you own (and costs quota per call). For transcripts of public videos — for summaries, search or LLM pipelines — you need another source.
The request
curl -X POST 'https://api.serpbase.dev/youtube/transcripts' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
-d '{"id":"jNQXAC9IVRw"}'
id is the part after watch?v= in the video URL.
What comes back
We tested two videos on 25 November 2026. jNQXAC9IVRw (the 19-second first YouTube upload) returned 6 caption lines in 3.8 seconds. dQw4w9WgXcQ (a music video) returned 61 lines in 8.4 seconds, the last one starting at 207.9 seconds.
Each item in transcript:
{
"start_seconds": 1.2,
"duration_seconds": 2.16,
"language": "en",
"text": "All right, so here we are, in front of the\nelephants"
}
Python: plain text and an SRT file
import requests
r = requests.post(
"https://api.serpbase.dev/youtube/transcripts",
headers={"X-API-Key": "YOUR_API_KEY"},
json={"id": "jNQXAC9IVRw"},
timeout=90,
).json()
if r["status"] != 0:
raise SystemExit(r.get("error"))
lines = r["transcript"]
print(" ".join(l["text"].replace("\n", " ") for l in lines))
def ts(s):
h, m = divmod(int(s), 3600)
m, sec = divmod(m, 60)
return f"{h:02}:{m:02}:{sec:02},{int((s % 1) * 1000):03}"
with open("captions.srt", "w") as f:
for i, l in enumerate(lines, 1):
end = l["start_seconds"] + l["duration_seconds"]
f.write(f"{i}\n{ts(l['start_seconds'])} --> {ts(end)}\n{l['text']}\n\n")
Things that trip people up
- Caption text keeps line breaks (
\n) as they appear on screen. Replace them with spaces before feeding text to a model. - Music videos are mostly lyrics and markers like
[♪♪♪]; filter those if you only want speech. - Videos without captions have nothing to return. Check
statusand handle the error rather than assuming every video has a transcript. - Long videos take longer. Our 3.5-minute video took 8.4 seconds; set a generous client timeout.
Related endpoints
Find the videos first with YouTube search, which returns video IDs, titles and channels; see also YouTube Search API without quota.
Cost and limits
Each request costs 2 credits; failed requests are not charged. Responses are HTTP 200 with a status field (0 = success). Credits cost $0.25–$0.50 per 1,000 depending on the plan; new accounts get 500 free credits without a card.
- Parameters and the full response: YouTube Transcripts docs
- Try it in the browser: YouTube Transcripts
- Credit packs: pricing