YouTube Video Captions

API docs
https://api.sandbase.ai/v1/api/youtube/web-v2/video-captions

Returns available video caption tracks or transcripts in multiple formats, filtered by video identifier and language code.

Price
$0.008USD / call
Method
POST
Response
JSON
Parameters
0 required · 4 optional
100 free calls / dayFirst 100 calls per day free (shared per organization) · Resets at 00:00 UTC. Pay per call after that.

Playground

Input
Caption format
Language code (e.g. en, zh-Hans, a.en), returns available caption list if empty
Video ID (recommended)
Full video URL (optional)
OutputExample
Responseoutputs · 805 B · 11 lines
[
  {
    "data": {
      "content": "1\n00:00:00,080 --> 00:00:04,000\nCloud flare has released an AI agents\n\n2\n00:00:01,880 --> 00:00:06,240\nSDK it's durable objects but with\n\n3\n00:00:04,000 --> 00:00:08,000\nsuperpowers this makes building agents\n\n4\n00:00:06,240 --> 00:00:09,880\nmuch much easier as it handles the\n\n5\n00:00:08,000 --> 00:00:12,000\ncomplex parts for you like persisting\n\n6\n00:00:09,880 --> 00:00:14,000\nState handling long running tasks and\n\n7\n00:00:12,000 --> 00:00:15,440\neven horizontal scaling this is just the\n\n8\n00:00:14,000 --> 00:00:17,080\nbeginning too the road map talks of\n\n9\n00:00:15,440 --> 00:00:19,119\naddin…",
      "format": "srt",
      "language_code": "en",
      "language_name": "English",
      "video_id": "l4tHKJFQvRg"
    }
  }
]

Examples

Select an example to load its inputs and result into the playground.

API README

YouTube Video Captions API

Returns the caption text of a YouTube video for one language, in the format you choose (srt, xml, json3 or txt). It needs a video_id or a video_url, plus a language_code. If you leave language_code empty, it returns the list of available caption tracks instead.

Use cases

  • Pull English subtitles as txt to feed a video summarization workflow.
  • Download srt files with timestamps to build subtitles for a re-upload or translation.
  • Fetch json3 captions to index spoken words for search.
  • Check which caption languages a video offers before choosing one to download.

Request

curl -X POST "https://api.sandbase.ai/v1/api/youtube/web-v2/video-captions" \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"video_id": "dQw4w9WgXcQ", "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "language_code": "en", "format": "srt"}'

The result is returned in outputs[0].data.

Parameters

NameTypeRequiredDescription
formatstringNoCaption format
language_codestringNoLanguage code (e.g. en, zh-Hans, a.en), returns available caption list if empty
video_idstringNoVideo ID (recommended)
video_urlstringNoFull video URL (optional)

Example response

Real response for the request above, trimmed: lists keep their first item and long strings are cut.

{
  "content": "1\n00:00:01,360 --> 00:00:03,040\n[♪♪♪]\n\n2\n00:00:18,640 --> 00:00:21,880\n♪ We're n…",
  "format": "srt",
  "language_code": "en",
  "language_name": "English",
  "video_id": "dQw4w9WgXcQ"
}

Response fields

FieldMeaning
contentThe full caption text in the requested format. For srt, each cue has a number, a start and end time in HH:MM:SS,mmm form, and the caption line. Sound cues such as [♪♪♪] appear as text.
formatThe caption format of content, matching the format you requested.
language_codeThe language code of the returned captions, for example en.
language_nameThe readable name of the caption language, for example English.
video_idThe ID of the video the captions belong to.

Notes

  • Send video_id when you can. video_url is optional and is not needed if you have the ID.
  • The video_id is the value after v= in a watch URL, for example dQw4w9WgXcQ.
  • Language codes can be plain, like en or zh-Hans, or auto-generated tracks like a.en.
  • format defaults to srt when you leave it out.

Pricing

$0.008 per successful call. Failed calls are not charged. It is included in the daily free quota of each organization.

Provide a video_id or video_url; a video input is required even when neither field is individually marked required. Leave language_code empty to discover tracks, then use a returned language code to retrieve caption content. Follow the Python YouTube transcript guide for language selection, saving SRT and preserving sources for research.

Explore more

Related APIs

All APIs
APIPriceResponse
YouTube$0.008 per callJSON
YouTube$0.001 per callJSON
YouTube$0.001 per callJSON
YouTube$0.001 per callJSON
YouTube$0.001 per callJSON
YouTube$0.001 per callJSON

Questions

FAQ

How do I use the YouTube Video Captions API?

Send a POST request to https://api.sandbase.ai/v1/api/youtube/web-v2/video-captions with your SandBase API key in the Authorization header (Bearer) and the parameters as a JSON body. You can also try it in the Playground on this page without writing code.

How much does the YouTube Video Captions API cost?

$0.008 per call. Every organization gets 100 free calls per UTC day, shared across eligible SandBase APIs including this one; after that each call is billed at this price from your SandBase balance. There is no subscription.

What parameters does the YouTube Video Captions API accept?

Provide video_id or video_url to identify the video. Leave language_code empty to list available caption tracks, then use a language code returned for that video to retrieve content. The optional format parameter accepts srt, xml, json3 or txt. See the README and Playground for the current request details.

What does the YouTube Video Captions API return?

A JSON response returned in the same HTTP request (synchronous). The README on this page includes a sample response.

Do I need a YouTube developer account or API key?

No. YouTube Video Captions runs through SandBase, so one SandBase API key covers this endpoint and every other API and model in the catalog. You do not need to apply for YouTube API access separately.