# YouTube Transcript and Subtitle Data Scraper (`khadinakbar/youtube-transcript-extractor`) Actor

Extract YouTube transcripts from video URLs, channels, or search queries. Receive timestamped segments, plain text, SRT subtitles, language details, video metadata, token estimates, and LLM-ready context.

- **URL**: https://apify.com/khadinakbar/youtube-transcript-extractor.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Videos, AI, MCP servers
- **Stats:** 42 total users, 5 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 transcript extracteds

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/actors/running/actors-in-store.md#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 and Subtitle Data Scraper

Extract YouTube transcripts from individual videos, URL lists, channels, or search queries. Each record can include timestamped segments, plain transcript text, SRT subtitles, video metadata, language details, word and token estimates, and an LLM-ready context field.

Use the Actor for research, content analysis, searchable knowledge bases, subtitle workflows, RAG pipelines, topic discovery, and AI agents that need structured spoken-video content.

### Best fit

- Research teams collecting spoken evidence from public YouTube videos.
- Content teams turning video material into searchable source documents.
- AI and RAG pipelines that need clean transcript text plus metadata.
- Analysts comparing themes across channels or search topics.
- Subtitle workflows that need timestamped segments or SRT output.

### A practical content-research scenario

A research agent starts with a YouTube search query and discovers videos around a market topic. The Actor extracts each transcript together with the title, channel, publication context, language, and token estimate. The agent can place `llmContext` directly into a summarization step, keep `transcriptSegments` for timestamp citations, and retain `videoId` as the stable reference for later comment or channel research.

This provides both readable text and machine-friendly evidence in one dataset.

### Input modes

The Actor selects a workflow from the supplied input:

| Input | Workflow |
| --- | --- |
| `videoUrls` | Extracts transcripts from individual or bulk YouTube URLs. |
| `channelUrl` | Discovers videos from a channel or handle, then extracts transcripts. |
| `searchQuery` | Discovers videos for a topic, then extracts transcripts. |

### Quick start

#### Extract a video transcript

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "language": "en",
  "outputFormat": "all",
  "includeMetadata": true
}
```

#### Research a channel

```json
{
  "channelUrl": "https://www.youtube.com/@mkbhd",
  "maxResults": 20,
  "language": "en",
  "outputFormat": "plain_text"
}
```

#### Discover transcripts by topic

```json
{
  "searchQuery": "how to use AI for customer research",
  "maxResults": 10,
  "language": "en",
  "outputFormat": "all"
}
```

### Input reference

| Field | Purpose |
| --- | --- |
| `videoUrls` | YouTube watch, short, embed, or shortened URLs. |
| `channelUrl` | Channel URL, channel ID URL, custom channel URL, or handle. |
| `searchQuery` | Topic used to discover YouTube videos. |
| `maxResults` | Upper bound for videos processed in channel and search workflows. |
| `language` | Preferred transcript language code. |
| `dateFrom`, `dateTo` | Narrows channel discovery by publication date. |
| `includeMetadata` | Adds video and channel metadata. |
| `outputFormat` | Selects all fields, segments, plain text, or SRT. |
| `customProxyUrl` | Optional private proxy URL supplied through the input surface. |
| `proxyConfiguration` | Controls Apify residential routing. |

### Output data

Each video record can include:

- `videoId`, `videoUrl`, `title`, `channelName`, `channelId`, and `channelUrl`
- `publishedAt`, `durationSeconds`, view, like, and comment counts
- `thumbnail`, `description`, and tags
- `transcriptSegments`, `transcriptText`, and `transcriptSrt`
- `llmContext`, `tokenEstimate`, and `wordCount`
- `languageUsed`, `availableLanguages`, and `isAutoGenerated`
- `inputMode`, `status`, `scrapedAt`, and `sourceUrl`

```json
{
  "videoId": "dQw4w9WgXcQ",
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Example video",
  "channelName": "Example channel",
  "transcriptText": "Transcript text appears here.",
  "transcriptSegments": [
    {
      "text": "Transcript text appears here.",
      "start": 0,
      "duration": 3.5
    }
  ],
  "languageUsed": "en",
  "status": "success"
}
```

### AI agent workflows

The Actor works as a focused transcript tool through Apify MCP and the Apify API. `llmContext` packages title, channel, publication context, video metrics, and transcript text into a convenient downstream string, while the raw transcript fields remain available for precise processing.

Example agent request:

> Find YouTube videos about customer research, extract English transcripts, return titles, channels, token estimates, and timestamped segments, then summarize recurring methods with source video IDs.

Useful routing guidance:

- Use `videoUrls` when the agent already has specific sources.
- Use `channelUrl` for creator or publisher research.
- Use `searchQuery` for topic discovery.
- Choose `plain_text` for compact semantic processing.
- Choose `segments` or `all` when timestamp citations matter.
- Preserve `videoId`, `languageUsed`, and `status` in downstream evidence.

### Run through the API

```bash
curl -X POST "https://api.apify.com/v2/acts/khadinakbar~youtube-transcript-extractor/runs" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "searchQuery": "how to use AI for customer research",
    "maxResults": 10,
    "language": "en",
    "outputFormat": "all"
  }'
