# YouTube Transcript API — Captions to JSON + LLM (`rikitrader/youtube-transcript-api`) Actor

Extract YouTube video transcripts + metadata in any language, incl. whole channels & playlists. JSON + LLM-ready Markdown + RAG chunks with real token counts. No API key. Pay per result.

- **URL**: https://apify.com/rikitrader/youtube-transcript-api.md
- **Developed by:** [\[R\] Kuantum](https://apify.com/rikitrader) (community)
- **Categories:** AI, Videos, Developer tools
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 API — Captions to JSON + LLM-ready text

**Get any YouTube video's transcript as clean, structured, AI-ready text.** Extract transcripts and metadata from **YouTube** — single videos, or **whole channels and playlists** — in **any available language**. Every result ships as **JSON** *and* **LLM-ready** formats (clean Markdown + token-aware **RAG chunks**), so it drops straight into ChatGPT, Claude, a vector database, or your analytics pipeline.

> No API keys. No monthly lock-in. **Pay only for what you extract.**

***

### ⚡ Why this one

- **YouTube done right.** It solves YouTube's JavaScript/PoToken challenge and consent walls (via `yt-dlp` + `deno`) — the stuff that breaks naive scrapers. Use residential proxy for scale.
- **LLM-ready out of the box.** Not just raw captions — cleaned plain text, paragraphed Markdown, and **embedding-ready chunks** whose size and `token_estimate` come from a real tokenizer (tiktoken `o200k`/`cl100k`), accurate even for CJK/emoji/code.
- **Channels & playlists.** Paste a channel or playlist URL → it transcribes the videos (bounded by `maxVideosPerList`).
- **Any language.** Requests your preferred language and falls back to the closest available variant.

### 🚀 Build with it

- **"Chat with a YouTube channel"** — transcribe a creator's catalog, embed the chunks, ship a RAG bot.
- **Research & datasets** — talks, lectures, podcasts as clean timestamped text in any language.
- **Repurposing** — turn a video into a blog post, summary, or show notes from the Markdown.
- **Analytics** — bulk-pull transcripts for sentiment / topic analysis.

### 📥 Input (highlights)

| Field | Type | Default | Description |
|---|---|---|---|
| `videoUrls` | array | — (required) | YouTube video, channel, or playlist URLs. |
| `language` | string | `en` | Preferred subtitle language; falls back to the closest variant. |
| `maxVideosPerList` | integer | `20` | Cap per channel/playlist (max 200; run ceiling 1,000). |
| `outputFormats` | array | all | `json`, `text`, `markdown`, `chunks`. |
| `chunkTokens` / `tokenizer` | — | `400` / `o200k` | Real, enforced token budget for RAG chunks. |
| `translateTo` | string | — | Optionally also return a translated copy. **Best-effort, often unavailable** — uses YouTube's auto-translation. |
| `proxyConfiguration` | object | Datacenter | Enable **residential** for reliable YouTube at scale. |

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=UF8uR6Z6KLc"],
  "language": "en",
  "outputFormats": ["json", "text", "markdown", "chunks"],
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

### 📤 Output

One dataset item per video: normalized metadata (title, channel, duration, views, upload date), `transcript_found`, `is_auto_generated`, `selected_language`, plus `text`, timestamped `transcript`, LLM-ready `markdown`, and token-aware `chunks` (with exact `token_estimate`). Add `translateTo` for a `translated` object alongside the original.

### 💸 Pricing

**Pay-per-result** — you pay per video successfully transcribed, no monthly subscription. Free Apify tier available to try it.

### ❓ Notes

Extraction needs the video to expose a caption track (human **or** auto-generated); no-caption videos return metadata only (enable **Best effort**). This is the YouTube-focused edition of a broader [**Video Transcript Scraper**](https://apify.com/rikitrader/video-transcript-scraper) that also covers Vimeo, TED, Dailymotion, and 1,000+ caption-bearing sites — same engine.

*Keywords: YouTube transcript API, YouTube captions to JSON, YouTube subtitles download, transcript for LLM, RAG, YouTube channel transcript, playlist transcript, video to text, any language.*

# Actor input Schema

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

One or more YouTube video, channel, or playlist URLs. Channels/playlists are expanded into their videos (see Max videos per list).

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

Preferred subtitle language code (ISO, e.g. 'en', 'es', 'fr', 'de', 'pt'). Falls back to the closest available variant (e.g. es → es-419) when the exact code is missing.

## `includeAutoCaptions` (type: `boolean`):

When no human-made subtitle track exists, fall back to the platform's machine-generated captions.

## `outputFormats` (type: `array`):

Which representations to include in each result. 'chunks' produces token-aware, embedding-ready segments for RAG / conversational agents.

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

Token budget per RAG chunk (used only when 'chunks' is selected). Enforced with a real tokenizer — see 'Tokenizer' — so it is accurate even for CJK/emoji/code.

## `tokenizer` (type: `string`):

Tokenizer for chunk sizing + token\_estimate. 'o200k' (GPT-4o / text-embedding-3) and 'cl100k' (ada-002 / GPT-3.5-4) are exact via tiktoken and a good proxy for Claude/Gemini; 'chars' is the fast chars/4 heuristic (under-counts CJK).

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

Optionally also return the transcript translated to this language (e.g. 'es', 'fr'). Best-effort and YouTube-only — uses YouTube's auto-translation, which isn't offered for every video/language. Adds a second extraction per video; result appears under 'translated' (null when unavailable).

## `includeTimestamps` (type: `boolean`):

Include the per-segment start/end array in the JSON output.

## `bestEffort` (type: `boolean`):

Return a row with metadata (and an 'error' note) even when no transcript is available, instead of skipping the URL.

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

How many videos to process in parallel.

## `maxVideosPerList` (type: `integer`):

When a channel/playlist URL is given, transcribe at most this many of its videos (most recent first). A total ceiling of 1000 videos per run also applies.

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

Apify Proxy settings. Defaults to low-cost DATACENTER proxy (good for TED, Vimeo, Loom, and most sites). For YouTube or high volume, switch on RESIDENTIAL proxy in the selector — YouTube frequently rate-limits or blocks datacenter IPs.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=UF8uR6Z6KLc"
  ],
  "language": "en",
  "includeAutoCaptions": true,
  "outputFormats": [
    "json",
    "text",
    "markdown",
    "chunks"
  ],
  "chunkTokens": 400,
  "tokenizer": "o200k",
  "includeTimestamps": true,
  "bestEffort": false,
  "maxConcurrency": 5,
  "maxVideosPerList": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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=UF8uR6Z6KLc"
    ],
    "language": "en",
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("rikitrader/youtube-transcript-api").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=UF8uR6Z6KLc"],
    "language": "en",
    "proxyConfiguration": { "useApifyProxy": True },
}

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

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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=UF8uR6Z6KLc"
  ],
  "language": "en",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call rikitrader/youtube-transcript-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=rikitrader/youtube-transcript-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/YdKDWDHbyhZzGmKz0/builds/aLY24bra5oYrTgOmR/openapi.json
