# YouTube Transcript Scraper — Subtitles, Chapters & RAG (MCP) (`datapipestudio/youtube-transcript-rag`) Actor

Fast, browser-free YouTube transcript and subtitles scraper API. Extract clean paragraphs, timestamps, chapters, rich metadata, and RAG chunks from videos, Shorts, playlists, channels, or search queries. MCP & AI-agent ready — $0 charged on failed videos.

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

## Pricing

from $1.90 / 1,000 transcript extracteds

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 — Subtitles, Chapters & RAG API (MCP)

**YouTube Transcript Scraper** by **DataPipe Studio** is a fast, browser-free Apify Actor and MCP tool that extracts clean YouTube transcripts, subtitles, timestamps, official chapters, rich metadata, and RAG-ready token chunks from **single videos, YouTube Shorts, playlists, entire channels, or YouTube search queries**.

Built on a lightweight pure-HTTP engine (256 MB RAM, zero headless browser), it runs in ~2 seconds per video, includes all platform and proxy costs in transparent pay-per-event pricing (**from $1.90 / 1,000 transcripts**), and charges **$0 on unavailable or captionless videos**.

***

### What does YouTube Transcript Scraper extract?

For every YouTube video, the scraper returns clean, structured JSON ready for LLMs, vector databases, spreadsheets, or automation workflows:

- **Clean Transcript Text (`transcriptText`)**: Automatically deduplicates YouTube auto-caption roll-ups, strips optional `[Music]` / `[Applause]` noise, and stitches readable paragraphs.
- **Timestamped Segments (`segments`)**: Exact `{start, duration, text}` array for every caption line (manual or auto-generated, with multi-language selection and automatic native-track fallback).
- **Rich Video Metadata (optional add-on)**: `title`, `channelName`, `channelId`, `viewCount`, `likeCount`, `durationSeconds`, `publishDate`, `category`, `keywords`, `thumbnailUrl`, `description`, and parsed official **`chapters`**.
- **Chapter-Aligned Markdown & RAG Chunks (optional add-on)**:
  - `chapterMarkdown`: Official YouTube chapters rendered as clean Markdown with clickable `https://youtu.be/{id}?t={sec}` deep links (automatically falls back to 3-minute sections when a video has no chapters).
  - `ragChunks`: Overlapping token-sized chunks (`chunkIndex`, `startSec`, `endSec`, `timestamp`, `deepLinkUrl`, `chapterTitle`, `videoTitle`, `channelName`, `approxTokens`, `text`) ready to embed directly into **Pinecone, Qdrant, Weaviate, Supabase pgvector, LangChain, or LlamaIndex**.

***

### Why choose this YouTube Transcript Scraper?

| Capability | DataPipe Studio YouTube Transcript Scraper | Basic Transcript Scrapers |
|---|---|---|
| **Supported inputs** | Videos, Shorts, Playlists, Channels (`@handle` & `UC...`), Search Queries | Single video URLs only |
| **Output cleanliness** | Deduplicated auto-captions, stitched paragraphs, optional `[Music]` removal | Raw overlapping XML/JSON fragments |
| **AI & RAG readiness** | Built-in **chapter Markdown** + **overlapping RAG token chunks** with deep links | Requires custom chunking & cleaning code |
| **Multi-client resilience** | Pure-HTTP cascade (`ANDROID` → `IOS` → `WEB`) + automatic IP retry on empty responses | Single endpoint breaks silently |
| **Fair billing** | **$0 charged** on private, unavailable, or captionless videos | Frequently charges on empty/failed items |
| **MCP & Agentic Payments** | Enabled (`Limited permissions`) — works out of the box with `https://mcp.apify.com` | Often requires full permissions or manual setup |

***

### How much does it cost to scrape YouTube transcripts?

All platform compute and residential proxy costs are **included** in the pay-per-event price. You only pay for videos that return a valid transcript:

| Event | Free Plan | Starter (Bronze) | Scale (Silver) | Business (Gold) | Included |
|---|---:|---:|---:|---:|---|
| **Actor Start** (`apify-actor-start`) | $0.002 | $0.002 | $0.002 | $0.0015 | One-time run initialization |
| **Transcript Extracted** (`transcript-extracted`) | $4.00 / 1k | **$3.00 / 1k** | **$2.40 / 1k** | **$1.90 / 1k** | Clean transcript text, language info, timestamped segments |
| **Rich Video Metadata** (`metadata-enriched`, optional) | +$3.00 / 1k | +$2.00 / 1k | +$1.80 / 1k | +$1.50 / 1k | Stats, channel info, publish date, keywords, chapters, description |
| **Chapter Markdown & RAG Chunks** (`rag-chunks-generated`, optional) | +$2.50 / 1k | +$1.50 / 1k | +$1.30 / 1k | +$1.10 / 1k | Clickable chapter Markdown + overlapping RAG chunks |

