YouTube Video Captions
Retrieve available caption tracks for a YouTube video or request captions in SRT, XML, JSON3, or plain-text format. Use it to support transcription, accessibility, localization, or text analysis.
/v1/youtube/get_video_captions_v1
$0.02
- Price
- $0.02 per successful call, Failed calls are free
- Endpoint ID
youtube.get_video_captions_v1
Parameters
-
video_idstring RequiredThe unique identifier for a YouTube video.
Example
dQw4w9WgXcQ -
language_codestring OptionalCaption language code, such as en, zh-Hans, or a.en. Leave it empty to retrieve available caption tracks.
Example
en -
formatstring OptionalCaption output format.
Available Values:
srt: SubRip caption format with timeline cuesxml: Original XML caption formatjson3: YouTube original JSON caption structuretxt: Plain text without timeline cues
Example
srt
Code samples
curl -G "https://api.mofa-ai.com/v1/youtube/get_video_captions_v1" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'video_id=dQw4w9WgXcQ' \
--data-urlencode 'language_code=en' \
--data-urlencode 'format=srt'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/youtube/get_video_captions_v1",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"video_id": "dQw4w9WgXcQ",
"language_code": "en",
"format": "srt",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/youtube/get_video_captions_v1");
url.search = new URLSearchParams({
video_id: "dQw4w9WgXcQ",
language_code: "en",
format: "srt",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
Example response
Request parameters {"format": "srt", "video_id": "dQw4w9WgXcQ", "language_code": "en"}
{
"success": true,
"code": 0,
"message": "success",
"request_id": "req_5f1c2a9be04d7c3a81f6e2d0",
"endpoint": "youtube.get_video_captions_v1",
"cost_usd": 0.02,
"data": {
"code": 0,
"data": {
"format": "srt",
"content": "1\n00:00:01,360 --> 00:00:03,040\n[♪♪♪]\n\n2\n00:00:18,640 --> 00:00:21,880\n♪ We're no strangers to love ♪\n\n3\n00:00:22,640 --> 00:00:26,960\n♪ You know the rules and so do I ♪\n\n4\n00:00:27,040 --> 00:00:31,0…",
"video_id": "dQw4w9WgXcQ",
"language_code": "en",
"language_name": "English"
},
"message": null,
"requestId": "9d20ad2945904a748f48fdfae13022fc",
"recordTime": "2026-11-08T08:00:12.224319946",
"requestParams": {
"body": null,
"query": {
"format": "srt",
"videoId": "dQw4w9WgXcQ",
"languageCode": "en"
}
}
}
}
Try it
Sign in to call this endpoint from this page. Successful calls are billed to your balance, failed calls are free, and new accounts get $0.50 of trial credit.
More YouTube endpoints
-
General Search
$0.02Search YouTube by keyword with optional type, upload-date, duration, feature, and sort filters, or continue with a token. Use it to discover videos, channels…
/v1/youtube/search_v1
-
Video Details
$0.02Retrieve public details for a YouTube video identified by video ID. Use it to inspect a known video before further content or comment analysis.
/v1/youtube/get_video_detail_v1
-
Channel Videos
$0.02Retrieve public videos from a YouTube channel, with optional cursor-based pagination. Use it to browse a channel's uploads and continue through additional re…
/v1/youtube/get_channel_videos_v1
-
Channel Shorts
$0.02Retrieve public Shorts from a YouTube channel ID with optional continuation-token pagination. Use it to browse a channel's short-form videos and continue thr…
/v1/youtube/get_channel_shorts_v1
-
Video Comment List
$0.02Retrieve first-level comments for a YouTube video with sorting, locale options, and cursor pagination. Use it to review audience discussion or continue throu…
/v1/youtube/get_video_comment_v1
-
Video Sub Comment List
$0.02Retrieve replies associated with a YouTube comment continuation cursor, with optional locale settings. Use it to follow threaded discussion beyond first-leve…
/v1/youtube/get_video_sub_comment_v1