# youtube.transcript

A YouTube video's captions as timed segments and as one text, in the language you choose, with the list of languages it offers.

YouTube transcript, one of the YouTube scrapers.

| | |
| --- | --- |
| Id | `youtube.transcript` |
| Version | 1 |
| Billed per | request — 1 unit for a charged run |
| Runs | within one request |

Start it with `POST /v1/scrapers/youtube.transcript/runs`. How runs work is in [Running a scraper](https://docs.enrichednow.com/running-a-scraper.md); what a run costs is in [Usage and units](https://docs.enrichednow.com/usage-and-units.md).

## Inputs

The fields of `input`. A field that is not listed here is refused.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | no | The video's address: a youtube.com/watch, youtu.be, /shorts/, /live/ or /embed/ link. Limit: at most 500 characters. |
| `video_id` | string | no | The video's 11-character id. Limit: at most 500 characters. |
| `language` | string | no | The caption language wanted, as a language code: "en", "es", "pt-BR". A code without a region also finds that language's regional tracks. Leave out for the language spoken in the video. Limit: at most 35 characters. |
| `segments` | boolean | no | Return the timed segments. Set false to get only the full text, which keeps the record small for a long video. Default: `true`. |

- Give exactly one of `url` and `video_id`. Both, or neither, is refused with `invalid_input`.
- Without `language` the transcript is in the language spoken in the video: the captions the channel supplied in that language when there are some, otherwise the auto-generated ones. `auto_generated` says which.
- With `language`, the track with that exact code is returned (`pt-BR`); failing that, one in the same language (`pt` finds `pt-BR`, `en-GB` finds `en`), captions the channel supplied before auto-generated ones. Nothing is translated: a language the video does not offer ends the run `unsupported` with `language_not_available`. `available_languages` in any successful run lists what a video offers.
- `segments` are the caption lines with `start` and `duration` in seconds; `text` is the same lines joined by spaces. Set `segments` to `false` for the text alone: a three-hour video has several thousand segments.
- A video with no captions ends the run `unsupported` with `no_captions`; so does a stream that is still on air. An age-restricted video ends it `unsupported` with `age_restricted`. A private video is `failed` with `private_video`, a removed one with `not_found`. None of them is charged.
- Billed per request: a charged run costs 1 unit, whatever the length of the transcript.

## Record fields

Every record of a run has these fields. A value that is not known is `null` — never an empty string and never `0`.

| Field | Type | Notes |
| --- | --- | --- |
| `video_id` | string | The video id. |
| `url` | string | The video's address: youtube.com/watch?v=<id>. |
| `title` | string or null | The video's title. |
| `channel_name` | string or null | The name of the channel that published it. |
| `channel_id` | string or null | That channel's id (UC…). |
| `duration_seconds` | integer or null | The video's length in seconds. |
| `language_code` | string | The language of the captions returned, as YouTube codes it ("en", "pt-BR"). |
| `language_name` | string or null | That track's name as YouTube shows it ("English", "English (auto-generated)"). |
| `auto_generated` | boolean | True when the captions were made by speech recognition, false when the channel supplied them. |
| `available_languages` | array of object | Every caption track the video offers, in YouTube's order: the language code, the name shown, and whether it is automatic. |
| `available_languages[].language_code` | string | The track's language code, as YouTube gives it, e.g. en. |
| `available_languages[].name` | string or null | As shown ("English (auto-generated)"). |
| `available_languages[].auto_generated` | boolean | Made by speech recognition, not uploaded by the channel. |
| `available_languages[].translatable` | boolean or null | Whether YouTube offers the track translated into other languages; null when the page does not say. |
| `segment_count` | integer | The number of caption lines in the track. |
| `text` | string | The whole transcript as one text: the caption lines in order, joined by spaces. |
| `segments` | array of object or null | The caption lines in order, each with its start time and duration in seconds; null when the input set `segments` to false. |
| `segments[].start` | number | When the line starts, in seconds from the start of the video. |
| `segments[].duration` | number or null | How long the line stays on screen, in seconds; null when the track does not say. |
| `segments[].text` | string | The line, as captioned. |
| `fetched_at` | string (date-time) | When the captions were read, in UTC. |

## Example request

It starts a run with this scraper's example input and waits up to 60 seconds for it. The key is read from `ENRICHEDNOW_API_KEY`.

```bash
curl -X POST "https://api.enrichednow.com/v1/scrapers/youtube.transcript/runs?wait=60" \
  -H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":{"video_id":"8jPQjjsBbIc","language":"en"}}'
```

## Example response

The run, once it has ended. A run that has not ended within `wait` comes back with `202` and the status `queued` or `running`.

```json
{
  "id": "run_841742f37553189ff9c27ba1",
  "scraper_id": "youtube.transcript",
  "scraper_version": 1,
  "status": "ok",
  "reason": null,
  "input": {
    "video_id": "8jPQjjsBbIc",
    "language": "en"
  },
  "record_count": 1,
  "units": 1,
  "units_per_request": 1,
  "units_per_record": null,
  "units_per_page": null,
  "diagnostics": {
    "requests": 1,
    "bytes": 259214,
    "wall_ms": 885,
    "facts": {}
  },
  "created_at": "2026-11-16T22:37:50.170950Z",
  "started_at": "2026-11-16T22:37:50.178331Z",
  "finished_at": "2026-11-16T22:37:51.066313Z"
}
```

Its records, from `GET /v1/runs/{id}/records`. The record is a real one: this scraper's own parser read it from a page recorded from the site.

```json
{
  "records": [
    {
      "video_id": "8jPQjjsBbIc",
      "url": "https://www.youtube.com/watch?v=8jPQjjsBbIc",
      "title": "How to stay calm when you know you'll be stressed | Daniel Levitin | TED",
      "channel_name": "TED",
      "channel_id": "UCAuUUnT6oDeKwE6v1NGQxug",
      "duration_seconds": 740,
      "language_code": "en",
      "language_name": "English",
      "auto_generated": false,
      "available_languages": [
        {
          "language_code": "ar",
          "name": "Arabic",
          "auto_generated": false,
          "translatable": true
        },
        {
          "language_code": "bg",
          "name": "Bulgarian",
          "auto_generated": false,
          "translatable": true
        }
      ],
      "segment_count": 260,
      "text": "A few years ago, I broke into my own house. I had just driven home, it was around midnight in the dead of Montreal winter, I had been visiting my friend, Jeff, across town, and the thermometer on the front porch read minus 40 degrees -- and … [truncated]",
      "segments": [
        {
          "start": 13.24,
          "duration": 2.56,
          "text": "A few years ago, I broke into my own house."
        },
        {
          "start": 16.88,
          "duration": 1.216,
          "text": "I had just driven home,"
        }
      ],
      "fetched_at": "2026-11-19T18:07:42.951604Z"
    }
  ],
  "next_cursor": null
}
```

What was done to the record for this page, and nothing else — the API returns every value whole. A text that was cut ends with `… [truncated]`.

- Shortened: `available_languages`: 41 items, the first 2 shown.
- Shortened: `text`: 12,360 characters, the first 240 shown.
- Shortened: `segments`: 260 items, the first 2 shown.

A run does not always end `ok`. [Results and statuses](https://docs.enrichednow.com/results-and-statuses.md#reason-codes) lists every status and the reasons every scraper shares; [the reasons of the YouTube scrapers](https://docs.enrichednow.com/results-and-statuses.md#youtube) are in their own section there.
