Short answer: add hl with a language code — "hl":"es", "hl":"de" — to your /youtube/transcripts request and you get that language's caption track, when the video has one. Always send hl: in our test, a request without it did not return English.
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":"iG9CE55wbtY","hl":"es"}'
id is the part after v= in the video address. The video here is a TED talk with captions in many languages.
What came back
Four requests for the same video on 2 December 2026:
| hl sent | language returned | caption lines | result |
|---|---|---|---|
| (none) | af (Afrikaans) | 417 | ok |
| es | es | 434 | ok |
| de | de | 421 | ok |
| ja | — | — | status 1502, not charged |
Each line carries its own language, so you can check what you got. Spanish, shortened:
{
"status": 0,
"credits_charged": 2,
"url": "https://www.youtube.com/watch?hl=es&v=iG9CE55wbtY",
"transcript": [
{"start_seconds": 26.9, "duration_seconds": 3.43, "language": "es", "text": "Buenos días. ¿Cómo están?"},
{"start_seconds": 31, "duration_seconds": 1.58, "language": "es", "text": "Ha sido increíble, ¿verdad?"}
]
}
The German track starts at 27.299 seconds with "Guten Morgen. Wie geht es Ihnen?". The tracks are separate translations, so line counts and timings differ slightly between languages (434 Spanish lines, 421 German).
On a second video, hl: "es" returned its Latin American Spanish track, labelled es-419.
Python: get a transcript in the first language that exists
import requests
def transcript(video_id, languages=("en", "es", "de")):
for hl in languages:
r = requests.post(
"https://api.serpbase.dev/youtube/transcripts",
headers={"X-API-Key": "YOUR_API_KEY"},
json={"id": video_id, "hl": hl},
timeout=60,
).json()
if r["status"] == 0 and r.get("transcript"):
got = r["transcript"][0]["language"]
if got.split("-")[0] == hl:
return got, r["transcript"]
return None, []
lang, lines = transcript("iG9CE55wbtY", ("ja", "es"))
print(lang, len(lines))
print(" ".join(l["text"] for l in lines[:5]))
Things that trip people up
- No
hlis not "English". Without it we got Afrikaans for an English-language talk. Send the language you want. - Check the returned
language. A regional code such ases-419can come back fores; compare the first part. - A language can fail. Japanese returned status 1502 for this video; handle it like any failed request. Failed requests are not charged, so falling back to another language costs nothing extra.
- Translations are separate tracks. Do not expect line N in Spanish to match line N in German; use
start_secondsto line them up.
Related
Cost and docs
Each transcript request is 2 credits; failed ones are not charged. New accounts get 500 free credits.
- Parameters: YouTube Transcripts docs
- Try it in the browser: YouTube Transcripts API
- Credit packs: pricing