YouTube subtitles download API
A YouTube video’s captions as a ready subtitle file: srt, vtt, ttml, json3 or srv1.
GET /v1/youtube/videos/{id}/subtitlesBeta2 credits per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/youtube/videos/dQw4w9WgXcQ/subtitles?format=vtt",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 2 credits{ "kind": "youtube#subtitles", "videoId": "dQw4w9WgXcQ", "languageCode": "en", "isAutoGenerated": false, "isTranslated": false, "format": "vtt", "content": "WEBVTT\nLanguage: en\n\n00:00:01.360 --> 00:00:03.040\n[♪♪♪]\n\n00:00:18.640 --> 00:00:21.880\n♪ We're no strangers to love ♪\n\n…", "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. |
formatquery | "srt" | "vtt" | "ttml" | "json3" | "srv1" | srt (default), vtt, ttml, json3 or srv1. One of srt, vtt, ttml, json3, srv1. |
languagequery | string | ISO 639-1 language code (en, es, pt-BR). Example: en. |
Response fields
200 with a YouTubeSubtitles, in the shape of YouTube Data API v3 resources.
| Field | Type | Description |
|---|---|---|
kind | "youtube#subtitles" | |
videoId | string | |
languageCode | string | |
isAutoGenerated | boolean | |
isTranslated | boolean | |
format | "srt" | "vtt" | "ttml" | "json3" | "srv1" | |
content | string | The subtitle file, in format. |
availableLanguages | YouTubeCaptionTrack[] |
Status codes
| Status | Meaning |
|---|---|
200 | The subtitle file. |
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
Which languages?
The tracks the video has, creator-made first; availableLanguages lists them.
YouTube is a trademark of Google LLC. We are not affiliated with or endorsed by Google or YouTube.