# FlashData YouTube Transcript API

เรียกข้อมูล YouTube สําเนาข้อความด้วยเวลาและเอกสารเต็ม เลือกคําบรรยายภาพให้อัตโนมัติโดยค่าปริยาย

อ้างอิงทางคลอง: https://flashdata.dev/th/docs/sources/youtube_transcript
Recorder: 2026-10-23

จุดสิ้นสุด: POST https://data.flashdata.dev/v1/queries/realtime
การยืนยันตัวตน: X-API-Key: YOUR_API_KEY
โหมด: [Realtime](https://flashdata.dev/th/docs/reference/realtime-and-async/reference.md#realtime) · [Async](https://flashdata.dev/th/docs/reference/realtime-and-async/reference.md#async) · [Batch](https://flashdata.dev/th/docs/reference/batch-and-bulk/reference.md#batch) · [Bulk](https://flashdata.dev/th/docs/reference/bulk-processing/reference.md)

ต้องการสิทธิ์ที่อนุญาตจากแหล่ง: youtube_transcript

แทนที่ YOUR_API_KEY ด้วย API กุญแจที่มีแหล่งที่ได้รับอนุญาตนี้ และหน่วยกิตที่มีอยู่ ประมวลผลการร้องขอบนเซิร์ฟเวอร์หรือโฮสต์ตัวแทนของคุณ

[ตั้งค่าการตรวจสอบสิทธิ์](https://flashdata.dev/th/docs/guides/headers-and-authentication/reference.md)

[เลือกภาษาและร่องเสียงแบบสําเนา](https://flashdata.dev/th/docs/guides/youtube-data-guide/reference.md#captions)

<a id="quickstart"></a>

## ส่งคําขอมา

### Python

```bash
python3 -m pip install requests
```

```python
import json

import requests

api_key = "YOUR_API_KEY"
payload = {
    "source": "youtube_transcript",
    "video_id": "dQw4w9WgXcQ",
    "params": {
        "language": "en",
        "auto": True,
    },
}

response = requests.post(
    "https://data.flashdata.dev/v1/queries/realtime",
    headers={"X-API-Key": api_key},
    json=payload,
    timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2))
```

### Bash / cURL

```bash
api_key="YOUR_API_KEY"
curl --fail-with-body --max-time 120 --request POST "https://data.flashdata.dev/v1/queries/realtime" \
  --header "Content-Type: application/json" \
  --header "X-API-Key: $api_key" \
  --data-binary @- <<'FLASHDATA_JSON'
{
  "source": "youtube_transcript",
  "video_id": "dQw4w9WgXcQ",
  "params": {
    "language": "en",
    "auto": true
  }
}
FLASHDATA_JSON
```

<a id="parameters"></a>

## พารามิเตอร์

<a id="parameters-group-0"></a>

### เนื้อหาคำขอ

| พารามิเตอร์ | ชนิด | จำเป็น | ค่าเริ่มต้น | คําอธิบาย |
| --- | --- | --- | --- | --- |
| <a id="parameter-source"></a> source | string | ใช่ | — | กําหนดเป็น youtube_transcript  |
| <a id="parameter-video_id"></a> video_id | string | ใช่ | ยังไม่ได้ตั้งค่า | เดอะ 11- ช่างทําเล็บ YouTube วิดีโอ IDเช่น FUFGCZ092b0. รับจดหมาย ตัวเลข อุปทาน และไฮเฟน ความยาวน้อยที่สุด: 11. ความยาวสูงสุด: 11. รูปแบบ: ^[A-Za-z0-9_-]{11}$ |
| <a id="parameter-params"></a> params | object | ไม่ | {} | Settings สําหรับการร้องขอนี้  |
| <a id="parameter-callback_url"></a> callback_url | string · nullable | ไม่ | ยังไม่ได้ตั้งค่า | Async และชุดเท่านั้น สาธารณะ HTTPS เสร็จสมบูรณ์แล้ว URL บนพอร์ต 443ถึง 2,048 ตัวละคร ไม่มีเอกสารรับรองผู้ใช้หรือส่วน URL Omit, ใช้ null หรือข้อความเปล่าสําหรับไม่ให้แจ้งเตือน ในชุดนี้ กําหนดให้แต่ละคําถาม ภายนอกพม่า  |

<a id="parameters-group-1"></a>

### เลือกคําบรรยายภาพ

| พารามิเตอร์ | ชนิด | จำเป็น | ค่าเริ่มต้น | คําอธิบาย |
| --- | --- | --- | --- | --- |
| <a id="parameter-params-language"></a> params.language | string \| array | ไม่ | en-orig → en | Omit สําหรับภาษาอังกฤษ (n-orig, แล้ว en). ด้วย อัตโนมัติ = true รหัสแต่ละตัวจะลองใช้ - ออร์แกนแทร็คก่อน จากนั้นใช้รหัสที่ต้องการ explicit - รหัสออริกและอัตโนมัติ = false คงที่ อาร์เรย์ร้องขอภาษาต่างๆ 1–10 โอมิธชอบเอนออริกมากกว่า และถอยกลับไป en, กลับมาหนึ่งแทร็ค ด้วยอัตโนมัติ=trueโค้ดแต่ละตัวลองติดตาม - orig ก่อน แล้วรหัสที่ต้องการ; โดยตรง - arig รหัสและออโต้=false อยู่เฉยๆนะ อาร์เรย์ของ 1–10 รหัสที่แตกต่างกัน ลองทุกภาษาที่ต้องการ และส่งกลับร่องเสียงและข้อผิดพลาดต่อลา ในลําดับที่ต้องการ languageCode ระบุว่าเป็นเพลงที่เลือก requestedLanguageCode จะรวมเข้าไป เมื่อมันแตกต่างจากรหัสที่ต้องการ |
| <a id="parameter-params-auto"></a> params.auto | boolean | ไม่ | true | true เลือก YouTube- คําบรรยายที่แต่งขึ้น; false เลือกคําบรรยายภาพที่อัปโหลดมา เลือกตัวเลือกนี้ เพื่อเลือกส่วนกํากับ ไม่ใช่การเลือกภาษา หรือตัวแปลคําสั่งใหม่  |

<a id="response"></a>

## อ่านผลที่ออกมา

บันทึกความสําเร็จ JSON ตอบกลับเป็น response.json. บันทึกนี้เป็น read-response.py และเรียกไพธอน read-response.py. มันใช้เฉพาะ Pythonห้องสมุดมาตรฐาน และไม่มีการร้องขอใหม่

### read-response.py

```python
import json
from pathlib import Path

response = json.loads(Path("response.json").read_text(encoding="utf-8-sig"))
if response.get("status") not in ("done", "completed") or not isinstance(response.get("results"), list):
    raise SystemExit("Expected completed result JSON; inspect the response or job status.")
if not response["results"]:
    print("[]")
    raise SystemExit(0)
result = response["results"][0]

output = {
    "tracks": result.get("tracks", [result]),
    "errors": result.get("errors", []),
}
print(json.dumps(output, ensure_ascii=False, indent=2))
```

## ตัวอย่างคำตอบ

ตัว อย่าง ที่ บันทึก ไว้; ทุ่ง นา และ การ นับ ขึ้น อยู่ กับ แหล่ง กําเนิด และ ข้อ เรียก ร้อง ให้ นํา เข้า.
```json
{
  "source": "youtube_transcript",
  "status": "done",
  "results": [
    {
      "videoId": "dQw4w9WgXcQ",
      "languageCode": "en",
      "languageName": null,
      "isAutoGenerated": true,
      "segments": [
        {
          "start": 0.32,
          "end": 14.58,
          "text": "[Music]"
        },
        {
          "start": 18.8,
          "end": 25.96,
          "text": "We're no strangers to"
        },
        {
          "start": 21.8,
          "end": 29.119,
          "text": "love. You know the rules and so do"
        },
        {
          "start": 25.96,
          "end": 30.279,
          "text": "I. I feel commitments from what I'm"
        },
        {
          "start": 29.119,
          "end": 34.36,
          "text": "thinking"
        },
        {
          "start": 30.279,
          "end": 39.559,
          "text": "of. You wouldn't get this from any other"
        },
        {
          "start": 34.36,
          "end": 43.12,
          "text": "guy. I just want to tell you how I'm"
        },
        {
          "start": 39.559,
          "end": 45.84,
          "text": "feeling. Got to make you understand."
        },
        {
          "start": 43.12,
          "end": 49.2,
          "text": "Never going to give you up. I'm going to"
        },
        {
          "start": 45.84,
          "end": 53.32000000000001,
          "text": "let you down. I'm going to run around"
        },
        {
          "start": 49.2,
          "end": 56.399,
          "text": "and desert you. I'm going to make"
        },
        {
          "start": 53.32,
          "end": 59.879,
          "text": "you say goodbye."
        },
        {
          "start": 56.399,
          "end": 64.04,
          "text": "Tell a lie and hurt"
        },
        {
          "start": 59.879,
          "end": 67.2,
          "text": "you. We've known each other for so"
        },
        {
          "start": 64.04,
          "end": 70.56,
          "text": "long. Your heart's been aching, but"
        },
        {
          "start": 67.2,
          "end": 72.60000000000001,
          "text": "you're too shy to say we don't know"
        },
        {
          "start": 70.56,
          "end": 77.799,
          "text": "what's been going"
        },
        {
          "start": 72.6,
          "end": 81.479,
          "text": "on. We know the game and we're going to"
        },
        {
          "start": 77.799,
          "end": 84.56,
          "text": "play. If you ask me how I'm"
        },
        {
          "start": 81.479,
          "end": 88.32,
          "text": "feeling, don't tell me your truth. to"
        },
        {
          "start": 84.56,
          "end": 88.32000000000001,
          "text": "see. I will give"
        },
        {
          "start": 89.88,
          "end": 94.72,
          "text": "you"
        },
        {
          "start": 91.72,
          "end": 94.72,
          "text": "around"
        },
        {
          "start": 95,
          "end": 99.04,
          "text": "you. I will say"
        },
        {
          "start": 99.56,
          "end": 106.759,
          "text": "goodbye and hurt you. I will give"
        },
        {
          "start": 103.99,
          "end": 108.6,
          "text": "[Music]"
        },
        {
          "start": 106.759,
          "end": 115.92,
          "text": "you"
        },
        {
          "start": 108.6,
          "end": 115.92,
          "text": "around you. I will leave you. I will say"
        },
        {
          "start": 116.439,
          "end": 121.079,
          "text": "goodbye and hurt you."
        },
        {
          "start": 128.319,
          "end": 132.56,
          "text": "Never going to give. Never going to"
        },
        {
          "start": 129.759,
          "end": 134,
          "text": "give."
        },
        {
          "start": 132.56,
          "end": 136.8,
          "text": "Never going to give. Never going to"
        },
        {
          "start": 134,
          "end": 141.04,
          "text": "give."
        },
        {
          "start": 136.8,
          "end": 143.68,
          "text": "We've known each other for so long."
        },
        {
          "start": 141.04,
          "end": 147.51999999999998,
          "text": "Your heart's been aching, but you're too"
        },
        {
          "start": 143.68,
          "end": 148.52,
          "text": "shy to say it. We both know what's been"
        },
        {
          "start": 147.52,
          "end": 152.239,
          "text": "going"
        },
        {
          "start": 148.52,
          "end": 157.8,
          "text": "on. We know the game and we're going to"
        },
        {
          "start": 152.239,
          "end": 161.36,
          "text": "play it. I just want to tell you how I'm"
        },
        {
          "start": 157.8,
          "end": 163.92000000000002,
          "text": "feeling. Got to make you understand."
        },
        {
          "start": 161.36,
          "end": 166.8,
          "text": "Never going to give you up. Never going"
        },
        {
          "start": 163.92,
          "end": 171.28,
          "text": "to let you down. Never going to run"
        },
        {
          "start": 166.8,
          "end": 171.28,
          "text": "around and desert you. Heat."
        },
        {
          "start": 172.33,
          "end": 182.76,
          "text": "[Music]"
        },
        {
          "start": 178.76,
          "end": 182.76,
          "text": "Heat. Heat. Heat."
        },
        {
          "start": 183.39,
          "end": 195.2,
          "text": "[Music]"
        },
        {
          "start": 191.04,
          "end": 197.76,
          "text": "Never going to tell a lie and hurt you."
        },
        {
          "start": 195.2,
          "end": 200.64,
          "text": "Never going to give you up. Never going"
        },
        {
          "start": 197.76,
          "end": 204.239,
          "text": "to let you down. Never going to run"
        },
        {
          "start": 200.64,
          "end": 206.83999999999995,
          "text": "around and desert you. Never going to"
        },
        {
          "start": 204.239,
          "end": 211.879,
          "text": "make you cry. Never going to say"
        },
        {
          "start": 206.84,
          "end": 211.879,
          "text": "goodbye. Never going to say goodbye."
        }
      ],
      "fullText": "[Music] We're no strangers to love. You know the rules and so do I. I feel commitments from what I'm thinking of. You wouldn't get this from any other guy. I just want to tell you how I'm feeling. Got to make you understand. Never going to give you up. I'm going to let you down. I'm going to run around and desert you. I'm going to make you say goodbye. Tell a lie and hurt you. We've known each other for so long. Your heart's been aching, but you're too shy to say we don't know what's been going on. We know the game and we're going to play. If you ask me how I'm feeling, don't tell me your truth. to see. I will give you around you. I will say goodbye and hurt you. I will give [Music] you around you. I will leave you. I will say goodbye and hurt you. Never going to give. Never going to give. Never going to give. Never going to give. We've known each other for so long. Your heart's been aching, but you're too shy to say it. We both know what's been going on. We know the game and we're going to play it. I just want to tell you how I'm feeling. Got to make you understand. Never going to give you up. Never going to let you down. Never going to run around and desert you. Heat. [Music] Heat. Heat. Heat. [Music] Never going to tell a lie and hurt you. Never going to give you up. Never going to let you down. Never going to run around and desert you. Never going to make you cry. Never going to say goodbye. Never going to say goodbye."
    }
  ],
  "usage": {
    "credits": 0.01
  },
  "created_at": "2026-09-16T07:45:44.040Z"
}
```

## หลายภาษา

ส่งอาร์เรย์ภาษาเพื่อรับแทร็กเสียงและข้อมูลข้อผิดพลาดต่อลา ตัวอย่างนี้แสดงภาษาอังกฤษและภาษาสเปนไม่สามารถใช้งานได้

```json
{
  "source": "youtube_transcript",
  "video_id": "jNQXAC9IVRw",
  "params": {
    "language": [
      "en",
      "es"
    ],
    "auto": true
  }
}
```

`results[0]`:

```json
{
  "videoId": "jNQXAC9IVRw",
  "isAutoGenerated": true,
  "tracks": [
    {
      "videoId": "jNQXAC9IVRw",
      "languageCode": "en-orig",
      "requestedLanguageCode": "en",
      "languageName": null,
      "isAutoGenerated": true,
      "segments": [
        {
          "start": 0,
          "end": 1.5,
          "text": "Hello world."
        }
      ],
      "fullText": "Hello world."
    }
  ],
  "errors": [
    {
      "languageCode": "es",
      "code": "language_unavailable",
      "message": "Auto-generated subtitles not available for language: es"
    }
  ]
}
```

## ช่องข้อมูลแบบวนรอบ

| ช่องข้อมูล | ชนิด | คําอธิบาย |
| --- | --- | --- |
| source | string | สิ่งที่ร้องขอมา API แหล่งข่าว |
| status | string | เสร็จสิ้นเมื่อการร้องขอจริง สําเร็จ |
| created_at | string | ช่วงเวลาการสร้างแบบ ISO 8601 |
| usage.credits | number | บัตรเครดิตตามที่ขอ จากแผนของคุณ |
| results[0].videoId | string | รายการที่ขอมาคือ ID |
| results[0].languageCode | string | อักขระกํากับการทํางานที่ถูกเลือก เช่น en-orig |
| results[0].languageName | string · nullable | แสดงผลชื่อภาษาหากมีอยู่ |
| results[0].requestedLanguageCode | string · optional | โค้ดที่ต้องการเมื่อมันแตกต่างจาก languageCode เป็นต้นเมื่อ Ann-orig ถูกเลือก |
| results[0].isAutoGenerated | boolean | จะให้สร้างคําบรรยายภาพที่เลือกไว้โดยอัตโนมัติหรือไม่ |
| results[0].segments | array | สัดส่วนตามเวลา |
| results[0].segments[].start | number | เวลาเริ่มต้นของ seckment ในวินาที. |
| results[0].segments[].end | number | เวลาสิ้นสุด seckment ในวินาที. |
| results[0].segments[].text | string | ข้อความคําบรรยายภาพ |
| results[0].fullText | string | ข้อความทุกส่วนถูกรวมเป็นสําเนา |
| results[0].tracks | array · optional | สําหรับภาษาอาร์เรย์เท่านั้น มีร่องเสียงอยู่ในลําดับที่ต้องการ แต่ละเพลงมีช่องข้อมูลแบบเดี่ยวที่แสดงอยู่ด้านบน |
| results[0].errors | array · optional | สําหรับภาษาอาร์เรย์เท่านั้น ภาษาล้มเหลวในลําดับที่ต้องการ ว่างเปล่าเมื่อทุกแทร็กประสบความสําเร็จ |
| results[0].errors[].languageCode | string | ภาษาที่ต้องการล้มเหลว |
| results[0].errors[].code | string | language_unavailable เมื่อเพลงที่เลือกยังไม่มีอยู่ retrieval_failed เมื่อไม่สามารถดาวน์โหลดหรือวิเคราะห์ได้ |
| results[0].errors[].message | string | คําบรรยายความล้มเหลวของภาษา |

- เดอะ API อ่านคําบรรยายภาพที่มีอยู่แล้วบน YouTube. มันไม่ได้สร้างสําเนาใหม่ ๆ หรือถอยกลับไประหว่างตัวอัปโหลดอัตโนมัติกับตัวอัปโหลด
- ภาษาสตริงคงการตอบรับแบบเดี่ยว อาร์เรย์, แม้แต่"en"HOURSฟังก์ชัน () จะคืนค่ากลับมาเป็นชั่วโมงของค่าเวลาที่กําหนด languageCodeสัดส่วนและ fullText. แต่ละแทร็กมีสนามกีฬาเหล่านั้น อัตโนมัติใช้ได้กับทุกภาษา
- เมื่อระบุอาร์เรย์ภาษา ให้ดู errors เพื่อทราบว่าแทร็กใดดึงข้อมูลไม่สำเร็จ หากดึงข้อมูลไม่ได้สักแทร็ก คำขอจะล้มเหลวและระบบจะคืนเครดิตที่กันไว้ การดึงข้อมูลวิดีโอล้มเหลวหรือคำขอหมดเวลาก็ทำให้คำขอล้มเหลวเช่นกัน
- มีเวลาจริง, async, patch และ จํานวนมาก Bulk การส่งออกยังคงอยู่ JSONL ด้วยบันทึกหนึ่งอันต่อวิดีโอ รวมทั้งร่องรอยและข้อผิดพลาด Accept ถึง X-Respond-With นําไปใช้ตามปกติ

## รูปแบบคำตอบ

การตอบสนองต่าง ๆ ใช้ JSON โดยปริยายแล้ว เลือกรูปแบบอื่นด้วยส่วนหัวแบบเสริมเหล่านี้

- Accept: application/json (ค่าปริยาย) หรือ text/plain. ข้อความธรรมดาแสดงสนามเดียวกัน ในผังที่อ่านได้ และไม่สามารถเปลี่ยนแปลงได้
- X-Respond-With: markdown. ไม่ต้องตั้งค่าสําหรับสนามเดิม Markdown ทํางานกับรูปแบบการตอบสนองต่าง ๆ

Markdown มีการใช้งานสําหรับลําดับเวลาจริงและผลลัพธ์ที่เสร็จสมบูรณ์

ช่องข้อมูลด้านล่างนี้ ใช้อธิบายค่าปริยาย JSON ตอบสนอง

[ตัวอย่างการร้องขอและรูปแบบการตอบสนอง](https://flashdata.dev/th/docs/guides/response-formats/reference.md#headers)

<a id="job-lifecycle"></a>

<a id="async-batch"></a>

## พื้นฐาน API

ตัวสร้างและตัวอย่างที่ต้องการด้านบน ใช้พารามิเตอร์ของแหล่งนี้ ใช้ Python ถึง cURL ตัวอย่างด้านล่างนี้ สําหรับการร่วมยอมจํานน สถานะ และขั้นตอนที่มีผล A Batch ร่างกายคือ JSON ออบเจกต์ที่มีลําดับ; แต่ละรายการจะคืนงานของมันเอง ID.

- [Async ร้องขอและใบเสร็จ](https://flashdata.dev/th/docs/reference/realtime-and-async/reference.md#async)

<a id="job-status"></a>

- [ตรวจสอบสถานะงานพิมพ์](https://flashdata.dev/th/docs/reference/realtime-and-async/reference.md#status)

<a id="job-results"></a>

- [ดึงข้อมูลผลลัพธ์ที่เสร็จสมบูรณ์แล้ว](https://flashdata.dev/th/docs/reference/realtime-and-async/reference.md#results)
- [Batch JSON ต้องการ](https://flashdata.dev/th/docs/reference/batch-and-bulk/reference.md#batch)
- [API ประมวลผล Bulk](https://flashdata.dev/th/docs/reference/bulk-processing/reference.md)
- [สร้าง Bulk การ ไหล เวียน ของ แหล่ง นี้](https://flashdata.dev/th/docs/reference/bulk-processing/reference.md?source=youtube_transcript#playground)
- [ผู้จัดทํา OpenAPI](https://flashdata.dev/docs/openapi.json)

<a id="webhooks"></a>

<a id="callbacks"></a>

## แจ้งเตือนการเติมให้สมบูรณ์

- [รับข้อมูลและตรวจสอบการเติมให้สมบูรณ์ของเว็บฮุค](https://flashdata.dev/th/docs/guides/async-batch/reference.md#webhooks)

<a id="troubleshooting"></a>

## การยิงปัญหา

- [ข้อผิดพลาดและรหัสสถานะ](https://flashdata.dev/th/docs/errors/reference.md#status-codes)
- [เมื่อต้องการลองใหม่](https://flashdata.dev/th/docs/errors/reference.md#retries)

## API ที่เกี่ยวข้อง

- [YouTube Captions API](https://flashdata.dev/th/docs/sources/youtube_captions/reference.md)
- [YouTube ข้อมูลกํากับภาพวิดีโอ API](https://flashdata.dev/th/docs/sources/youtube_metadata/reference.md)
