# YouTube Transcript & Captions (any language, SRT/VTT) (`mathtec/youtube-transcript`) Actor

Get the transcript or captions of YouTube videos: plain text, timestamped segments, SRT or VTT, in your preferred language, human-made captions first. Failed videos are free.

- **URL**: https://apify.com/mathtec/youtube-transcript.md
- **Developed by:** [Adam Rudd](https://apify.com/mathtec) (community)
- **Categories:** Videos, AI, Social media
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.30 / 1,000 transcript returneds

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 (any language, SRT/VTT)

Get the transcript or captions of YouTube videos as **plain text, timestamped segments, SRT or WebVTT**, in the language
you prefer. Human-made captions are returned before auto-generated ones when both exist, and every row says which you got.

- **Input:** YouTube video links (watch, youtu.be, Shorts, embed, live) or 11-character video ids, **channel links**
  (`@handle`, `/channel/UC...`, `/c/...`, `/user/...`) and **playlist links** (`list=...`). A channel or playlist gives its
  newest videos (up to `maxVideosPerChannel`); add `/videos`, `/shorts` or `/streams` to a channel link to take only that tab.
  Listing a channel or playlist is free.
- **Output:** one dataset row per video: `text`, `language`, `isGenerated` (auto-generated captions or not),
  `languageFallback` (your preferred language wasn't available, so the first available track was used),
  `availableLanguages`, `durationSeconds`, and `segments` / `srt` / `vtt` depending on the output format.
- **Failed videos are free:** a video with captions disabled, no captions, or unavailable gives a row with `status:
  failed` and the reason, and is not charged.

### Input

| Field | Default | Notes |
|---|---|---|
| `videos` | *(required)* | video links or ids |
| `languages` | `["en"]` | caption languages in order of preference (ISO codes) |
| `preferManual` | `true` | prefer human-made captions over auto-generated ones |
| `outputFormat` | `segments` | `text`, `segments`, `srt` or `vtt` (plain text is always included) |
| `maxVideosPerChannel` | `20` | newest videos per channel or playlist link |

### Output example

```json
{
  "videoId": "gYskRI0ynAM",
  "url": "https://www.youtube.com/watch?v=gYskRI0ynAM",
  "status": "ok",
  "language": "en",
  "isGenerated": true,
  "languageFallback": false,
  "availableLanguages": ["en"],
  "durationSeconds": 771.6,
  "segmentCount": 412,
  "text": "my name is Craig Wright I've been involved with cryptography ...",
  "segments": [{"start": 0.0, "duration": 3.2, "text": "my name is Craig Wright"}]
}
```

### Pricing

One price per video that returns captions (see the Pricing tab). Listing channels and playlists is free. Videos that
fail are not charged.

### What it does not do (yet)

Videos with **no captions at all** come back as `failed` (free). Live streams in progress are not transcribed. For audio and video files outside YouTube, our
[Audio & Video Transcriber](https://apify.com/mathtec/whisper-media-transcriber) transcribes the speech with Whisper.

### Responsible use

You are responsible for how you use the transcripts, including copyright and YouTube's terms.

# Actor input Schema

## `videos` (type: `array`):

YouTube video links (watch, youtu.be, shorts, embed, live) or 11-character video ids; channel links (@handle, /channel/UC..., /c/..., /user/...; add /videos, /shorts or /streams to take only that tab); playlist links (list=...). A channel or playlist gives its newest videos, up to 'Max videos per channel or playlist'. One dataset row per video.

## `maxVideosPerChannel` (type: `integer`):

For each channel or playlist link, the newest videos to transcribe (playlists: the first ones in playlist order). Listing is free; only returned transcripts are charged.

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

Caption languages in order of preference (ISO codes such as en, es, de). If none is available, the first available track is returned and flagged with languageFallback.

## `preferManual` (type: `boolean`):

When a video has both human-made and auto-generated captions in a preferred language, return the human-made ones.

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

Plain text is always included.

## `transcribeIfNoCaptions` (type: `boolean`):

When a video has no captions at all, download its audio and transcribe it with Whisper (small model). Charged per started audio minute, a separate event; failures are free. Needs at least 2048 MB memory; 4096 MB runs about twice as fast.

## `maxWhisperMinutesPerVideo` (type: `integer`):

Videos without captions that are longer than this are not transcribed (free failed row).

## Actor input object example

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=gYskRI0ynAM"
  ],
  "maxVideosPerChannel": 20,
  "languages": [
    "en"
  ],
  "preferManual": true,
  "outputFormat": "segments",
  "transcribeIfNoCaptions": false,
  "maxWhisperMinutesPerVideo": 60
}
```

# Actor output Schema

## `transcripts` (type: `string`):

Dataset items: input, videoId, url, status (ok | failed | rejected), source (captions | whisper), sourceType and sourcePlaylistId (for videos listed from a channel or playlist), language, languageName, isGenerated, languageFallback, availableLanguages, durationSeconds, segmentCount, text, and segments / srt / vtt per outputFormat; whisperModel, modelRevision, languageProbability, audioMinutesCharged, processingSeconds for Whisper rows; error when not ok.

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

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

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

```

## MCP server setup

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

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/DnzSvoSyeEnhwH8An/builds/MnCPkbzjiupIA271d/openapi.json
