# YouTube Transcript Scraper (`thenetaji/youtube-transcript-scraper`) Actor

Get the full transcript of any YouTube video or Short, as timed segments and as plain text ready for summarising or search. Optionally download the captions as a .vtt or .srt subtitle file.

- **URL**: https://apify.com/thenetaji/youtube-transcript-scraper.md
- **Developed by:** [The Netaji](https://apify.com/thenetaji) (community)
- **Categories:** Social media, Videos, For creators
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.80 / 1,000 transcripts

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?

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 Scraper

The Actor returns the transcript of any public YouTube video or Short — as timed segments, and as one clean block of plain text ready to summarise, search, or feed to a model. It can also attach the captions as a `.vtt` or `.srt` subtitle file. Videos are accepted as URLs or bare IDs, and no YouTube account, API key, or cookie is required.

### Accepted input

| Field | Type | Default | Description |
|---|---|---|---|
| `video_sources` | array | — | Required. Video or Shorts URLs, or bare 11-character IDs. |
| `transcript_language` | string | — | Language code to request, such as `en`, `de`, `ja`. Leave empty for the video's own default. |
| `includeSubtitleFile` | boolean | `false` | Also attach the captions as a subtitle file. |
| `caption_format` | enum | `vtt` | `vtt` for WebVTT, `srt` for SubRip. Applies to the subtitle file only. |
| `maxItems` | integer | `100` | Maximum videos processed. `0` processes every supplied target. |

```json
{
  "video_sources": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" },
    { "url": "https://www.youtube.com/shorts/P4-3XTiiogo" },
    { "url": "9bZkp7q19f0" }
  ],
  "maxItems": 100
}
```

### Response fields

One row per video.

| Field | Contents |
|---|---|
| `recordType` | Always `video_transcript` |
| `source` | The URL or ID as supplied |
| `videoId` | Video ID |
| `url` | Canonical video URL |
| `text` | **The whole transcript as plain text**, segments joined in order |
| `transcript` | Timed segments, each with `startMs`, `endMs`, `startTime`, `text` |
| `segmentCount` | Number of timed segments |
| `wordCount` | Approximate word count of `text` |
| `transcriptLanguage` | Language code YouTube actually served |
| `transcriptLanguageName` | Display name of that track |
| `position` | One-based position within the run |

Present only with `includeSubtitleFile`:

| Field | Contents |
|---|---|
| `subtitleText` | The captions as a complete `.vtt` or `.srt` file |
| `subtitleFormat` | `vtt` or `srt` |
| `subtitleLanguage` | Language code of the attached track |
| `availableLanguages` | Every caption track YouTube lists for the video |

```json
{
  "recordType": "video_transcript",
  "videoId": "dQw4w9WgXcQ",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "transcriptLanguage": "en",
  "transcriptLanguageName": "English (auto-generated)",
  "segmentCount": 52,
  "wordCount": 291,
  "text": "[Music] We're no strangers to love. You know the rules and so do I...",
  "transcript": [
    { "startMs": "320", "endMs": "14580", "startTime": "0:00", "text": "[Music]" }
  ]
}
```

### Plain text and timed segments

Both are always returned, because they answer different questions.

`text` is the transcript as a single string with the timing removed. This is what you want for summarising, keyword search, sentiment work, or anything fed to a language model — no post-processing, no joining segments yourself.

`transcript` keeps YouTube's segment boundaries and timings, which is what you need to jump to a moment in the video, build a clickable transcript, or align quotes with timestamps.

Segments are joined with a space rather than a newline. YouTube breaks auto-generated captions at roughly even intervals rather than at sentence ends, so newlines would imply sentence boundaries that are not really there.

### Choosing a language

Leave `transcript_language` empty and you get the video's own default track, which is the right choice most of the time.

If you do set it, read `transcriptLanguage` on the row. **YouTube does not refuse a language it does not have** — it answers successfully with whatever track it holds. Asking a video that carries only English, German, and Japanese for Spanish returns German, with no error. The Actor cannot prevent that, so it does two things instead: every row records the language actually served, and the run log warns when it differs from what you asked for.

```
"dQw4w9WgXcQ": no es transcript exists, so YouTube returned de-DE instead.
The row records the language actually served.
```

Filter on `transcriptLanguage` if a run must contain one language only. With `includeSubtitleFile` enabled, `availableLanguages` lists every track the video actually has, which is the reliable way to find out what is on offer.

### Subtitle files

`includeSubtitleFile` attaches the captions as a complete subtitle file in `subtitleText` — WebVTT by default, SubRip with `caption_format: "srt"`. Both are ready to save and load into a video player or editor as-is.

It costs two extra requests per video: one to list the tracks, one to fetch the chosen one. It is charged once, only when both succeed. The track chosen is the one matching the transcript's own language where possible, so the two halves of a row agree; otherwise the video's first listed track is used.

Translated subtitles are not offered. YouTube advertises over 120 translation targets for a typical video, but every request for a translated track fails at the source, so the option is left out rather than shipped as a switch that never works.

### Behaviour on partial results

Each video is fetched individually. A target that cannot be parsed, that has no transcript, or that returns an empty one is logged and skipped, and the run continues with the rest. The run fails only when no supplied target was a usable video reference.

Not every video has a transcript. Captions must exist — either uploaded by the creator or auto-generated by YouTube — and creators can disable them. Music videos, very short clips, and videos in languages YouTube does not auto-caption often have none. A skipped video costs nothing.

### Frequently asked questions

**Which URL forms are accepted?**
`youtube.com/watch?v=`, `youtu.be/`, `youtube.com/shorts/`, `/embed/`, and `/live/`, plus bare 11-character video IDs. Mixing forms in one run is fine.

**Does this work on Shorts?**
Yes. Shorts use the same caption system as regular videos and need no special handling — pass the `/shorts/` URL or the bare ID.

**Why did a video return no transcript?**
It has no caption track. Auto-generated captions cover many but not all languages, and creators can turn captions off entirely. The run log names each skipped video, and skipped videos are not charged.

**Are auto-generated captions distinguishable from human ones?**
Yes, from `transcriptLanguageName`: YouTube labels automatic tracks explicitly, as in `English (auto-generated)`. Human-written tracks carry the plain language name.

**Is the transcript punctuated?**
For auto-generated tracks, partially — YouTube adds sentence punctuation but no speaker labels, and its accuracy varies with audio quality and accent. Human-uploaded tracks are as the creator wrote them.

**Can I get a transcript in a language the video was not captioned in?**
No. Only tracks YouTube actually holds for that video can be returned, and translation of caption tracks fails at the source. Translate the returned `text` yourself if you need another language.

**Is a YouTube account or API key required?**
No. Only publicly visible captions are read, with no credentials or logged-in session, and no YouTube Data API quota is consumed.

### Related Actors

| Actor | Purpose |
|---|---|
| [YouTube Video Scraper](https://apify.com/thenetaji/youtube-video-scraper) | Full video metadata, with transcripts as an optional extra |
| [YouTube Channel Scraper](https://apify.com/thenetaji/youtube-channel-scraper) | Find every video a channel has published |
| [YouTube Search Scraper](https://apify.com/thenetaji/youtube-search-scraper) | Find videos by keyword, hashtag, or chart |
| [YouTube Playlist Scraper](https://apify.com/thenetaji/youtube-playlist-scraper) | Every video in a playlist, with optional transcripts |

# Actor input Schema

## `video_sources` (type: `array`):

One or more public YouTube video or Shorts URLs. Bare video IDs are also accepted.

## `transcript_language` (type: `string`):

Language code of the transcript to request, such as en, de, or ja. YouTube serves whichever track it has; the language actually returned is reported on every row. Leave empty for the video's default.

## `includeSubtitleFile` (type: `boolean`):

Attach the caption track as a ready-to-use WebVTT or SRT file, alongside the transcript. Two extra requests per video, charged only when the track is returned.

## `caption_format` (type: `string`):

File format for the attached subtitle track.

## `maxItems` (type: `integer`):

Maximum number of primary records to save across all targets. Set 0 to continue until no more pages remain.

## Actor input object example

```json
{
  "video_sources": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "transcript_language": "en",
  "includeSubtitleFile": false,
  "caption_format": "vtt",
  "maxItems": 20
}
```

# Actor output Schema

## `dataset` (type: `string`):

All records scraped by this run

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

// Run the Actor and wait for it to finish
const run = await client.actor("thenetaji/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 = {
    "video_sources": [{ "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }],
    "maxItems": 20,
}

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

```

## MCP server setup

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