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.
| Field | Type | Description |
|---|---|---|
url | string | The video's address: a youtube.com/watch, youtu.be, /shorts/, /live/ or /embed/ link.Limit: at most 500 characters. |
video_id | string | The video's 11-character id.Limit: at most 500 characters. |
language | string | 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 | 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
urlandvideo_id. Both, or neither, is refused withinvalid_input. - Without
languagethe 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_generatedsays which. - With
language, the track with that exact code is returned (pt-BR); failing that, one in the same language (ptfindspt-BR,en-GBfindsen), captions the channel supplied before auto-generated ones. Nothing is translated: a language the video does not offer ends the rununsupportedwithlanguage_not_available.available_languagesin any successful run lists what a video offers. segmentsare the caption lines withstartanddurationin seconds;textis the same lines joined by spaces. Setsegmentstofalsefor the text alone: a three-hour video has several thousand segments.- A video with no captions ends the run
unsupportedwithno_captions; so does a stream that is still on air. An age-restricted video ends itunsupportedwithage_restricted. A private video isfailedwithprivate_video, a removed one withnot_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. |
language_code (in available_languages[]) | string | The track's language code, as YouTube gives it, e.g. en. |
name (in available_languages[]) | string or null | As shown ("English (auto-generated)"). |
auto_generated (in available_languages[]) | boolean | Made by speech recognition, not uploaded by the channel. |
translatable (in available_languages[]) | 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. |
start (in segments[]) | number | When the line starts, in seconds from the start of the video. |
duration (in segments[]) | number or null | How long the line stays on screen, in seconds; null when the track does not say. |
text (in segments[]) | string | The line, as captioned. |
fetched_at | string (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=enInstall 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:
{
"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.
{
"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.
{
"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.