# FlashData YouTube Transcript API

YouTubeのトランスクリプトテキストをタイムスタンプと完全なトランスクリプトで取得します。 デフォルトで自動キャプションが選択されます。

キャニシニカル参照: https://flashdata.dev/ja/docs/sources/youtube_transcript
レビュー: 2026-10-23

エンドポイント: POST https://data.flashdata.dev/v1/queries/realtime
認証: X-API-Key: YOUR_API_KEY
モード: [Realtime](https://flashdata.dev/ja/docs/reference/realtime-and-async/reference.md#realtime) · [Async](https://flashdata.dev/ja/docs/reference/realtime-and-async/reference.md#async) · [Batch](https://flashdata.dev/ja/docs/reference/batch-and-bulk/reference.md#batch) · [Bulk](https://flashdata.dev/ja/docs/reference/bulk-processing/reference.md)

必要なソース権限: youtube_transcript

YOUR_API_KEYをAPIキーに置き換え、このソースの許可と利用可能なクレジットを持っています。 サーバやエージェントホストのリクエストを実行します。

[認証の設定](https://flashdata.dev/ja/docs/guides/headers-and-authentication/reference.md)

[トランスクリプト言語を選択し、追跡する](https://flashdata.dev/ja/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-character 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 | 英語(en-orig, then en)の省略。 auto=true では、各コードは -orig のトラックを最初に試み、要求されたコード。 Explicit -orig コードと auto=false は正確です。 配列は、1–10の異なる言語を要求します。 入退役希望を優先し、入退去を認める。 auto=true では、各コードは -orig のトラックを最初に試み、要求されたコード; explicit -orig のコードおよび auto=false の滞在の厳密な。 1–10のコードの配列は要求された言語を試し、要求の順序でトラックおよび言語の間違いを戻します。languageCodeは選択されたトラックを識別します;要求されたコードと異なっているときrequestedLanguageCodeは含まれています。 |
| <a id="parameter-params-auto"></a> params.auto | boolean | ノーザン | true | true は YouTube 生成されたキャプションを選択します。false は、アップローダーで提供されるキャプションを選択します。 これは、言語の検出や新しい転写ではなく、キャプションの起源を選択します。  |

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

## 結果を読む

response.jsonとして成功するJSON応答を保存します。 これをread-response.pyとして保存し、python 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と異なる場合、例えば en-orig が選択されたとき。 |
| results[0].isAutoGenerated | boolean | 選択したキャプションが自動的に生成されるかどうか。 |
| results[0].segments | array | 慢性的な順序のキャプションの区分。 |
| results[0].segments[].start | number | 秒単位の開始時間。 |
| results[0].segments[].end | number | 秒単位で終了時刻をセグメント化します。 |
| 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で既に利用可能なキャプションを読み込みます。 自動およびアップローダーによって証明されるキャプション間で新しいトランスクリプトを生成したり、フォールバックしたりしません。
- 文字列の言語は、単一トラックの応答を保持します。 languageCode、セグメント、fullTextの代わりに、配列、 ["en"]、リターントラックとエラー。 各トラックにはこれらのフィールドが含まれます。各言語に自動適用されます。
- 言語の配列を指定した場合は、errors で取得に失敗したトラックを確認してください。トラックを 1 件も取得できない場合、リクエストは失敗し、確保済みのクレジットは返還されます。動画の抽出エラーやリクエストの期限切れでも失敗します。
- リアルタイム、非同期、バッチ、一括で利用できます。 Bulkエクスポートは、トラックやエラーを含むビデオごとの1レコードでJSONLを維持します。 Accept と X-Respond-With は、通常どおり適用されます。

## レスポンス形式

応答はデフォルトでJSONを使用します。 これらのオプションヘッダーで別の形式を選択します。

- Accept: application/json (デフォルト) または text/plain. プレーンテキストは、読みやすいレイアウトで同じフィールドを提示します。
- X-Respond-With: markdown. 元のフィールドにアンセットを残します。 Markdownは、応答形式のいずれかで動作します。

Markdownはリアルタイムの問い合わせと完了した結果に利用できます。

下のフィールドは、デフォルトのJSON応答を記述します。

[リクエストとレスポンスの形式例](https://flashdata.dev/ja/docs/guides/response-formats/reference.md#headers)

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

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

## API の基本

上記のビルダーと例は、このソースのパラメーターを使用します。 Python と cURL の例を以下に使用して、共有の投稿、ステータス、結果の手順を実行します。 Batch ボディは、クエリを含む JSON オブジェクトです。各項目は独自のジョブ ID を返します。

- [Asyncリクエストとレシート](https://flashdata.dev/ja/docs/reference/realtime-and-async/reference.md#async)

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

- [ジョブステータスの確認](https://flashdata.dev/ja/docs/reference/realtime-and-async/reference.md#status)

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

- [完了した結果を取得する](https://flashdata.dev/ja/docs/reference/realtime-and-async/reference.md#results)
- [Batch JSON リクエスト](https://flashdata.dev/ja/docs/reference/batch-and-bulk/reference.md#batch)
- [Bulk 処理 API](https://flashdata.dev/ja/docs/reference/bulk-processing/reference.md)
- [Bulkのワークフローをこのソースにビルドする](https://flashdata.dev/ja/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>

## 完了通知

- [完了のWebhooksを受信し、確認する](https://flashdata.dev/ja/docs/guides/async-batch/reference.md#webhooks)

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

## トラブルシューティング

- [エラーとステータスコード](https://flashdata.dev/ja/docs/errors/reference.md#status-codes)
- [再試行するとき](https://flashdata.dev/ja/docs/errors/reference.md#retries)

## 関連API

- [YouTube Captions API](https://flashdata.dev/ja/docs/sources/youtube_captions/reference.md)
- [YouTubeビデオメタデータAPI](https://flashdata.dev/ja/docs/sources/youtube_metadata/reference.md)