- **Free Apify tier:** Includes $5 monthly credit (~1,250 test transcripts, capped at 15 videos per run).
- **Paid Apify plans:** Up to **5,000 videos per run** with automatic Starter/Scale/Business volume discounts.

***

### How to scrape YouTube transcripts in bulk

#### 1. Videos, Shorts, Playlists & Channels (JSON Input)

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=aircAruvnKk",
    "https://youtu.be/kqtD5dpn9C8",
    "https://www.youtube.com/shorts/aircAruvnKk",
    "https://www.youtube.com/@3blue1brown",
    "https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi"
  ],
  "maxVideos": 25,
  "languages": ["en"],
  "includeTimestamps": true,
  "includeMetadata": true,
  "includeRagChunks": true,
  "ragChunkTokens": 400,
  "ragChunkOverlapTokens": 50
}
```

#### 2. YouTube Search to RAG Chunks

```json
{
  "searchQueries": ["python asyncio tutorial", "retrieval augmented generation"],
  "maxVideos": 10,
  "languages": ["en"],
  "includeTimestamps": false,
  "includeMetadata": true,
  "includeRagChunks": true
}
```

***

### How to use with Python, Node.js, cURL, n8n & MCP (Claude / Cursor / ChatGPT)

#### Apify MCP Server (Claude Desktop, Cursor, AI Agents)

Because this Actor uses **`Limited permissions`** and Pay-Per-Event pricing, it is automatically compatible with **`https://mcp.apify.com`** and autonomous agentic payments:

1. Connect your AI client (Claude, Cursor, ChatGPT, or LangGraph) to `https://mcp.apify.com`.
2. Call `datapipestudio/youtube-transcript-rag` with `urls` or `searchQueries`. For minimal LLM context bloat, set `includeTimestamps: false` and `includeRagChunks: true`.

#### Python API Example (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_API_TOKEN")

