Sand AISand AI MAGI-2MAGI-2 現已登上 SandBase:支援原生音訊的 1080p 影片立即試用

YouTube Video Captions

API 文件
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.

價格
$0.008美元/次呼叫
方法
POST
回應
JSON
參數
0 個必填 · 4 個選填

Playground

輸入
Caption format
Language code (e.g. en, zh-Hans, a.en), returns available caption list if empty
Video ID (recommended)
Full video URL (optional)
輸出範例
回應outputs · 805 B · 11 行
[
  {
    "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"
    }
  }
]

範例

選擇一個範例,將其輸入與結果載入 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.

請提供 video_id 或 video_url;即使任一欄位單獨未標示為必填,仍需要影片輸入。將 language_code 留空即可探索可用軌道,接著使用回傳的語言代碼擷取字幕內容。請參考 Python YouTube transcript 指南,了解語言選擇、儲存 SRT,以及在研究中保留來源。

探索更多

相關 APIs

所有 APIs
API價格回應
YouTube每次呼叫 $0.008JSON
YouTube每次呼叫 $0.001JSON
YouTube每次呼叫 $0.001JSON
YouTube每次呼叫 $0.001JSON
YouTube每次呼叫 $0.001JSON
YouTube每次呼叫 $0.001JSON

指南:Best YouTube API in 2026: Pricing Compared

問題

常見問題

我要如何使用 YouTube Video Captions API?

使用 POST 請求將您的 SandBase API 金鑰放在 Authorization 標頭(Bearer)中,並以 JSON 主體傳入參數,即可呼叫 https://api.sandbase.ai/v1/api/youtube/web-v2/video-captions。您也可以直接在本頁的 Playground 試用,不必撰寫程式碼。

YouTube Video Captions API 的費用是多少?

每次 $0.008,並從您的 SandBase 餘額中扣款。您只會為實際發出的呼叫付費;沒有訂閱方案。

YouTube Video Captions API 接受哪些參數?

請提供 video_id 或 video_url 來識別影片。language_code 留空可列出可用的字幕軌,接著使用該影片回傳的語言代碼即可擷取內容。可選的 format 參數支援 srt、xml、json3 或 txt。請參考 README 與 Playground 取得目前的請求細節。

YouTube Video Captions API 會回傳什麼?

在同一個 HTTP 請求中回傳的 JSON 回應(同步)。 本頁的 README 包含範例回應。

我需要 YouTube 開發者帳號或 API 金鑰嗎?

不需要。YouTube Video Captions 是透過 SandBase 運作,因此一組 SandBase API 金鑰即可使用此端點以及目錄中的其他所有 API 和模型。您不需要另外申請 YouTube API 存取權。