# YouTube Transcript Scraper — Captions + AI ASR Fallback (`lexiie/youtube-transcript-api`) Actor

Extract transcripts from any YouTube video, Shorts, or playlist as LLM-ready JSON with timestamps, language info, and title. Get plain text plus SRT/VTT subtitles. Caption-less videos are transcribed with GPU AI instead of failing. Pay only for delivered transcripts.

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

## Pricing

from $1.50 / 1,000 successful 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 API — Captions + AI ASR Fallback

Give the Actor a YouTube video or playlist and get machine-readable transcripts back: plain text, timestamped segments, and SRT/VTT subtitles. When a video has no captions, the Actor falls back to GPU AI transcription instead of failing — so you never get an empty result.

#### What can it do?

| 📦 What you get | ⚙️ Features |
|---|---|
| 📝 **Plain-text transcript** of any public video | 🎬 **Video + playlist** inputs (playlist expands to per-video items) |
| ⏱️ **Timestamped segments** (`text/start/duration`) | 🌍 **Language selection + fallback chain** (`en` → `id` → `ja` → any) |
| 📄 **SRT + WebVTT** subtitle contents | 🌐 **Auto-translate** via YouTube (free, optional `targetLanguage`) |
| 🤖 **AI transcripts** for caption-less videos | 🛡️ **Partial failure** — one bad video never kills the run |
| 📊 **Structured JSON** ready for LLMs & RAG | 🔁 **Retry + proxy rotation** with machine-readable error codes |

Typical uses: RAG pipelines, research, content analysis, dataset generation,
search indexing, and repurposing video into articles or shorts scripts.

#### What data do I get per video?

One dataset item per video. Successful items carry the transcript in 4
formats at once; failed videos carry a structured error and cost nothing.

**Success sample**

```json
{
  "status": "success",
  "videoId": "dQw4w9WgXcQ",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "language": "en",
  "requestedLanguage": "en",
  "transcriptType": "MANUAL",
  "text": "We're no strangers to love...",
  "segments": [{ "text": "We're no strangers to love", "start": 18.64, "duration": 3.24 }],
  "srt": "1\n00:00:18,640 --> 00:00:21,880\nWe're no strangers to love\n",
  "vtt": "WEBVTT\n\n00:00:18.640 --> 00:00:21.880\nWe're no strangers to love\n"
}
```

`transcriptType` tells you which engine produced it: `MANUAL` / `AUTO_GENERATED`
(YouTube captions) or `ASR_GENERATED` (GPU fallback). `error.path` on failures
tells you the same: `"caption"` or `"asr"`.

**Failed sample (always free)**

```json
{
  "status": "failed",
  "videoId": "abc123",
  "url": "https://www.youtube.com/watch?v=abc123",
  "error": { "code": "TRANSCRIPT_NOT_AVAILABLE", "message": "...", "path": "asr" }
}
```

#### How much does it cost?

Pay-per-event — you pay per **successful** transcript, never for failures,
and never per minute of video. A 5-minute video and a 2-hour video cost the
same flat AI price, unlike per-minute STT APIs that bill $0.12–$4.00 per
audio hour.

| Event | FREE | BRONZE (Starter) | SILVER (Scale) | GOLD (Business) |
|---|---|---|---|---|
| `successful-transcript` (captions) | $0.003 ($3/1K) | $0.0025 ($2.5/1K) | $0.002 ($2/1K) | $0.0015 ($1.5/1K) |
| `successful-transcript-asr` (AI fallback) | $0.10 | $0.09 | $0.08 | $0.07 |

Example: on the Free plan's $5 monthly credits you can extract ≈1,600 caption
transcripts; an ASR fallback costs a flat $0.10 whatever the video length
(up to 2h). See the Pricing tab for your plan's exact rates.

#### How do I use it?

1. Create a free Apify account.
2. Open **YouTube Transcript API** in Apify Console.
3. Paste one or more YouTube URLs (video, Shorts, or playlist).
4. Pick `language` (e.g. `en`) and optional `fallbackLanguages` (e.g. `id`).
5. Click **Save & Start**.
6. Download the dataset as JSON/CSV/Excel, or pull it via API/MCP.

