YouTube transcript API
The transcript of a YouTube video from its captions (creator-made first, else auto-generated): timestamped segments and the whole text, in the original spoken language or one you choose.
GET /v1/youtube/videos/{id}/transcriptBeta2 credits per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/youtube/videos/dQw4w9WgXcQ/transcript?language=en",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 2 credits{ "kind": "youtube#transcript", "videoId": "dQw4w9WgXcQ", "languageCode": "en", "languageName": "English", "isAutoGenerated": false, "isTranslated": false, "text": "[♪♪♪] ♪ We're no strangers to love ♪ ♪ You know the rules and so do I ♪ ♪ A full commitment's what I'm thinking of ♪ ♪ Y…", "segments": [ { "startMs": 1360, "durationMs": 1680, "text": "[♪♪♪]" }, { "startMs": 18640, "durationMs": 3240, "text": "♪ We're no strangers to love ♪" }, "… 18 more" ], "availableLanguages": [ { "languageCode": "en", "name": "English", "isAutoGenerated": false, "isTranslatable": true }, { "languageCode": "en", "name": "English (auto-generated)", "isAutoGenerated": true, "isTranslatable": true }, "… 4 more" ]}Parameters
| Name | Type | Description |
|---|---|---|
idpath · required | string | A video or Short id, or any URL of it (watch, youtu.be, shorts, live, embed). Example: dQw4w9WgXcQ. |
languagequery | string | ISO 639-1 language code (en, es, pt-BR). Example: en. |
original_audioquery | "0" | "1" | "true" | "false" | true: only the original spoken language (wins over language). One of 0, 1, true, false. |
Response fields
200 with a YouTubeTranscript, in the shape of YouTube Data API v3 resources.
| Field | Type | Description |
|---|---|---|
kind | "youtube#transcript" | |
videoId | string | |
languageCode | string | |
languageName | string | |
isAutoGenerated | boolean | |
isTranslated | boolean | True when YouTube machine-translated the track into the asked language. |
text | string | The whole transcript, segments joined with spaces. |
segments | YouTubeTranscriptSegment[] | |
availableLanguages | YouTubeCaptionTrack[] |
Status codes
| Status | Meaning |
|---|---|
200 | The transcript. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | The video, channel, playlist or post does not exist, was removed, or has nothing there. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | YouTube is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
What if there are no captions?
The call answers 404 target_not_found and is never charged. Asking for a language the video has no track in does the same, with the available languages in the hint.
YouTube is a trademark of Google LLC. We are not affiliated with or endorsed by Google or YouTube.