idstring
YouTube video ID. A Short uses the same ID as any other video.
https://api.sandbase.ai/v1/api/youtube/video-transcriptFetch the transcript/captions of a YouTube video or Short by URL or ID.
出力はここに表示されます
入力を完了してから[実行]をクリックしてください。
Returns the transcript of a YouTube video or Short as plain text and as timed segments. You pass either a video url or a video id.
curl -X POST "https://api.sandbase.ai/v1/api/youtube/video-transcript" \
-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.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | No | YouTube video ID. A Short uses the same ID as any other video. |
url | string | No | Full YouTube video URL. Shorts (youtube.com/shorts/...), youtu.be, live, and embed URLs all work. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"data": {
"language": "en",
"segments": [
{
"durationSeconds": 1.68,
"startSeconds": 1.36,
"text": "[♪♪♪]"
}
],
"transcript": "[♪♪♪]\n♪ We're no strangers to love ♪\n♪ You know the rules and so do I ♪\n♪ A full…"
},
"found": true
}
| Field | Meaning |
|---|---|
found | true when a transcript was found for the video. A lookup that finds nothing returns found: false. |
data.language | Language code of the transcript, for example en. |
data.transcript | The full transcript as one string. Each caption line is separated by a newline. |
data.segments[].text | The text of one caption line. Music cues such as [♪♪♪] can appear as text. |
data.segments[].startSeconds | Start time of the segment, in seconds from the beginning of the video. |
data.segments[].durationSeconds | How long the segment lasts, in seconds. |
url or id. A Short uses the same ID as any other video, and youtube.com/shorts/..., youtu.be, live, and embed URLs all work for url.id is the value after v= in a standard watch URL, for example dQw4w9WgXcQ.data.transcript for the whole text and data.segments when you need timing.Billed at the actual cost of each call, about $0.0009 for the request above. Failed calls are not charged.
開発を始める
統一認証と使用状況の追跡を備えたプラットフォームAPIエンドポイントです。
curl -X POST "https://api.sandbase.ai/v1/api/youtube/video-transcript" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}'SandBaseのAPIキーをサーバー環境に設定してください。リクエストはBearer認証を使用します。
export SANDBASE_API_KEY="YOUR_API_KEY"キーはサーバー側で管理してください。ブラウザコードに公開しないでください。
idstringYouTube video ID. A Short uses the same ID as any other video.
urlstringFull YouTube video URL. Shorts (youtube.com/shorts/...), youtu.be, live, and embed URLs all work.
このAPIの保存済みサンプルレスポンスです。表示時にライブリクエストは行われません。
保存済みレスポンスはまだ公開されていません。PlaygroundでAPIを実行し、レスポンスを確認してください。
さらに探索
| API | 価格 | レスポンス |
|---|---|---|
YouTube Video Transcriptこの API YouTube | 1回あたり $0.0009 から | JSON |
YouTube | 1回あたり $0.00045 から | JSON |
YouTube | 1回あたり $0.0012 から | JSON |
YouTube | 1回あたり $0.0012 から | JSON |
YouTube | 1回あたり $0.0012 から | JSON |
YouTube | $0.014286 / 回 | JSON |
質問
Authorization ヘッダー(Bearer)に SandBase API key を指定し、パラメータを JSON ボディで送信して https://api.sandbase.ai/v1/api/youtube/video-transcript に POST リクエストを送ります。このページの Playground で、コードを書かずに試すこともできます。
1回あたり $0.0009 から、SandBase 残高から課金されます。課金対象はご利用分のみで、サブスクリプションはありません。
必須パラメータはありません。 任意: id (string) と url (string)。 このページの Parameters テーブルと Playground に、すべてのフィールドが一覧表示されています。
同じ HTTP リクエスト内で返される JSON レスポンスです(同期)。 このページの README にサンプルレスポンスがあります。
いいえ。YouTube Video Transcript は SandBase 経由で動作するため、SandBase の API key 1つでこのエンドポイントと、カタログ内の他のすべての API とモデルを利用できます。YouTube の API アクセスを別途申請する必要はありません。