Skip to the content
EnrichedNowDocs

    Type to search every page.

    Menu

    Scraper APIYouTube

    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.

    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; what a run costs is in Usage and units.

    Inputs

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

    Inputs of youtube.transcript
    FieldTypeDescription
    urlstringThe video's address: a youtube.com/watch, youtu.be, /shorts/, /live/ or /embed/ link.Limit: at most 500 characters.
    video_idstringThe video's 11-character id.Limit: at most 500 characters.
    languagestringThe 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.
    segmentsbooleanReturn 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.

    Record fields of youtube.transcript
    FieldTypeNotes
    video_idstringThe video id.
    urlstringThe video's address: youtube.com/watch?v=<id>.
    titlestring or nullThe video's title.
    channel_namestring or nullThe name of the channel that published it.
    channel_idstring or nullThat channel's id (UC…).
    duration_secondsinteger or nullThe video's length in seconds.
    language_codestringThe language of the captions returned, as YouTube codes it ("en", "pt-BR").
    language_namestring or nullThat track's name as YouTube shows it ("English", "English (auto-generated)").
    auto_generatedbooleanTrue when the captions were made by speech recognition, false when the channel supplied them.
    available_languagesarray of objectEvery caption track the video offers, in YouTube's order: the language code, the name shown, and whether it is automatic.
    language_code (in available_languages[])stringThe track's language code, as YouTube gives it, e.g. en.
    name (in available_languages[])string or nullAs shown ("English (auto-generated)").
    auto_generated (in available_languages[])booleanMade by speech recognition, not uploaded by the channel.
    translatable (in available_languages[])boolean or nullWhether YouTube offers the track translated into other languages; null when the page does not say.
    segment_countintegerThe number of caption lines in the track.
    textstringThe whole transcript as one text: the caption lines in order, joined by spaces.
    segmentsarray of object or nullThe caption lines in order, each with its start time and duration in seconds; null when the input set segments to false.
    start (in segments[])numberWhen the line starts, in seconds from the start of the video.
    duration (in segments[])number or nullHow long the line stays on screen, in seconds; null when the track does not say.
    text (in segments[])stringThe line, as captioned.
    fetched_atstring (date-time)When the captions were read, in UTC.

    Example request

    # Start a run and wait up to 60 seconds for it to finish
    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"}}'
    
    # Read its records, with the id the first call answered
    curl "https://api.enrichednow.com/v1/runs/$RUN_ID/records?limit=100" \
      -H "Authorization: Bearer $ENRICHEDNOW_API_KEY"
    from enrichednow import EnrichedNow
    
    client = EnrichedNow()  # reads ENRICHEDNOW_API_KEY
    
    # Start a run, wait for it to end, and get its records
    result = client.scrape("youtube.transcript", {
        "video_id": "8jPQjjsBbIc",
        "language": "en",
    })
    print(result.run.id, result.run.status, result.run.record_count)
    
    # Read its records: pages are fetched as you go
    for record in result.records:
        print(record)

    Install it with pip install enrichednow, then save as run.py and run python3 run.py

    import EnrichedNow from "enrichednow";
    
    const client = new EnrichedNow(); // reads ENRICHEDNOW_API_KEY
    
    // Start a run, wait for it to end, and get its records
    const { run, records } = await client.scrape("youtube.transcript", {
      video_id: "8jPQjjsBbIc",
      language: "en",
    });
    console.log(run.id, run.status, run.record_count);
    
    // Read its records: pages are fetched as you go
    for await (const record of records) console.log(record);

    Install it with npm install enrichednow, then save as run.mjs and run node run.mjs

    package main
    
    import (
    	"context"
    	"fmt"
    	"log"
    	"time"
    
    	enrichednow "github.com/enrichednow/enrichednow-go"
    )
    
    func main() {
    	client, err := enrichednow.NewClient() // reads ENRICHEDNOW_API_KEY
    	if err != nil {
    		log.Fatal(err)
    	}
    	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
    	defer cancel()
    
    	// Start a run, wait for it to end, and get its records
    	run, records, err := client.Scrape(ctx, "youtube.transcript", map[string]any{"video_id": "8jPQjjsBbIc", "language": "en"})
    	if err != nil {
    		log.Fatal(err)
    	}
    	fmt.Println(run.ID, run.Status, run.RecordCount)
    
    	// Read its records: pages are fetched as you go
    	for records.Next() {
    		fmt.Println(string(records.Current()))
    	}
    	if err := records.Err(); err != nil {
    		log.Fatal(err)
    	}
    }

    Install it with go get github.com/enrichednow/enrichednow-go@latest, then save as run.go and run go run run.go

    import com.enrichednow.EnrichedNowClient;
    import com.enrichednow.ScrapeResult;
    import java.util.Map;
    
    public class Run {
        public static void main(String[] args) {
            EnrichedNowClient client = EnrichedNowClient.fromEnv(); // reads ENRICHEDNOW_API_KEY
    
            // Start a run, wait for it to end, and get its records
            ScrapeResult result = client.scrape("youtube.transcript", Map.of("video_id", "8jPQjjsBbIc", "language", "en"));
            System.out.println(result.run().id() + " " + result.run().status() + " " + result.run().recordCount());
    
            // Read its records: pages are fetched as you go
            for (Map<String, Object> record : result.records()) {
                System.out.println(record);
            }
        }
    }

    Add com.enrichednow:enrichednow-java:0.4.0 to your Maven or Gradle build, then save as Run.java

    enrichednow run youtube.transcript --input video_id=8jPQjjsBbIc --input language=en

    Install it with curl -fsSL https://raw.githubusercontent.com/enrichednow/enrichednow-cli/main/install.sh | sh

    It starts a run with this scraper’s example input, waits for it to finish and reads its records a page at a time. The key is read from ENRICHEDNOW_API_KEY.

    The body on its own:

    JSON
    {
      "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 lists every status and the reasons every scraper shares; the reasons of the YouTube scrapers are in their own section there.