# YouTube Transcript Scraper (+ Metadata) (`zkill3r/youtube-transcript-scraper`) Actor

Get full YouTube transcripts (timestamped segments and plain text) plus video metadata from videos, channels and playlists. Manual or auto-generated captions, language fallback and auto-translation. Built for AI/RAG, summaries, SEO and content repurposing.

- **URL**: https://apify.com/zkill3r/youtube-transcript-scraper.md
- **Developed by:** [Zee Lex](https://apify.com/zkill3r) (community)
- **Categories:** Videos, AI, Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.25 / 1,000 transcripts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Transcript Scraper (+ Metadata)

Get the **full transcript** of any YouTube video, as timestamped segments and as clean plain text, together with key **video metadata**. Works on single videos, whole channels and playlists. It's built for AI/RAG pipelines, summaries, SEO and content repurposing.

- Videos, Shorts, live replays, channels (`@handle`, `/channel/UC…`, `/c/…`, `/user/…`) and playlists
- Manual (creator-uploaded) or auto-generated captions, your choice
- Preferred language with a fallback to any available language, plus YouTube's own auto-translation (`translateTo`)
- Every video gets a result with a clear `status`, so you can see *why* a video has no transcript
- You pay only for videos that return a transcript
- Fast HTTP scraping with no browser, at 512 MB of memory

### Use cases

- **AI / RAG:** feed transcripts into vector databases, chatbots and agents; segments keep timestamps for citations
- **Summaries:** summarise lectures, podcasts and talks with an LLM
- **SEO and repurposing:** turn videos into blog posts, show notes, newsletters, social posts and quotes
- **Research:** analyse what a channel or a playlist talks about, at scale

### Input examples

**A single video**

```json
{ "videoUrls": ["https://www.youtube.com/watch?v=aircAruvnKk"] }
```

**A channel's latest 50 videos, plain text only**

```json
{
    "channelUrls": ["https://www.youtube.com/@3blue1brown"],
    "maxVideosPerChannel": 50,
    "outputFormat": "text"
}
```

**A playlist, transcripts in Spanish (auto-translated where needed)**

```json
{
    "playlistUrls": ["https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi"],
    "maxVideosPerPlaylist": 100,
    "language": "es",
    "translateTo": "es"
}
```

| Field | Default | Notes |
|---|---|---|
| `videoUrls` | – | watch, youtu.be, /shorts/, /live/, embed URLs or 11-char IDs |
| `channelUrls` | – | latest uploads of each channel |
| `playlistUrls` | – | in playlist order |
| `maxVideosPerChannel` / `maxVideosPerPlaylist` | `20` | |
| `language` | `en` | `en` also matches `en-GB`, `en-US`… |
| `fallbackToAnyLanguage` | `true` | otherwise status `no_transcript` |
| `translateTo` | – | YouTube auto-translate (`tlang`), when offered |
| `preferManualCaptions` | `true` | `false` prefers auto-generated |
| `outputFormat` | `both` | `segments`, `text`, `both` |
| `includeMetadata` | `true` | `false` = transcript only, fewer requests |
| `maxConcurrency` | `10` | |
| `proxyConfiguration` | Apify datacenter | blocked requests escalate to RESIDENTIAL |

### Output sample

One dataset item per video:

```json
{
    "videoId": "aircAruvnKk",
    "url": "https://www.youtube.com/watch?v=aircAruvnKk",
    "title": "But what is a neural network? | Deep learning chapter 1",
    "channelName": "3Blue1Brown",
    "channelId": "UCYO_jab_esuFRV4b17AJtAw",
    "channelUrl": "https://www.youtube.com/@3blue1brown",
    "publishedAt": "2017-10-05T15:11:25.000Z",
    "durationSeconds": 1120,
    "viewCount": 25009905,
    "likeCount": 568125,
    "description": "What are the neurons, why are there layers, and what is the math underlying it?\nHelp fund future projects: https://www.patreon.com/3blue1brown\nWritten...",
    "thumbnailUrl": "https://i.ytimg.com/vi_webp/aircAruvnKk/maxresdefault.webp",
    "isLive": false,
    "isShort": false,
    "transcriptLanguage": "en",
    "transcriptLanguageName": "English",
    "isAutoGenerated": false,
    "isTranslated": false,
    "availableLanguages": [
        {
            "languageCode": "ar",
            "languageName": "Arabic",
            "isAutoGenerated": false
        },
        {
            "languageCode": "bn",
            "languageName": "Bangla",
            "isAutoGenerated": false
        },
        {
            "languageCode": "zh",
            "languageName": "Chinese",
            "isAutoGenerated": false
        }
    ],
    "transcript": [
        {
            "start": 4.22,
            "duration": 1.18,
            "text": "This is a 3."
        },
        {
            "start": 6.06,
            "duration": 4.653,
            "text": "It's sloppily written and rendered at an extremely low resolution of 28x28 pixels,"
        },
        {
            "start": 10.713,
            "duration": 3.007,
            "text": "but your brain has no trouble recognizing it as a 3."
        }
    ],
    "transcriptText": "This is a 3. It's sloppily written and rendered at an extremely low resolution of 28x28 pixels, but your brain has no trouble recognizing it as a 3. And I want you to take a moment to appreciate how c...",
    "wordCount": 3357,
    "status": "ok",
    "error": null
}
```

The sample values are illustrative.

**Statuses**

| `status` | Meaning | Charged |
|---|---|---|
| `ok` | transcript returned | yes |
| `no_transcript` | video has no captions, none in your language (with fallback off), or it's an upcoming premiere/stream | no |
| `private` | private video | no |
| `unavailable` | removed, region-blocked, members-only or otherwise unplayable | no |
| `age_restricted` | needs a signed-in, age-verified account | no |
| `error` | still blocked or failing after 4 retries (technical) | no |

`error` explains non-ok statuses. It's also set on `ok` items when a fallback was used, e.g. `No transcript in "en"; returned "de".`

Field notes:

- `start` and `duration` are in seconds. `duration` is how long the caption is on screen, so captions can overlap.
- `publishedAt` is ISO 8601 (UTC). `likeCount` is `null` when the channel hides likes or YouTube doesn't show the count.
- `isLive` is `true` for videos that are or were live streams.
- `isShort` uses a lightweight check that runs only for videos of 3 minutes or less (or a `/shorts/` input).
- `wordCount` counts whitespace-separated words, so it isn't meaningful for Chinese or Japanese.
- With `includeMetadata: false`, all metadata fields except `title` are `null`.

### Run summary

`RUN_SUMMARY` in the key-value store (linked from the run's Output tab) contains:

- `overallStatus`: `ok`, `partial` or `failed`
- totals per status, number of charged transcripts and whether your cost limit was reached
- retries and their reasons, and escalations to residential proxy
- where captions came from (watch page or InnerTube client) and in which format (json3, srv1, srv3)
- per channel/playlist results (resolved ID, videos queued, errors)
- invalid inputs
- % missing for every field across `ok` items

The run **fails** (non-zero exit) only if every input failed for technical reasons. Videos without captions don't fail the run. Channels or playlists that don't exist are reported in the summary as bad input.

### How it works

1. Loads the watch page with consent cookies set, so the EU consent page is skipped. It reads metadata, the playability status and the caption tracks from `ytInitialPlayerResponse`.
2. If the page's caption links need a PO token (`&exp=xpe`) or there are none, it asks YouTube's InnerTube player API, as the ANDROID client first, then the WEB client. This is the same approach as the open-source `youtube-transcript-api`.
3. Downloads the chosen track as `json3`, falling back to the default XML and then `srv3`. It decodes entities and merges the segments into plain text.
4. Channels are turned into their uploads playlist (`UC…` → `UU…`). Playlists are read through InnerTube `browse`, following continuations.
5. Bot checks ("Sign in to confirm you're not a bot"), reCAPTCHA pages, 429/403/5xx and empty responses mark the session as bad. The request is retried on a new session with exponential backoff (2, 4, 8, 16 s), and from the 2nd retry it goes through residential proxy.

### Limitations

- YouTube actively fights scraping. It increasingly requires "PO tokens" for caption downloads and shows bot checks to datacenter IPs. This Actor works around that with the ANDROID client and residential escalation, but YouTube can change this at any time.
- Age-restricted, private and members-only videos need a signed-in account, and this Actor never logs in.
- Auto-translation exists only when YouTube offers it for that video. The translations are machine-made.
- Auto-generated captions have no punctuation in many languages and may contain recognition errors.
- Channel scraping reads the channel's uploads playlist, which includes Shorts and past live streams in upload order.
- All YouTube-specific paths and request shapes are in `src/mappings.ts`. Rising "missing" percentages in `RUN_SUMMARY` are the early warning that YouTube changed something.

### Pricing

| Apify plan | Price per 1,000 transcripts |
|---|---|
| Free | $3.00 |
| Bronze | $2.75 |
| Silver | $2.50 |
| Gold+ | $2.25 |

Video metadata is included at no extra cost, and **you only pay for videos that actually return a transcript** — videos without captions, private or unavailable videos are free. This Actor is built for **pay-per-event** pricing with a single custom event, `transcript` (the `CHARGE_EVENT` constant in `src/mappings.ts`). That event is charged once per video with status `ok`. When setting up monetization, don't enable the per-dataset-item event, or videos without transcripts would be charged too. The Actor stops as soon as the user's maximum cost per run is reached.

### Development

```bash
npm install
npm test                    # unit tests (node --test) on saved fixtures
npm run build && apify run  # local run with storage/key_value_stores/default/INPUT.json
```

- **Check against real YouTube:** where youtube.com is reachable, run `npm run capture-fixtures`. It saves real watch, player, timedtext and browse responses to `test/fixtures/live/`, and `npm test` then also runs `test/live-fixtures.test.ts` on them. The fixtures in `test/fixtures/` are synthetic; `make_fixtures.py` builds them from the shapes used by youtube-transcript-api and youtubei.js.
- **Offline end-to-end run:** `npm run mock-server` starts a local stand-in covering every status, a bot check, a PO-token fallback, a channel with two pages and a missing playlist. Then run `YT_BASE_URL=http://127.0.0.1:4577 node dist/main.js`.

Request shapes and paths are ported from [youtube-transcript-api](https://github.com/jdepoix/youtube-transcript-api) v1.2.4 and [youtubei.js](https://github.com/LuanRT/YouTube.js) v18.3.0, both MIT-licensed. Neither is a runtime dependency.

# Actor input Schema

## `videoUrls` (type: `array`):

YouTube videos: watch URLs, youtu.be links, /shorts/, /live/ and embed URLs, or bare 11-character video IDs.

## `channelUrls` (type: `array`):

Optional. Channel URLs (https://www.youtube.com/@handle, /channel/UC..., /c/..., /user/...) or a bare @handle. The latest uploads are scraped.

## `playlistUrls` (type: `array`):

Optional. Playlist URLs (https://www.youtube.com/playlist?list=...) or playlist IDs.

## `maxVideosPerChannel` (type: `integer`):

How many of each channel's latest uploads to scrape.

## `maxVideosPerPlaylist` (type: `integer`):

How many videos to scrape from each playlist, in playlist order.

## `language` (type: `string`):

Preferred transcript language code, e.g. en, es, ms, pt-BR. "en" also matches regional variants like en-GB.

## `fallbackToAnyLanguage` (type: `boolean`):

If the video has no transcript in your language, return the transcript in whatever language is available instead of status no_transcript.

## `translateTo` (type: `string`):

Optional language code (e.g. es). Uses YouTube's own auto-translation when the video offers it; otherwise the original language is returned and the item's error field says so.

## `preferManualCaptions` (type: `boolean`):

Prefer captions uploaded by the creator over YouTube's auto-generated ones. Turn off to prefer auto-generated captions.

## `outputFormat` (type: `string`):

"segments": timestamped segments only (transcript field); "text": plain text only (transcriptText field); "both": both fields.

## `includeMetadata` (type: `boolean`):

Add channel, publish date, duration, views, likes, description, thumbnail, Short/live flags. Turn off for transcript only (fewer requests, cheaper).

## `maxConcurrency` (type: `integer`):

How many videos are processed in parallel. Lower it if RUN_SUMMARY shows many retries.

## `proxyConfiguration` (type: `object`):

Apify datacenter proxy by default. Requests YouTube blocks are retried on a new session, and from the 2nd retry on RESIDENTIAL proxy automatically (if your plan includes it).

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=aircAruvnKk"
  ],
  "maxVideosPerChannel": 20,
  "maxVideosPerPlaylist": 20,
  "language": "en",
  "fallbackToAnyLanguage": true,
  "preferManualCaptions": true,
  "outputFormat": "both",
  "includeMetadata": true,
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `videos` (type: `string`):

One item per video: transcript, metadata and status.

## `allFields` (type: `string`):

Every field, including timestamped segments and plain text.

## `runSummary` (type: `string`):

Totals per status, overall status, retries, proxy escalations, caption sources and % missing per field.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=aircAruvnKk"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("zkill3r/youtube-transcript-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "videoUrls": ["https://www.youtube.com/watch?v=aircAruvnKk"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("zkill3r/youtube-transcript-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "videoUrls": [
    "https://www.youtube.com/watch?v=aircAruvnKk"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call zkill3r/youtube-transcript-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zkill3r/youtube-transcript-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/KrSwMB5hkzueB8PAQ/builds/I9ejMcETMQTbyV0BL/openapi.json
