# YouTube Transcript Extractor - Bulk Captions & Subtitles API (`apricot_blackberry/youtube-transcript-extractor`) Actor

Extract YouTube transcripts in bulk. Timestamped segments, plain text, SRT and VTT from any video URL or ID. Auto and manual captions, 100+ languages. Pay only for successful transcripts.

- **URL**: https://apify.com/apricot\_blackberry/youtube-transcript-extractor.md
- **Developed by:** [Creator Fusion](https://apify.com/apricot_blackberry) (community)
- **Categories:** Videos, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## YouTube Transcript Extractor — Bulk Captions API for AI Agents & RAG Pipelines

Extract **YouTube transcripts** at scale and get **typed JSON rows** back: timestamped segments, clean plain text, and optional SRT/WebVTT subtitle files. Works with manual and auto-generated captions in 100+ languages. Built for AI agents, RAG pipelines, and automation — the full output schema is published below and enforced by the platform.

**You only pay for successful transcripts.** Videos with no captions, unavailable videos, and extraction failures are reported as error rows and cost nothing beyond the run start.

### Why AI agents use this YouTube transcript extractor

- **Deterministic typed output** — every row conforms to the published dataset schema; no HTML, no parsing surprises.
- **Cost-predictable** — flat per-transcript event pricing; failed videos are never charged, so budget = videos × price, worst case.
- **No auth, no cookies, no API keys** — paste URLs, get transcripts.
- **Clear error semantics** — per-video `error` field with a human-readable reason; the run fails (exit 1) only when *zero* videos succeed, so partial batches still return data.
- **Cost-tiered networking** — each video is tried over a direct connection first (free), then the standard datacenter proxy (included in Apify plans), and only escalates to residential proxy on failure — and only if you leave `residentialFallback` on.

### Input schema

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `videoUrls` | array of strings | **yes** | — | YouTube URLs (`watch?v=`, `youtu.be`, Shorts, live, embed) or bare 11-char video IDs |
| `language` | string | no | `"en"` | Preferred caption language (ISO code). Manual captions win over auto-generated |
| `fallbackToAutoCaptions` | boolean | no | `true` | Use auto-generated captions when no manual track matches |
| `fallbackToAnyLanguage` | boolean | no | `true` | Take any available track when the preferred language is missing |
| `formats` | array | no | `[]` | Add `"srt"` and/or `"vtt"` subtitle strings to each row |
| `includeSegments` | boolean | no | `true` | Include the timestamped `segments` array |
| `residentialFallback` | boolean | no | `true` | Escalate to residential proxy only for videos that failed direct + datacenter attempts. Residential traffic is billed to your account per GB (transcripts are tiny). Disable to guarantee zero residential cost |
| `proxyConfiguration` | object | no | datacenter | Standard proxy used from the 2nd attempt per video; 1st attempt is always a free direct connection |

### Output schema

One row per input video. Success rows have `error` absent; failure rows contain `error` plus whatever metadata was recoverable.

| Field | Type | Description |
|---|---|---|
| `videoId` | string | 11-char video ID |
| `url` | string | Canonical watch URL |
| `title` | string | null | Video title |
| `channel` | string | null | Channel name |
| `channelId` | string | null | Channel ID (UC…) |
| `durationSeconds` | number | null | Video length |
| `viewCount` | number | null | Views at scrape time |
| `language` | string | Language of the extracted track |
| `isAutoGenerated` | boolean | True for auto (ASR) captions |
| `availableLanguages` | string\[] | All tracks on the video, auto tracks suffixed `(auto)` |
| `text` | string | Full transcript as one plain string — LLM-ready |
| `segmentCount` | number | Number of segments |
| `segments` | `{start, duration, text}[]` | Timestamped segments (seconds) |
| `srt` / `vtt` | string | Complete subtitle file content (only if requested in `formats`) |
| `error` | string | Failure rows only: reason. **Never charged** |

#### Example success row

```json
{
    "videoId": "dQw4w9WgXcQ",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "title": "Rick Astley - Never Gonna Give You Up (Official Video)",
    "channel": "Rick Astley",
    "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
    "durationSeconds": 213,
    "viewCount": 1690000000,
    "language": "en",
    "isAutoGenerated": false,
    "availableLanguages": ["en", "en (auto)", "de-DE", "ja"],
    "text": "We're no strangers to love You know the rules and so do I ...",
    "segmentCount": 61,
    "segments": [
        { "start": 18.64, "duration": 3.24, "text": "We're no strangers to love" }
    ]
}
```

#### Example failure row

```json
{
    "videoId": "jNQXAC9IVRw",
    "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "title": "Me at the zoo",
    "error": "No captions in \"xx\". Available: en, de"
}
```

### Error semantics (for retry logic)

- **Invalid input** (empty `videoUrls`): run fails immediately, exit 1, clear status message.
- **Per-video failure**: error row in the dataset; the run still SUCCEEDS if at least one video produced a transcript.
- **All videos failed**: run FAILS (exit 1) with the first failure reason in the status message — safe to alert on.
- Each video gets 3 attempts with escalating network tiers before its error row is written.

### Use from AI agents (MCP)

Add this actor as a tool in Claude, Cursor, ChatGPT connectors, or any MCP client — the input schema above is the tool's parameter schema:

```json
{
    "mcpServers": {
        "apify": {
            "url": "https://mcp.apify.com/?tools=apricot_blackberry/youtube-transcript-extractor",
            "headers": { "Authorization": "Bearer <YOUR_APIFY_TOKEN>" }
        }
    }
}
```

### Use from code

**curl** (synchronous — returns dataset items directly):

```bash
curl -X POST "https://api.apify.com/v2/acts/apricot_blackberry~youtube-transcript-extractor/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"], "language": "en"}'
```

**JavaScript** (`npm i apify-client`):

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('apricot_blackberry/youtube-transcript-extractor').call({
    videoUrls: ['https://www.youtube.com/watch?v=dQw4w9WgXcQ'],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("apricot_blackberry/youtube-transcript-extractor").call(
    run_input={"videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"]}
)
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

### Use from automation platforms

- **n8n / Make / Zapier** — use the native Apify integration and select this actor by name.
- **LangChain / LlamaIndex** — use the Apify tool/loader wrappers with actor id `apricot_blackberry/youtube-transcript-extractor`.
- **Webhooks** — Apify webhooks can fire on run completion (e.g. `ACTOR.RUN.SUCCEEDED`) to push transcripts into your own pipeline the moment a run finishes, no polling required.

### Pricing

| Event | When it's charged |
|---|---|
| Actor start | Once per run |
| Transcript extracted | Only when a transcript is successfully extracted |

No captions? Video unavailable? **Not charged.**

### FAQ

**Does it work on videos without manual subtitles?**
Yes — it falls back to YouTube's auto-generated captions (configurable).

**Does it download the video or audio?**
No. It reads YouTube's caption data directly — a transcript typically takes 1-2 seconds.

**What about YouTube Shorts?**
Fully supported — paste the Shorts URL as-is.

**Will I be charged proxy costs?**
Direct connection is tried first (free). The datacenter proxy tier is included in Apify plans. Residential is used only as a last resort per video and can be disabled entirely with `residentialFallback: false`.

**How many videos per run?**
No hard limit; 5 videos are processed concurrently. Thousands per run is fine.

### Changelog

- **1.1** — Published enforced output schema; cost-tiered proxy escalation (direct → datacenter → optional residential); agent/MCP integration docs.
- **1.0** — Initial release: bulk extraction, language fallbacks, SRT/VTT, metadata, success-only billing.

# Actor input Schema

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

YouTube video URLs (watch, youtu.be, Shorts, live, embed) or bare 11-character video IDs. One transcript per video.

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

ISO language code to prefer (e.g. en, es, de, pt, ja). Manual captions in this language win over auto-generated ones.

## `fallbackToAutoCaptions` (type: `boolean`):

Use YouTube's auto-generated captions when no manual captions exist in the preferred language.

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

If nothing matches the preferred language, take the first available caption track instead of failing the video.

## `formats` (type: `array`):

Plain text and timestamped segments are always included. Optionally add subtitle file formats.

## `includeSegments` (type: `boolean`):

Include the segments array (start, duration, text). Turn off for smaller items when you only need plain text.

## `residentialFallback` (type: `boolean`):

Escalate to residential proxies ONLY for videos that fail via both direct connection and the standard proxy. Residential traffic is billed to your Apify account per GB (transcripts are small, typically well under 1 MB per video). Disable to never incur residential costs.

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

Standard proxy used from the second attempt per video (the first attempt connects directly, which is free). Datacenter by default - included in Apify plans. Residential escalation is controlled separately by 'Residential proxy fallback'.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "language": "en",
  "fallbackToAutoCaptions": true,
  "fallbackToAnyLanguage": true,
  "formats": [],
  "includeSegments": true,
  "residentialFallback": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `transcripts` (type: `string`):

All extracted transcript rows (one per video). Success rows carry text/segments/metadata; failed rows carry an error field and are never charged.

# 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=dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("apricot_blackberry/youtube-transcript-extractor").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=dQw4w9WgXcQ"] }

# Run the Actor and wait for it to finish
run = client.actor("apricot_blackberry/youtube-transcript-extractor").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=dQw4w9WgXcQ"
  ]
}' |
apify call apricot_blackberry/youtube-transcript-extractor --silent --output-dataset

```

## MCP server setup

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

```

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/oOQUs5hQ2j2sK3vqZ/builds/2VV7gLRgnNXf83xUg/openapi.json
