# FlashData YouTube Transcript API

Recuperare il testo di trascrizione YouTube con timestamp e una trascrizione completa. Le didascalie automatiche vengono selezionate per impostazione predefinita.

Riferimento canonico: https://flashdata.dev/it/docs/sources/youtube_transcript
Recensito: 2026-10-23

Punto di arrivo: POST https://data.flashdata.dev/v1/queries/realtime
Autenticazione: X-API-Key: YOUR_API_KEY
Modalità: [Realtime](https://flashdata.dev/it/docs/reference/realtime-and-async/reference.md#realtime) · [Async](https://flashdata.dev/it/docs/reference/realtime-and-async/reference.md#async) · [Batch](https://flashdata.dev/it/docs/reference/batch-and-bulk/reference.md#batch) · [Bulk](https://flashdata.dev/it/docs/reference/bulk-processing/reference.md)

Permesso di origine richiesto: youtube_transcript

Sostituisci YOUR_API_KEY con una chiave API che ha questo permesso di origine e crediti disponibili. Eseguire le richieste sul server o sul server host dell'agente.

[Impostare l'autenticazione](https://flashdata.dev/it/docs/guides/headers-and-authentication/reference.md)

[Scegli una lingua e una traccia trascrizione](https://flashdata.dev/it/docs/guides/youtube-data-guide/reference.md#captions)

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

## Invia una richiesta

### 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>

## Parametri

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

### Corpo della richiesta

| Parametro | Tipologia | Obbligatorio | Predefinito | Designazione |
| --- | --- | --- | --- | --- |
| <a id="parameter-source"></a> source | string | Sì | — | Impostare su youtube_transcript.  |
| <a id="parameter-video_id"></a> video_id | string | Sì | Non impostato | Il video 11-character YouTube video ID, come FUfGcZ092b0. Accetta lettere, numeri, sottolineature e trattini. Lunghezza minima: 11. Lunghezza massima: 11. Modello: ^[A-Za-z0-9_-]{11}$ |
| <a id="parameter-params"></a> params | object | No | {} | Settings per questa richiesta.  |
| <a id="parameter-callback_url"></a> callback_url | string · nullable | No | Non impostato | Async e solo lotto. Completamento HTTPS pubblico URL sulla porta 443, fino a caratteri 2,048. Nessuna credenziali utente o frammentazione URL. Omit, utilizzare null o una stringa vuota per nessuna notifica. In un lotto, impostare questo su ogni query, param esterni.  |

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

### Selezione di acquisizione

| Parametro | Tipologia | Obbligatorio | Predefinito | Designazione |
| --- | --- | --- | --- | --- |
| <a id="parameter-params-language"></a> params.language | string \| array | No | en-orig → en | Omit per l'inglese (en-orig, poi en). Con auto=true, ogni codice prova prima la sua traccia -orig, poi il codice richiesto. Codici espliciti -orig e auto=false rimangono esatti. Arrays richiedono lingue distinte 1–10. Omettere di preferire en-orig e rientrare a en, tornando una traccia. Con auto=true, ogni codice prova prima la sua traccia -orig, poi il codice richiesto; codici espliciti -orig e auto=false rimangono esatti. Gli array di codici distinti 1–10 provano ogni lingua richiesta e restituiscono tracce e errori per lingua nell'ordine di richiesta. languageCode identifica la traccia selezionata; requestedLanguageCode è incluso quando differisce dal codice richiesto. |
| <a id="parameter-params-auto"></a> params.auto | boolean | No | true | true seleziona le didascalie generate da YouTube; false seleziona le didascalie fornite dal caricatore. Questo seleziona l'origine didascalia, non il rilevamento della lingua o la nuova trascrizione.  |

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

## Leggi il risultato

Salvare la risposta di successo JSON come response.json. Salvare questo come read-response.py ed eseguire pitone read-response.py. Utilizza solo la libreria standard di Python e non fa nuove richieste.

### 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))
```

## Risposta di esempio

Esempio registrato; i campi e i conti dipendono dalla fonte e dall'ingresso richiesto.
```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"
}
```

## Lingue multiple

Inviare un array di lingua per ricevere tracce e errori per lingua. Questo esempio mostra l'inglese disponibile e lo spagnolo non disponibile.

```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"
    }
  ]
}
```

## Campi di risposta

| Campo di applicazione | Tipologia | Designazione |
| --- | --- | --- |
| source | string | La fonte API richiesta. |
| status | string | fatto quando la richiesta in tempo reale riesce. |
| created_at | string | Tempo di creazione di risposta in formato ISO 8601. |
| usage.credits | number | Crediti a carico della richiesta, in base al tuo piano. |
| results[0].videoId | string | Il video richiesto ID. |
| results[0].languageCode | string | Codice traccia didascalia selezionato effettivo, come en-orig. |
| results[0].languageName | string · nullable | Nome della visualizzazione della lingua quando disponibile. |
| results[0].requestedLanguageCode | string · optional | Il codice richiesto quando differisce da languageCode, per esempio en quando en-orig è stato selezionato. |
| results[0].isAutoGenerated | boolean | Se le didascalie selezionate sono state generate automaticamente. |
| results[0].segments | array | Segmenti di cattura in ordine cronologico. |
| results[0].segments[].start | number | Tempo di inizio del segmento in pochi secondi. |
| results[0].segments[].end | number | Tempo di fine segmento in pochi secondi. |
| results[0].segments[].text | string | Testo di acquisizione. |
| results[0].fullText | string | Tutto il testo del segmento è entrato in una trascrizione. |
| results[0].tracks | array · optional | Solo per i sistemi linguistici. Le tracce disponibili in ordine di richiesta; ognuna ha i campi a binario singolo elencati sopra. |
| results[0].errors | array · optional | Solo per i sistemi linguistici. Lingue non richieste in ordine. Vuoto quando ogni traccia riesce. |
| results[0].errors[].languageCode | string | La lingua richiesta che ha fallito. |
| results[0].errors[].code | string | language_unavailable quando la traccia selezionata non esiste; retrieval_failed quando non può essere scaricata o analizzata. |
| results[0].errors[].message | string | Descrizione del guasto linguistico. |

- Lo API legge le didascalie già disponibili su YouTube. Non genera nuove trascrizioni o rientra tra le didascalie automatiche e provviste di caricabatterie.
- Un linguaggio di stringa mantiene la risposta single-track. Un array, anche ["en"], restituisce tracce ed errori invece di languageCode di alto livello, segmenti e fullText. Ogni traccia include quei campi. auto si applica a ogni lingua.
- Per gli elenchi di lingue, consulta errors per individuare le tracce non recuperate. Se non viene recuperata alcuna traccia, la richiesta non va a buon fine e i crediti riservati vengono rimborsati. Anche un errore di estrazione del video o la scadenza del tempo limite fanno fallire la richiesta.
- Disponibile in tempo reale, asincastro, lotto e massa. Le esportazioni di Bulk rimangono JSONL con un record per video, incluse le sue tracce e gli errori. Accept e X-Respond-With si applicano come al solito.

## Formati di risposta

Le risposte usano JSON per impostazione predefinita. Scegli un altro formato con queste intestazioni opzionali.

- Accept: application/json (predefinito) o text/plain. Testo normale presenta gli stessi campi in un layout leggibile e indentato.
- X-Respond-With: markdown. Lasciare unset per i campi originali. Markdown funziona con il formato di risposta.

Markdown è disponibile per domande in tempo reale e risultati completati.

I campi sottostanti descrivono la risposta predefinita JSON.

[Esempi di formato di richiesta e risposta](https://flashdata.dev/it/docs/guides/response-formats/reference.md#headers)

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

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

## Nozioni di base sulle API

Il costruttore di richieste ed esempi sopra usano i parametri di questa fonte. Utilizzare gli esempi Python e cURL qui sotto per la presentazione condivisa, lo stato e i passaggi di risultato. Un corpo Batch è un oggetto JSON contenente query; ogni elemento restituisce il proprio lavoro ID.

- [Async richiesta e ricevuta](https://flashdata.dev/it/docs/reference/realtime-and-async/reference.md#async)

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

- [Controllare lo stato del lavoro](https://flashdata.dev/it/docs/reference/realtime-and-async/reference.md#status)

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

- [Recuperare i risultati completati](https://flashdata.dev/it/docs/reference/realtime-and-async/reference.md#results)
- [richieste Batch JSON](https://flashdata.dev/it/docs/reference/batch-and-bulk/reference.md#batch)
- [API di elaborazione Bulk](https://flashdata.dev/it/docs/reference/bulk-processing/reference.md)
- [Costruire un flusso di lavoro Bulk per questa sorgente](https://flashdata.dev/it/docs/reference/bulk-processing/reference.md?source=youtube_transcript#playground)
- [Clienti OpenAPI](https://flashdata.dev/docs/openapi.json)

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

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

## Notifiche di completamento

- [Ricevi e verifica il completamento webhooks](https://flashdata.dev/it/docs/guides/async-batch/reference.md#webhooks)

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

## Risoluzione dei problemi

- [Errori e codici di stato](https://flashdata.dev/it/docs/errors/reference.md#status-codes)
- [Quando riprova](https://flashdata.dev/it/docs/errors/reference.md#retries)

## API correlate

- [YouTube Captions API](https://flashdata.dev/it/docs/sources/youtube_captions/reference.md)
- [YouTube Video Metadati API](https://flashdata.dev/it/docs/sources/youtube_metadata/reference.md)
