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

YouTube Video Transcript (Provenance)

API 文件
https://api.sandbase.ai/v1/api/youtube/video-transcript-full

Fetch a YouTube video or Short transcript with timed segments and its provenance: whether the words are creator-written captions or machine speech recognition.

價格
自 $0.002 起美元/次呼叫
方法
POST
回應
JSON
參數
1 個必填 · 3 個選填

Playground

輸入
YouTube video or Short URL (e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ" or "https://www.youtube.com/shorts/Fir1x9cw2vg").
Preferred caption language code (e.g. "en", "es"). Defaults to English. If the video has no captions in that language, you get the transcript in another language the video has; the `language` field in the result says which. With `captionKind` set to "manual" or "automatic", no other language is returned.
Which caption track to accept: "manual" only creator-written captions, "automatic" only YouTube's speech recognition, "any" whichever exists.
Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `views`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a transcript that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge.
輸出就緒

您的輸出會顯示在這裡

完成輸入後,點擊執行。

API README

YouTube Video Transcript (Provenance) API

Returns the transcript of a YouTube video or Short as full text and as timed segments. It also says whether the captions were written by the creator or generated by speech recognition. It needs a YouTube video or Short URL.

Use cases

  • Index the spoken text of a video so you can search it by keyword.
  • Pull timed lines from a video to build subtitles or jump links to exact moments.
  • Check whether a video has creator-written captions before you rely on the text for quoting.
  • Collect a video's transcript together with its title, channel and view count for content analysis.

Request

curl -X POST "https://api.sandbase.ai/v1/api/youtube/video-transcript-full" \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}'

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

Parameters

NameTypeRequiredDescription
urlstringYesYouTube video or Short URL (e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ" or "https://www.youtube.com/shorts/Fir1x9cw2vg").
captionKindstringNoWhich caption track to accept: "manual" only creator-written captions, "automatic" only YouTube's speech recognition, "any" whichever exists.
languagestringNoPreferred caption language code (e.g. "en", "es"). Defaults to English. If the video has no captions in that language, you get the transcript in another language the video has; the language field in the result says whi
requireFieldsarrayNoOptional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example views, and it is served only by a source that returns every one of t

Example response

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

{
  "data": {
    "authorId": "UCuAXFkgsw1L7xaCfnd5JJOw",
    "authorUrl": "https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw",
    "channel": "Rick Astley",
    "description": "The official video for “Never Gonna Give You Up” by Rick Astley. \n\nNever: The Au…",
    "durationSeconds": 213,
    "image": "https://i.ytimg.com/vi/dQw4w9WgXcQ/sddefault.jpg",
    "isAiGenerated": null,
    "isAutoGenerated": false,
    "keywords": [
      "rick astley"
    ],
    "language": "en",
    "segments": [
      {
        "endSeconds": 3.04,
        "startSeconds": 1.36,
        "text": "[♪♪♪]"
      }
    ],
    "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)"
  },
  "found": true
}

Response fields

FieldMeaning
data.transcriptThe full transcript as one string. Segment texts are joined with spaces.
data.segments[].textThe text of one caption line.
data.segments[].startSeconds / data.segments[].endSecondsStart and end time of the caption line, in seconds from the start of the video.
data.isAutoGeneratedfalse when the captions were written by the creator. Expect true for machine speech recognition.
data.isAiGeneratedFlag for AI-generated text. It is null in this response, so treat it as unknown.
data.languageLanguage code of the transcript returned. It can differ from the language you asked for.
data.title / data.channel / data.durationSecondsVideo title, channel name and video length in seconds.
data.viewsView count of the video.
data.authorId / data.authorUrlThe channel ID and the channel URL of the video's author.
data.videoId / data.urlThe video ID and the canonical watch URL.

Notes

  • Set captionKind to manual or automatic to accept only that caption type. With either value, no other language is returned.
  • If the video has no captions in the requested language, you get another language the video has. Check data.language to see which one.
  • Name fields in requireFields, such as views or likes, when you need them present. This can route the call to a different source and change the price.
  • If nothing is found, the call still succeeds and returns found: false. For more video metadata, call YouTube Video Details.

Pricing

Billed at the actual cost of each call, about $0.002 for the request above. Failed calls are not charged.

探索更多

相關 APIs

所有 APIs
API價格回應
YouTube每次呼叫 $0.002 起JSON
YouTube每次呼叫 $0.00045 起JSON
YouTube每次呼叫 $0.0012 起JSON
YouTube每次呼叫 $0.0012 起JSON
YouTube每次呼叫 $0.0012 起JSON
YouTube每次呼叫 $0.014286JSON

指南:Best YouTube API in 2026: Pricing Compared

問題

常見問題

我要如何使用 YouTube Video Transcript (Provenance) API?

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

YouTube Video Transcript (Provenance) API 的費用是多少?

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

YouTube Video Transcript (Provenance) API 接受哪些參數?

必要:url (string)。 選填:language (string), captionKind(manual, automatic, any 之一) 和 requireFields (array)。 本頁的 Parameters 表格與 Playground 會列出每個欄位。

YouTube Video Transcript (Provenance) API 會回傳什麼?

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

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

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