```

The Apify token stays in the `Authorization` header. Results are available from the run's default dataset in JSON, CSV, Excel, and other supported formats.

### Transcript sourcing and fallback

The primary route uses the Actor's native YouTube transcript stack. It combines Android-client caption retrieval, embedded page data, InnerTube methods, signed caption URLs, timed-text formats, language selection, rotating residential sessions, custom proxy support, and direct routing.

When the native strategies complete without transcript segments, the implemented final recovery route calls ScrapeCreators for the same public YouTube video and language. ScrapeCreators results are normalized into the same segment, text, language, SRT, and dataset contract before delivery. This is a real source-level fallback and remains secondary to the native path.

### Pricing

This Actor uses Pay per event pricing with platform usage passed through. A transcript event is charged when the corresponding dataset record is written through the Actor's coupled data-and-billing path. Treat the live Pricing tab as the current source of truth for event prices and billing details.

Use `maxResults` and `outputFormat` to align each run with the workflow's scope and context budget.

### Best results

- Supply direct video URLs for the most focused transcript workflow.
- Use channel or search discovery with a practical result cap before expanding a research batch.
- Set the preferred language and inspect `languageUsed` in every returned record.
- Choose timestamped segments for evidence citation and plain text for compact analysis.
- Keep metadata enabled when channel, publication, and engagement context matter.

### Related Actors

- Start with [YouTube Search Scraper](https://apify.com/khadinakbar/youtube-search-scraper) when discovery needs richer video, channel, and playlist filters, then pass selected video URLs here.
- Pair transcripts with [YouTube Comments Scraper](https://apify.com/khadinakbar/youtube-comments-scraper) when the workflow combines spoken content with audience reactions.

### Builder's note

I designed this Actor to return both human-readable transcript text and source-aware fields for machines. The native multi-strategy path handles caption variation, the ScrapeCreators recovery route adds an independent provider path, and the output formats let an agent choose compact text or timestamp-level evidence without changing tools.

### Responsible use

This Actor collects publicly available YouTube transcript and video information. Use the results for legitimate research and content workflows in line with applicable laws, source terms, copyright requirements, and your organization's data-governance policies.

# Actor input Schema

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

One or more YouTube video URLs. Supports youtube.com/watch, youtu.be, Shorts, and embed links.

## `channelUrl` (type: `string`):

A YouTube channel URL or @handle (e.g. @mkbhd). Extracts transcripts from the channel's videos.

## `searchQuery` (type: `string`):

Search YouTube by keyword and extract transcripts from the top results.

## `maxResults` (type: `integer`):

Maximum number of videos to process. Default 10.

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

Preferred transcript language (ISO 639-1 code, e.g. 'en', 'es', 'fr'). Falls back to English if unavailable.

## `dateFrom` (type: `string`):

Only include videos published on or after this date (YYYY-MM-DD). Channel and search modes only.

## `dateTo` (type: `string`):

Only include videos published on or before this date (YYYY-MM-DD). Channel and search modes only.

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

Fetch title, views, likes, channel info, tags, and thumbnail. Disable for faster runs if you only need transcript text.

## `outputFormat` (type: `string`):

Which transcript formats to return: 'all' (segments + plain text + SRT + LLM context), 'segments' (timestamped only), 'plain\_text' (text + LLM context), or 'srt' (subtitle format).

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

Optional rotating residential proxy (e.g. http://user:pass@host:port). Overrides Apify proxy if set.

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

Apify proxy settings. Residential proxy is required — datacenter IPs are blocked by YouTube.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channelUrl": "https://www.youtube.com/@mkbhd",
  "searchQuery": "how to use ChatGPT for business",
  "maxResults": 10,
  "language": "en",
  "includeMetadata": true,
  "outputFormat": "all",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset of YouTube video transcripts with metadata, timestamps, plain text, SRT, and LLM-ready context. Each item has semantic field names for easy AI agent consumption.

# 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"
    ],
    "channelUrl": "https://www.youtube.com/@mkbhd",
    "searchQuery": "how to use ChatGPT for business",
    "language": "en"
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/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"],
    "channelUrl": "https://www.youtube.com/@mkbhd",
    "searchQuery": "how to use ChatGPT for business",
    "language": "en",
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/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"
  ],
  "channelUrl": "https://www.youtube.com/@mkbhd",
  "searchQuery": "how to use ChatGPT for business",
  "language": "en"
}' |
apify call khadinakbar/youtube-transcript-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khadinakbar/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/HY1l2lAN9rwPg8LsZ/builds/1GYfnAX9Z92lzQVgN/openapi.json