run = client.actor("datapipestudio/youtube-transcript-rag").call(run_input={
    "urls": ["https://www.youtube.com/watch?v=aircAruvnKk"],
    "languages": ["en"],
    "includeMetadata": True,
    "includeRagChunks": True,
    "ragChunkTokens": 400,
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["title"], "->", item["ragChunkCount"], "RAG chunks")
```

#### n8n / Make / Webhook Automation

Add the official **Apify node** in n8n or Make, select **`datapipestudio/youtube-transcript-rag`**, pass any YouTube channel URL on a weekly schedule, and send `ragChunks` directly to your vector store or summarization node.

***

### Example Output Item

```json
{
  "videoId": "aircAruvnKk",
  "url": "https://www.youtube.com/watch?v=aircAruvnKk",
  "status": "ok",
  "source": "url",
  "language": "en",
  "sourceLanguage": "en",
  "isAutoGenerated": false,
  "isTranslated": false,
  "availableLanguages": ["ar", "de", "en", "es", "fr", "ja"],
  "segmentCount": 312,
  "wordCount": 3357,
  "title": "But what is a neural network? | Deep learning chapter 1",
  "channelName": "3Blue1Brown",
  "channelId": "UCYO_jab_esuFRV4b17AJtAw",
  "viewCount": 19500000,
  "durationSeconds": 1153,
  "publishDate": "2017-10-05",
  "chapters": [
    { "startSec": 0, "timestamp": "00:00", "title": "Introduction example" },
    { "startSec": 127, "timestamp": "02:07", "title": "Series preview" }
  ],
  "transcriptText": "This is a three. It's sloppily written and rendered at an extremely low resolution...",
  "chapterMarkdown": "# But what is a neural network?...\n\n## [00:00](https://youtu.be/aircAruvnKk?t=0) Introduction example\n...",
  "ragChunkCount": 14,
  "ragChunks": [
    {
      "chunkIndex": 0,
      "startSec": 0,
      "endSec": 148,
      "durationSec": 148,
      "timestamp": "00:00",
      "deepLinkUrl": "https://youtu.be/aircAruvnKk?t=0",
      "chapterTitle": "Introduction example",
      "videoTitle": "But what is a neural network? | Deep learning chapter 1",
      "channelName": "3Blue1Brown",
      "approxTokens": 392,
      "text": "..."
    }
  ]
}
```

***

### Frequently Asked Questions (FAQ)

#### Can I scrape transcripts from an entire YouTube channel or playlist?

Yes. Pass any channel URL (`https://www.youtube.com/@handle` or `/channel/UC...`) or playlist URL (`?list=PL...`) in `urls` and set `maxVideos` (up to 5,000 on paid plans). The Actor automatically resolves video IDs, deduplicates them, and extracts transcripts in parallel.

#### Does it work on YouTube Shorts and live stream replays?

Yes. Pass any `youtube.com/shorts/...`, `youtube.com/live/...`, `youtu.be/...`, `youtube.com/embed/...`, or bare 11-character video ID.

#### How does it handle multiple languages and auto-generated captions?

Provide an ordered `languages` list (for example `["en", "es", "ar"]`). The Actor prioritizes human-written manual captions first, then auto-generated (`asr`) captions, then YouTube auto-translation (`allowAutoTranslation: true`), and automatically falls back to the video's native caption track if YouTube blocks translation on a signed URL.

#### Can I export YouTube transcripts as RAG chunks for LangChain, Pinecone, or Supabase?

Yes. Enable `includeRagChunks: true` and set `ragChunkTokens` (default `400`) and `ragChunkOverlapTokens` (default `50`). Every chunk includes `deepLinkUrl`, `startSec`, `endSec`, `chapterTitle`, `videoTitle`, and `approxTokens`.

#### Do I get charged for private, deleted, or captionless videos?

No. Unavailable or captionless videos are logged cleanly in the dataset (`status: "unavailable"` or `"no_captions"`) and trigger **$0 in per-video charges**.

#### Does this Actor use a headless browser?

No. It runs on a lightweight pure-HTTP Python engine using only ~65 MB of RAM (256 MB container), making it faster and far more reliable than browser-based YouTube scrapers.

# Actor input Schema

## `urls` (type: `array`):

List of YouTube video URLs, Shorts URLs, bare 11-char video IDs, playlist URLs, or channel URLs (@handle or /channel/UC...).

## `searchQueries` (type: `array`):

Optional search queries to automatically discover videos and extract their transcripts.

## `maxVideos` (type: `integer`):

Maximum total videos to extract across all inputs. Free Apify plans are capped at 15 videos per run; paid plans support up to 5,000.

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

Ordered list of preferred transcript language codes (e.g. \['en', 'es', 'ar']). Manual captions are preferred over auto-generated.

## `allowAutoTranslation` (type: `boolean`):

If none of the preferred languages exist natively, request YouTube's built-in translation to the first preferred language.

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

Include the raw array of {start, duration, text} caption segments in each output item.

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

Include title, channel info, views, likes, duration, publish date, keywords, chapters, and description.

## `includeRagChunks` (type: `boolean`):

Generate chapter-aligned Markdown with clickable timestamps plus pre-chunked RAG segments ready for vector databases and LLMs.

## `ragChunkTokens` (type: `integer`):

Approximate token size for each generated RAG chunk (used only when Generate RAG Chunks is enabled).

## `ragChunkOverlapTokens` (type: `integer`):

Approximate token overlap between consecutive RAG chunks to preserve context across boundaries.

## `stripSoundMarkers` (type: `boolean`):

Remove bracketed non-speech sound annotations like \[Music] or \[Applause] from clean text and RAG chunks.

## `concurrency` (type: `integer`):

Number of videos to extract in parallel.

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

Residential proxies are recommended on cloud IPs because YouTube rate-limits datacenter ranges.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "searchQueries": [],
  "maxVideos": 10,
  "languages": [
    "en"
  ],
  "allowAutoTranslation": true,
  "includeTimestamps": true,
  "includeMetadata": true,
  "includeRagChunks": false,
  "ragChunkTokens": 400,
  "ragChunkOverlapTokens": 50,
  "stripSoundMarkers": true,
  "concurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

Table view of extracted videos, transcripts, chapters, and RAG chunk counts.

## `fullDataset` (type: `string`):

Complete structured JSON output including timestamped segments, chapter Markdown, and RAG chunks.

# 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 = {
    "urls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datapipestudio/youtube-transcript-rag").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 = { "urls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"] }

# Run the Actor and wait for it to finish
run = client.actor("datapipestudio/youtube-transcript-rag").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 '{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ]
}' |
apify call datapipestudio/youtube-transcript-rag --silent --output-dataset

```

## MCP server setup

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

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/U1qbcLqsFeA6dNmpE/builds/WOptAWPK83HJiyEh7/openapi.json