#### Input

| Paste this URL | What happens |
|---|---|
| `youtube.com/watch?v=ID` | Single video transcript |
| `youtu.be/ID`, `.../shorts/ID`, `.../embed/ID` | Single video transcript |
| `youtube.com/playlist?list=ID` | One item per video, with `playlistId` + `videoIndex` |
| `watch?v=ID&list=PLAYLIST` | Single video — unless `expandWatchPlaylist: true`, then the whole playlist |

```json
{
  "urls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "language": "en",
  "fallbackLanguages": ["id"],
  "targetLanguage": "",
  "includeTimestamps": true,
  "expandWatchPlaylist": false,
  "enableAsrFallback": false
}
```

- `targetLanguage` (e.g. `"id"`): auto-translate via YouTube, free. If
  translation fails the original is kept (`translationStatus: failed`).
- `enableAsrFallback: true`: transcribe via GPU AI when captions are missing
  (slower, billed as `successful-transcript-asr`). Off by default.
- Limits: max 100 videos/run, max 2h per video for ASR, max 10 ASR jobs/run.

#### Output views

The Output tab has 3 views: **Overview** (one row per video), **Segments**
(timestamped captions), and **Subtitles** (SRT/VTT contents).

#### Use-case recipes

- **RAG over videos**: playlist URL → per-video `text` + `segments` → chunk by
  segment timestamps → embed. Re-run weekly for channels; new videos append.
- **Content repurposing**: single video → `text` → LLM article/thread script;
  `srt` doubles as upload-ready subtitles for reposted clips.
- **Research corpus**: 100 URLs/run → `language` + `transcriptType` columns let
  you filter manual vs auto captions before analysis.

#### FAQ

**What if a video has no captions?**
With `enableAsrFallback: false` (default) you get a structured
`TRANSCRIPT_NOT_AVAILABLE` failure, free. With `true`, GPU AI transcribes it
(`ASR_GENERATED`), flat price regardless of duration.

**Am I charged for failed videos?**
Never — private, removed, caption-less (without fallback), or over-limit
videos cost $0.

**How long does a run take?**
Caption transcripts take seconds per video (3 concurrent workers). Each ASR
fallback takes minutes (GPU job); caption results stream into the dataset
first, ASR results follow.

**Does it download video or audio?**
The caption path downloads nothing but caption text. The ASR fallback
processes audio on ephemeral GPU workers; no media is stored.

# Actor input Schema

## `urls` (type: `array`):

YouTube video or playlist URLs.

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

Preferred transcript language (ISO 639-1).

## `fallbackLanguages` (type: `array`):

Fallback languages in priority order.

## `targetLanguage` (type: `string`):

Optional: auto-translate the transcript via YouTube (free). Empty = no translation.

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

Include per-segment start/duration timestamps.

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

Include video metadata (title, duration) when available.

## `preserveFormatting` (type: `boolean`):

Keep original caption formatting instead of normalizing whitespace.

## `expandWatchPlaylist` (type: `boolean`):

If a watch URL carries a playlist (?v=..\&list=..), process the whole playlist instead of just the single video.

## `enableAsrFallback` (type: `boolean`):

When captions are unavailable, transcribe via GPU AI (slower, billed as successful-transcript-asr event). Off by default.

## `proxyEnabled` (type: `boolean`):

Route traffic through the residential proxy configured via Actor secrets (PROXY\_URL).

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "language": "en",
  "fallbackLanguages": [],
  "targetLanguage": "",
  "includeTimestamps": true,
  "includeMetadata": true,
  "preserveFormatting": false,
  "expandWatchPlaylist": false,
  "enableAsrFallback": false,
  "proxyEnabled": true
}
```

# Actor output Schema

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

One dataset item per video: transcript text, segments, SRT/VTT, metadata.

# 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 = {
    "urls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "language": "en",
    "targetLanguage": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("lexiie/youtube-transcript-api").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 = {
    "urls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
    "language": "en",
    "targetLanguage": "",
}

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

```

## MCP server setup

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

```

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/Rna8xWxAeI9FQH5V7/builds/Jtbz1XkIaFvkilu50/openapi.json
