urlstringจำเป็น
YouTube video or Short URL (e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ" or "https://www.youtube.com/shorts/Fir1x9cw2vg").
https://api.sandbase.ai/v1/api/youtube/video-transcript-fullFetch a YouTube video or Short transcript with timed segments and its provenance: whether the words are creator-written captions or machine speech recognition.
เอาต์พุตของคุณจะแสดงที่นี่
กรอกอินพุตให้ครบ แล้วคลิก Run
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.
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.
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Yes | YouTube video or Short URL (e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ" or "https://www.youtube.com/shorts/Fir1x9cw2vg"). |
captionKind | string | No | Which caption track to accept: "manual" only creator-written captions, "automatic" only YouTube's speech recognition, "any" whichever exists. |
language | string | No | 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 whi |
requireFields | array | No | 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 t |
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
}
| Field | Meaning |
|---|---|
data.transcript | The full transcript as one string. Segment texts are joined with spaces. |
data.segments[].text | The text of one caption line. |
data.segments[].startSeconds / data.segments[].endSeconds | Start and end time of the caption line, in seconds from the start of the video. |
data.isAutoGenerated | false when the captions were written by the creator. Expect true for machine speech recognition. |
data.isAiGenerated | Flag for AI-generated text. It is null in this response, so treat it as unknown. |
data.language | Language code of the transcript returned. It can differ from the language you asked for. |
data.title / data.channel / data.durationSeconds | Video title, channel name and video length in seconds. |
data.views | View count of the video. |
data.authorId / data.authorUrl | The channel ID and the channel URL of the video's author. |
data.videoId / data.url | The video ID and the canonical watch URL. |
captionKind to manual or automatic to accept only that caption type. With either value, no other language is returned.language, you get another language the video has. Check data.language to see which one.requireFields, such as views or likes, when you need them present. This can route the call to a different source and change the price.found: false. For more video metadata, call YouTube Video Details.Billed at the actual cost of each call, about $0.002 for the request above. Failed calls are not charged.
เริ่มสร้าง
เอ็นด์พอยต์ของ Platform API ที่มีการยืนยันตัวตนและการติดตามการใช้งานแบบรวมศูนย์
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",
"captionKind": "any"
}'ตั้งค่า SandBase API key ของคุณในสภาพแวดล้อมฝั่งเซิร์ฟเวอร์ คำขอจะใช้การยืนยันตัวตนแบบ Bearer
export SANDBASE_API_KEY="YOUR_API_KEY"เก็บ key ไว้บนเซิร์ฟเวอร์ อย่าเปิดเผยในโค้ดฝั่งเบราว์เซอร์
urlstringจำเป็นYouTube video or Short URL (e.g. "https://www.youtube.com/watch?v=dQw4w9WgXcQ" or "https://www.youtube.com/shorts/Fir1x9cw2vg").
languagestringPreferred 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.
captionKindstringWhich caption track to accept: "manual" only creator-written captions, "automatic" only YouTube's speech recognition, "any" whichever exists.
ค่าเริ่มต้น: "any"
ค่าที่เป็นไปได้: manual, automatic, any
requireFieldsarrayOptional; 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 นี้; จะไม่มีการส่งคำขอจริงเมื่อเปิดดู
ยังไม่มีการเผยแพร่การตอบกลับที่บันทึกไว้ ให้รัน API ใน Playground เพื่อดูการตอบกลับ
สำรวจเพิ่มเติม
| API | ราคา | การตอบกลับ |
|---|---|---|
YouTube | เริ่มต้นที่ $0.002 ต่อครั้ง | JSON |
YouTube | เริ่มต้นที่ $0.00045 ต่อครั้ง | JSON |
YouTube | เริ่มต้นที่ $0.0012 ต่อครั้ง | JSON |
YouTube | เริ่มต้นที่ $0.0012 ต่อครั้ง | JSON |
YouTube | เริ่มต้นที่ $0.0012 ต่อครั้ง | JSON |
YouTube | $0.014286 ต่อการเรียก | JSON |
คำถาม
ส่งคำขอ POST ไปที่ https://api.sandbase.ai/v1/api/youtube/video-transcript-full โดยใส่ SandBase API key ของคุณใน Authorization header (Bearer) และส่งพารามิเตอร์เป็น JSON body คุณยังสามารถลองใช้ได้ใน Playground บนหน้านี้โดยไม่ต้องเขียนโค้ด
เริ่มต้นที่ $0.002 ต่อครั้ง คิดจากยอดคงเหลือ SandBase ของคุณ คุณจะถูกเรียกเก็บเฉพาะคำขอที่คุณส่งเท่านั้น ไม่มีค่าสมาชิกรายเดือน
ที่ต้องระบุ: url (string). ตัวเลือก: language (string), captionKind (หนึ่งใน manual, automatic, any) และ requireFields (array). ตาราง Parameters และ Playground ในหน้านี้แสดงทุกฟิลด์
การตอบกลับ JSON ที่ส่งกลับในคำขอ HTTP เดียวกัน (แบบซิงโครนัส) README บนหน้านี้มีตัวอย่างการตอบกลับ
ไม่จำเป็น YouTube Video Transcript (Provenance) ทำงานผ่าน SandBase ดังนั้น SandBase API key เดียวครอบคลุม endpoint นี้และทุก API กับโมเดลอื่นในแค็ตตาล็อก คุณไม่ต้องสมัครขอสิทธิ์เข้าถึง YouTube API แยกต่างหาก