# YouTube Transcript Extractor for AI and RAG (`wilanibe/youtube-transcript`) Actor

Extract YouTube transcripts and captions in bulk as text, timed segments or Markdown, with token-sized chunks for AI and RAG pipelines. Clear status for every video; you pay only for successful transcripts.

- **URL**: https://apify.com/wilanibe/youtube-transcript.md
- **Developed by:** [Wilson Anibe](https://apify.com/wilanibe) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.80 / 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 Extractor for AI and RAG

Get the transcript of any public YouTube video as timed segments, plain text or Markdown, with optional token-sized chunks ready for embeddings. Every video you submit comes back with a clear status, and you pay only for transcripts that were actually extracted.

### What you can use it for

- **AI and RAG pipelines.** Turn videos into chunks of a size you choose, each with start and end times, so answers can link back to the exact moment in the video.
- **Research.** Collect transcripts from a list of videos, a playlist or a channel, with title, channel, duration and publish date, for analysis or search.
- **Content repurposing.** Get Markdown with the video title as a heading and the creator's chapters as sections, ready to edit into an article, newsletter or show notes.
- **Subtitles and accessibility.** Get timed segments with start and duration in seconds, in the language you prefer, with manual captions chosen over auto-generated ones.

### Sample output

One item per video. This is a real result for a TED talk, shortened where marked with `...`:

```json
{
  "videoId": "-moW9jvvMr4",
  "url": "https://www.youtube.com/watch?v=-moW9jvvMr4",
  "title": "A Simple Way to Break a Bad Habit | Judson Brewer | TED",
  "channelName": "TED",
  "channelId": "UCAuUUnT6oDeKwE6v1NGQxug",
  "durationSeconds": 565,
  "publishedAt": "2016-02-24",
  "language": "en",
  "isAutoGenerated": false,
  "availableLanguages": ["ar", "be", "bg", "my", "ckb", "zh-CN", "..."],
  "transcript": [
    { "start": 12.76, "duration": 1.856, "text": "When I was first learning to meditate," },
    { "start": 14.64, "duration": 3.056, "text": "the instruction was to simply pay attention to my breath," },
    { "start": 17.72, "duration": 2.08, "text": "and when my mind wandered, to bring it back." },
    "..."
  ],
  "chunks": [
    {
      "index": 0,
      "text": "When I was first learning to meditate, the instruction was to simply pay attention to my breath, and when my mind wandered, to bring it back. Sounded simple eno...",
      "start": 12.76,
      "end": 103.576,
      "tokenCount": 356
    },
    "..."
  ],
  "wordCount": 1509,
  "status": "ok",
  "statusReason": "Transcript extracted",
  "attempts": 1
}
```

With `outputFormat` set to `text`, `transcript` is one string. With `markdown`, it looks like this:

```markdown
## Why Scientists Are Puzzled By This Virus

### Start (0:00)

Very recently scientists discovered that your body is teeming with trillions of the most bizarre viruses ...

### You Are an Ecosystem (0:23)

You're a living, breathing ecosystem made of up to 40 trillion cells. ...
```

`chunks` is included only when you set `chunkTokens`.

### Sample input

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=-moW9jvvMr4",
    "https://youtu.be/5MuIMqhT8DM",
    "https://www.youtube.com/shorts/QM5vh0ZKvZo"
  ],
  "sources": ["https://www.youtube.com/@TED"],
  "maxVideosPerSource": 20,
  "languages": ["en", "es"],
  "outputFormat": "segments",
  "chunkTokens": 400
}
```

| Field | What it does | Default |
|---|---|---|
| `videos` | Video URLs or IDs. Watch, youtu.be, Shorts, embed and live URLs all work. Duplicates are removed. | |
| `sources` | Channel or playlist URLs to expand into videos. | |
| `maxVideosPerSource` | Videos to take from each channel or playlist. | 50 |
| `languages` | Preferred language codes, in order. `en` also matches `en-US`, `en-GB`. | `["en"]` |
| `fallbackToAnyLanguage` | If no preferred language exists, return an available one. | `true` |
| `preferManualCaptions` | Use creator-uploaded captions over auto-generated ones in the same language. | `true` |
| `outputFormat` | `segments`, `text` or `markdown`. | `segments` |
| `chunkTokens` | Also split into chunks of about this many tokens, breaking at sentence ends. | off |
| `includeMetadata` | Title, channel, duration, publish date. | `true` |
| `proxyConfiguration` | Apify Proxy settings. | Residential |
| `maxConcurrency` | Videos processed at the same time. | 10 |

### Status for every video

Every video you submit produces exactly one result. A video that fails never stops the run.

| Status | Meaning | Charged |
|---|---|---|
| `ok` | Transcript extracted. | Yes |
| `no_captions` | The video has no captions of any kind. | No |
| `language_not_available` | No captions in your languages and `fallbackToAnyLanguage` is off. `availableLanguages` lists what exists. | No |
| `private` | Private, paid or members-only video. | No |
| `deleted` | Removed, unavailable or never existed. | No |
| `age_restricted` | YouTube requires sign-in to confirm age. This Actor never signs in. | No |
| `live_not_finished` | Live stream in progress or premiere not yet started. Try again after it ends. | No |
| `blocked` | YouTube refused every attempt, after retries with fresh IP addresses. | No |
| `error` | Anything else, including input that is not a YouTube video. `statusReason` explains. | No |

`statusReason` gives a short explanation, and `attempts` shows how many tries were made.

### Pricing

This Actor uses pay-per-event pricing. You are charged for one **transcript** event per video with status `ok`. Videos with any other status are not charged. The price per transcript is shown on the Pricing tab of this page.

Apify also applies its standard small per-run start charge, shown on the same tab.

If you set a maximum charge per run, the Actor stops cleanly when it is reached. Videos it did not get to are not processed or charged, and the run summary says so.

### How it works

- Transcripts come from YouTube's own captions (manual or auto-generated). Audio and video files are never downloaded.
- No YouTube account, cookies or sign-in are used. Only public data is read.
- Requests go through Apify residential proxy by default, because YouTube blocks most datacenter and cloud addresses.
- If a request is blocked or the connection drops, the Actor retries with a new IP address and a growing delay. If the main method fails twice, it switches to a second, independent extraction method. Attempts per video are capped at five.
- If the run is restarted or migrated by the platform, finished videos are not processed or charged again.
- A run summary with counts per status is saved in the key-value store under `SUMMARY`.

### Limits

- Videos without any captions return `no_captions`. This Actor does not transcribe audio.
- Private, members-only, paid and age-restricted videos cannot be read without signing in, so they return a status instead of a transcript.
- Auto-generated captions often have little punctuation. Chunks then break at caption boundaries, close to the requested size, instead of at sentence ends.
- `tokenCount` is an estimate (characters divided by 4). Your model's tokenizer may count differently.
- `wordCount` counts space-separated words, so it undercounts languages written without spaces, such as Japanese and Chinese.
- Channel sources take videos from the channel's Videos tab. Shorts and past live streams on separate tabs are not included unless you add them as videos.
- Availability can differ by country. A video may be playable in one region and restricted in another.
- YouTube changes its internals from time to time. That can temporarily raise the share of `blocked` or `error` results until the Actor is updated.

### FAQ

**Do I need a YouTube API key or account?**
No.

**Am I charged for videos that fail?**
No. Only results with status `ok` are charged.

**Can I get the transcript in a language the video was not captioned in?**
Not in this version. You get the caption languages the video has, listed in `availableLanguages`.

**Why did a video come back as `blocked`?**
YouTube refused all attempts for that video, even after retries with new IP addresses. Run it again later. If many videos are blocked, check that the proxy setting is residential.

**Can I use datacenter proxy to save cost?**
You can select it, but in our testing YouTube refused most requests from datacenter addresses. Residential is the reliable choice.

**How do I get only the text for an LLM prompt?**
Set `outputFormat` to `text`, or `markdown` if you want headings.

**Is there a limit on video length?**
No fixed limit. Three-hour videos have been tested.

# Changelog

This Actor's version history is a separate document: https://apify.com/wilanibe/youtube-transcript/changelog.md

# Actor input Schema

## `videos` (type: `array`):

YouTube video URLs or 11-character video IDs. Accepts watch, youtu.be, Shorts, embed and live URLs. Duplicates are removed.

## `sources` (type: `array`):

Channel URLs (for example https://www.youtube.com/@TED) or playlist URLs. Each is expanded into its most recent videos, up to the limit below.

## `maxVideosPerSource` (type: `integer`):

How many videos to take from each channel or playlist, newest first for channels.

## `languages` (type: `array`):

Language codes in order of preference, for example en, es. A code like en also matches regional variants such as en-US.

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

If none of the preferred languages exist, return the transcript in a language that is available (manual captions first if preferred). If off, such videos get status language_not_available and are not charged.

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

Within a language, use creator-uploaded captions when they exist and auto-generated captions otherwise.

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

segments: list of start, duration and text in seconds. text: one plain string. markdown: title as heading, chapter headings when the video has chapters, then paragraphs.

## `chunkTokens` (type: `integer`):

When set, also returns the transcript split into chunks of about this many tokens (estimated as characters divided by 4), breaking at sentence ends where the captions have punctuation. Each chunk has start and end times. Useful for embeddings and RAG.

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

Adds title, channel, duration and publish date. Turning it off makes runs slightly faster and uses less proxy traffic.

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

YouTube blocks most datacenter and cloud IP addresses. Residential proxy is the default and recommended setting.

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

How many videos to process at the same time. Lowered automatically on small memory settings.

## Actor input object example

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=-moW9jvvMr4",
    "https://youtu.be/5MuIMqhT8DM",
    "https://www.youtube.com/shorts/QM5vh0ZKvZo"
  ],
  "maxVideosPerSource": 50,
  "languages": [
    "en"
  ],
  "fallbackToAnyLanguage": true,
  "preferManualCaptions": true,
  "outputFormat": "segments",
  "includeMetadata": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "maxConcurrency": 10
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "videos": [
        "https://www.youtube.com/watch?v=-moW9jvvMr4",
        "https://youtu.be/5MuIMqhT8DM",
        "https://www.youtube.com/shorts/QM5vh0ZKvZo"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("wilanibe/youtube-transcript").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 = {
    "videos": [
        "https://www.youtube.com/watch?v=-moW9jvvMr4",
        "https://youtu.be/5MuIMqhT8DM",
        "https://www.youtube.com/shorts/QM5vh0ZKvZo",
    ],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("wilanibe/youtube-transcript").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 '{
  "videos": [
    "https://www.youtube.com/watch?v=-moW9jvvMr4",
    "https://youtu.be/5MuIMqhT8DM",
    "https://www.youtube.com/shorts/QM5vh0ZKvZo"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call wilanibe/youtube-transcript --silent --output-dataset

```

## MCP server setup

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

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/Cb7pzBJwhKIcjFHn5/builds/mytklHy71cyD79Smn/openapi.json
