# YouTube Transcript to RAG Dataset (`ghostgrid/youtube-transcript-to-rag`) Actor

Extract YouTube transcripts and convert them into RAG-ready chunks with timestamps, metadata, and content hashes.

- **URL**: https://apify.com/ghostgrid/youtube-transcript-to-rag.md
- **Developed by:** [GhostGrid](https://apify.com/ghostgrid) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 page processeds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 to RAG Dataset

Extract YouTube video transcripts and convert them into structured, RAG-ready chunks with timestamps, metadata, and content hashes. No API key required.

### What does this Actor do?

This Actor takes YouTube video URLs, fetches their transcripts using the YouTube transcript API, and splits them into chunks optimized for Retrieval-Augmented Generation (RAG) pipelines. Each chunk includes precise timestamps, stable IDs, content hashes, and token estimates. It also outputs the raw transcript alongside the chunks.

### Why use it?

- Build knowledge bases from YouTube content without manual transcription
- Feed video transcripts into vector databases, search systems, or LLM context windows
- Get stable, deterministic chunk IDs so re-runs produce the same identifiers
- No YouTube Data API key needed for basic metadata (uses oEmbed)
- Choose from three chunking strategies to fit your embedding model's context window

### Data Fields

#### Chunk Records

| Field | Type | Description |
|---|---|---|
| type | string | Always "chunk" |
| chunk_id | string | Stable UUID based on video ID and start time |
| video_id | string | YouTube video ID |
| video_url | string | Full YouTube URL |
| video_title | string | Video title from oEmbed |
| channel_name | string | Channel name from oEmbed |
| duration_seconds | float | Total video duration |
| language | string | Transcript language code |
| start_time | float | Chunk start time in seconds |
| end_time | float | Chunk end time in seconds |
| text | string | Chunk text content |
| source_url | string | YouTube URL with timestamp parameter |
| content_hash | string | SHA-256 hash of chunk text |
| token_estimate | int | Estimated token count (chars / 4) |
| chunk_index | int | Zero-based index of this chunk |
| total_chunks | int | Total chunks for this video |
| crawled_at | string | ISO timestamp of when data was fetched |

#### Transcript Records

| Field | Type | Description |
|---|---|---|
| type | string | Always "transcript" |
| video_id | string | YouTube video ID |
| video_url | string | Full YouTube URL |
| video_title | string | Video title |
| channel_name | string | Channel name |
| duration_seconds | float | Video duration |
| language | string | Language code |
| transcript_text | string | Full concatenated transcript |
| segments | array | List of {text, start, duration} objects |
| word_count | int | Total word count |
| token_estimate | int | Estimated token count |
| crawled_at | string | ISO timestamp |

### How to Use

1. Go to the Actor page on Apify
2. Click "Start" or configure input
3. Add YouTube video URLs to the `video_urls` array
4. Choose your chunk strategy (timestamp, fixed_size, or sentence)
5. Set chunk duration or token limit depending on strategy
6. Run the Actor
7. Download results from the Dataset tab as JSON, CSV, or Excel

### Pricing

This Actor uses the Apify platform pricing model. Costs are based on:

- **Compute**: ~0.5 CU per video processed (simple API calls, no browser)
- **Transcript charges**: 1 platform event per video processed via `Actor.charge()`
- **Dataset storage**: Standard Apify dataset storage rates apply

A typical run processing 50 videos costs well under 1 CU total.

### Input Parameters

| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
| video_urls | array | - | Yes | YouTube video URLs |
| languages | array | ["en"] | No | Preferred transcript languages (ISO codes) |
| chunk_strategy | string | "timestamp" | No | Chunking method: timestamp, fixed_size, sentence |
| chunk_duration_seconds | integer | 60 | No | Seconds per chunk (timestamp strategy) |
| chunk_token_limit | integer | 512 | No | Max tokens per chunk (fixed_size strategy) |
| include_raw_transcript | boolean | true | No | Include full raw transcript in output |
| max_videos | integer | 50 | No | Maximum videos to process (1-500) |

### Output Example

#### Chunk record:
```json
{
  "type": "chunk",
  "chunk_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "video_id": "dQw4w9WgXcQ",
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "video_title": "Rick Astley - Never Gonna Give You Up",
  "channel_name": "Rick Astley",
  "duration_seconds": 214,
  "language": "en",
  "start_time": 0.0,
  "end_time": 60.5,
  "text": "This is an example transcript chunk.",
  "source_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=0",
  "content_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  "token_estimate": 150,
  "chunk_index": 0,
  "total_chunks": 4,
  "crawled_at": "2026-07-04T12:00:00+00:00"
}
````

#### Transcript record:

```json
{
  "type": "transcript",
  "video_id": "dQw4w9WgXcQ",
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "video_title": "Rick Astley - Never Gonna Give You Up",
  "channel_name": "Rick Astley",
  "duration_seconds": 214,
  "language": "en",
  "transcript_text": "This is an example transcript.",
  "segments": [{"text": "This is an example transcript.", "start": 0.0, "duration": 2.5}],
  "word_count": 1500,
  "token_estimate": 375,
  "crawled_at": "2026-07-04T12:00:00+00:00"
}
```

### FAQ

**Q: Does this require a YouTube API key?**
A: No. Transcripts are fetched via the youtube-transcript-api library and metadata comes from the oEmbed endpoint, both of which work without API keys.

**Q: What languages are supported?**
A: Any language that has subtitles/captions on the YouTube video. Set the `languages` parameter with ISO codes in order of preference.

**Q: How are chunk IDs generated?**
A: Chunk IDs are deterministic UUID5 values based on the video ID, start time, and chunk index. Re-running the same video produces the same chunk IDs.

**Q: Can I process playlists?**
A: No. This Actor accepts individual video URLs only. Playlist expansion requires the YouTube Data API which needs an API key.

**Q: What happens if a video has no transcript?**
A: The Actor logs a warning and skips that video. Processing continues with the remaining URLs.

### Disclaimer

This Actor relies on the youtube-transcript-api library and YouTube's oEmbed endpoint. YouTube may change access behavior or rate limit requests at any time. This Actor is not affiliated with YouTube or Google. Use responsibly and respect YouTube's Terms of Service.

# Actor input Schema

## `video_urls` (type: `array`):

YouTube video URLs to extract transcripts from.

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

Preferred transcript languages (ISO codes). Default: en.

## `chunk_strategy` (type: `string`):

How to split transcripts into chunks.

## `chunk_duration_seconds` (type: `integer`):

Duration per chunk in seconds (for timestamp strategy).

## `chunk_token_limit` (type: `integer`):

Max tokens per chunk (for fixed\_size strategy).

## `include_raw_transcript` (type: `boolean`):

Include the full raw transcript in output.

## `max_videos` (type: `integer`):

Maximum number of videos to process.

## Actor input object example

```json
{
  "video_urls": [
    "https://www.youtube.com/watch?v=VIDEO_ID"
  ],
  "languages": [
    "en"
  ],
  "chunk_strategy": "timestamp",
  "chunk_duration_seconds": 60,
  "chunk_token_limit": 512,
  "include_raw_transcript": true,
  "max_videos": 50
}
```

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

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

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Transcript to RAG Dataset",
        "description": "Extract YouTube transcripts and convert them into RAG-ready chunks with timestamps, metadata, and content hashes.",
        "version": "0.1",
        "x-build-id": "veSy4plHJFm2i8Ylg"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/ghostgrid~youtube-transcript-to-rag/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-ghostgrid-youtube-transcript-to-rag",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/ghostgrid~youtube-transcript-to-rag/runs": {
            "post": {
                "operationId": "runs-sync-ghostgrid-youtube-transcript-to-rag",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/ghostgrid~youtube-transcript-to-rag/run-sync": {
            "post": {
                "operationId": "run-sync-ghostgrid-youtube-transcript-to-rag",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "video_urls"
                ],
                "properties": {
                    "video_urls": {
                        "title": "Video URLs",
                        "type": "array",
                        "description": "YouTube video URLs to extract transcripts from."
                    },
                    "languages": {
                        "title": "Preferred Languages",
                        "type": "array",
                        "description": "Preferred transcript languages (ISO codes). Default: en.",
                        "default": [
                            "en"
                        ]
                    },
                    "chunk_strategy": {
                        "title": "Chunk Strategy",
                        "enum": [
                            "timestamp",
                            "fixed_size",
                            "sentence"
                        ],
                        "type": "string",
                        "description": "How to split transcripts into chunks.",
                        "default": "timestamp"
                    },
                    "chunk_duration_seconds": {
                        "title": "Chunk Duration (seconds)",
                        "minimum": 10,
                        "maximum": 600,
                        "type": "integer",
                        "description": "Duration per chunk in seconds (for timestamp strategy).",
                        "default": 60
                    },
                    "chunk_token_limit": {
                        "title": "Chunk Token Limit",
                        "minimum": 100,
                        "maximum": 4096,
                        "type": "integer",
                        "description": "Max tokens per chunk (for fixed_size strategy).",
                        "default": 512
                    },
                    "include_raw_transcript": {
                        "title": "Include Raw Transcript",
                        "type": "boolean",
                        "description": "Include the full raw transcript in output.",
                        "default": true
                    },
                    "max_videos": {
                        "title": "Max Videos",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of videos to process.",
                        "default": 50
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
