# YouTube Transcript & Captions Scraper (`drain54/youtube-transcript-scraper`) Actor

Extract fast, clean YouTube video transcripts with timestamps, text, token counts, and video metadata for AI agents and LLM ingestion.

- **URL**: https://apify.com/drain54/youtube-transcript-scraper.md
- **Developed by:** [Indra Darmawan](https://apify.com/drain54) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 transcribed youtube videos

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/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 & Captions Scraper 🎬

Extract fast, clean, and complete YouTube video transcripts with timestamps, text, token counts, and video metadata in seconds. Designed specifically for AI agents, LLM ingestion, automated video summarization, and RAG pipelines.

***

### What does YouTube Transcript Scraper do?

YouTube Transcript Scraper extracts transcripts and closed captions from any public YouTube video, YouTube Short, or Video ID:

- **Clean Full Transcript**: Continuous plain-text transcript stripped of formatting, ready for LLMs.
- **Timestamped Segments**: Start time, duration, and text for every caption segment.
- **Video Metadata**: Title, channel name, channel URL, and high-res thumbnail URL.
- **LLM Token Estimation**: Pre-computed character and token counts for context planning.
- **Lightning Fast**: Pure HTTP extraction (sub-second per video), zero heavy browser overhead.

***

### Why use YouTube Transcript Scraper?

- **AI Summarization & RAG**: Feed YouTube video transcripts directly into ChatGPT, Claude, LangChain, or vector databases.
- **Content Repurposing**: Turn YouTube videos into blog posts, newsletters, Twitter/X threads, or LinkedIn posts.
- **Pay Per Event (PPE)**: Ultra-cheap micropayment per video transcribed ($0.002 per video), avoiding expensive subscriptions.
- **Support Shorts & Long Videos**: Works with standard videos and YouTube Shorts alike.

***

### How to use

1. Enter one or more **YouTube Video URLs** or IDs (one per line).
2. Toggle whether to include timestamped segments.
3. Click **Start** to run the scraper.
4. Download your transcripts in JSON, CSV, or Excel format.

#### Input Example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "https://youtu.be/dQw4w9WgXcQ"
  ],
  "includeTimestamps": true
}
```

#### Output Example

```json
{
  "videoId": "jNQXAC9IVRw",
  "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "title": "Me at the zoo",
  "channelName": "jawed",
  "channelUrl": "https://www.youtube.com/@jawed",
  "thumbnailUrl": "https://i.ytimg.com/vi/jNQXAC9IVRw/hqdefault.jpg",
  "fullText": "All right, so here we are, in front of the elephants. The cool thing about these guys is that they have really really long trunks...",
  "segmentsCount": 6,
  "characterCount": 146,
  "estimatedTokens": 36,
  "segments": [
    { "start": 1.2, "duration": 2.16, "text": "All right, so here we are, in front of the elephants" },
    { "start": 5.32, "duration": 2.66, "text": "the cool thing about these guys is that they have really..." }
  ],
  "elapsedMs": 320,
  "status": "success"
}
```

***

### Extracted Fields

| Field | Type | Description |
|---|---|---|
| `videoId` | string | 11-character YouTube video ID |
| `title` | string | Official video title |
| `channelName` | string | Creator channel name |
| `channelUrl` | string | URL of the YouTube channel |
| `thumbnailUrl` | string | High quality video thumbnail link |
| `fullText` | string | Clean consolidated transcript text |
| `estimatedTokens` | integer | Estimated LLM token count (~chars/4) |
| `segments` | array | Timestamped caption blocks with start time and duration |
| `status` | string | `success` or `error` |

***

### API Integration

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("drain54/youtube-transcript-scraper").call(
    run_input={"videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"]}
)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["title"])
    print(item["fullText"])
```

# Actor input Schema

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

List of YouTube video URLs, shorts, or 11-character video IDs to transcribe.

## `preferredLanguages` (type: `array`):

Priority list of language codes to extract (e.g. en, id, es, ja). Will extract human subtitles first, then fall back to auto-generated.

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

Whether to return the list of timestamped segments in addition to the full text.

## `cookiesText` (type: `string`):

Optional YouTube cookies in Netscape format (from browser extensions like 'Get cookies.txt') to bypass any bot detection or access members-only/age-restricted videos.

## `customProxyUrl` (type: `string`):

Optional custom proxy URL (e.g., http://user:pass@host:port). If empty, Apify Proxy is used.

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

Apify Proxy settings to prevent YouTube blocks.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "preferredLanguages": [
    "en",
    "id",
    "es"
  ],
  "includeTimestamps": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ]
};

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

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

```

## MCP server setup

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

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/3WgM9WDER6JqekJsU/builds/JZjDA0iDhandGTfzM/openapi.json
