100 free credits. No credit card required. Get a key

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 failure
import 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

NameTypeDescription
idpath · requiredstringA video or Short id, or any URL of it (watch, youtu.be, shorts, live, embed). Example: dQw4w9WgXcQ.
languagequerystringISO 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.

FieldTypeDescription
kind"youtube#transcript"
videoIdstring
languageCodestring
languageNamestring
isAutoGeneratedboolean
isTranslatedbooleanTrue when YouTube machine-translated the track into the asked language.
textstringThe whole transcript, segments joined with spaces.
segmentsYouTubeTranscriptSegment[]
availableLanguagesYouTubeCaptionTrack[]
Status codes
StatusMeaning
200The transcript.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404The video, channel, playlist or post does not exist, was removed, or has nothing there.
429Too many requests. Wait for Retry-After seconds.
503YouTube 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.