# YouTube Transcript Scraper: Subtitles, Captions & Text (`shelfdata/youtube-transcript-scraper`) Actor

YouTube transcripts for many videos per run: timestamped caption segments plus plain text, English or the video's own language by default, or a target language you pick. Only videos with captions are charged.

- **URL**: https://apify.com/shelfdata/youtube-transcript-scraper.md
- **Developed by:** [ShelfData](https://apify.com/shelfdata) (community)
- **Categories:** Videos, AI, Social media
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 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.

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 Scraper: Subtitles, Captions & Text

Get the **transcripts of many YouTube videos in one run**: paste video URLs (or IDs) and get one row per video with the
timestamped caption segments and the whole transcript as plain text. English by default, or pick a target language.
You pay only for videos that have a transcript.

Built for researchers, content and SEO teams, and AI/LLM pipelines that need the spoken text of videos: summaries,
search indexes, quotes, subtitles and training data. Unofficial; not affiliated with YouTube or Google.

### How to use

1. Add the **YouTube video URLs**: watch, `youtu.be`, Shorts, live or embed links, or bare 11-character video IDs.
2. Optionally pick a **Transcript language**.
3. Run it. Each video with captions becomes one row; videos without a transcript are listed in the run's `OUTPUT` record
   with the reason.

| Input | Meaning |
|---|---|
| `urls` | Video URLs or IDs; each video is read once, duplicates are dropped |
| `targetLanguage` | Empty (default): English captions when the video has them, otherwise the video's own captions, plus the video title. Set (e.g. `de`): that language's captions; when a video has none, YouTube's machine translation is tried |
| `proxySource` | `apify_residential` (default, Apify Residential exits, included in the price), `owner` (Apify datacenter, often refused by YouTube) or `custom_pool` |
| `apifyProxyCountry` | Country of the Residential exits, default `US` |
| `apifyProxySessions` | Proxy sessions to rotate over, default 5 |
| `customProxyUrls` | Your own proxy URLs for `custom_pool` (secret) |

### Output example

One row per video. `transcript` holds the caption segments in order (start and end in seconds), `text` the same words
as one plain text:

```json
{
  "videoId": "jNQXAC9IVRw",
  "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "title": "Me at the zoo",
  "transcript": [
    {"start": 1.2, "end": 3.36, "text": "All right, so here we are, in front of the elephants"},
    {"start": 5.318, "end": 7.974, "text": "the cool thing about these guys is that they have really..."},
    {"start": 7.974, "end": 12.616, "text": "really really long trunks"},
    {"start": 12.616, "end": 14.367, "text": "and that's cool"},
    {"start": 14.421, "end": 15.733, "text": "(baaaaaaaaaaahhh!!)"},
    {"start": 16.881, "end": 18.881, "text": "and that's pretty much all there is to say"}
  ],
  "text": "All right, so here we are, in front of the elephants the cool thing about these guys is that they have really... really really long trunks and that's cool (baaaaaaaaaaahhh!!) and that's pretty much all there is to say"
}
```

The same video with **Transcript language** `de` (the video has German captions):

```json
{
  "videoId": "jNQXAC9IVRw",
  "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "title": null,
  "transcript": [
    {"start": 0.0, "end": 5.067, "text": "Also hier sind wir vor den Elefanten."},
    {"start": 5.067, "end": 12.467, "text": "Das Coole an den Typen ist dass sie sehr, sehr, sehr, lange Rüssel haben."},
    {"start": 12.467, "end": 14.267, "text": "Und das ist cool."},
    {"start": 17.067, "end": 21.0, "text": "Ansonsten gibt es nicht wirklich viel zu sagen."}
  ],
  "text": "Also hier sind wir vor den Elefanten. Das Coole an den Typen ist dass sie sehr, sehr, sehr, lange Rüssel haben. Und das ist cool. Ansonsten gibt es nicht wirklich viel zu sagen."
}
```

Caption text is returned as YouTube serves it, including sound tags such as `[Music]` or `♪` and, in some music
videos, `<i>` formatting. The run's `OUTPUT` record summarises `total` and lists every video that gave no transcript
(`success` is `false` when there is at least one), for example:

```json
{
  "kind": "not_found",
  "target": "https://www.youtube.com/watch?v=jX6kn9_U8qk",
  "message": "video jX6kn9_U8qk: no public captions"
}
```

### Reliability

No browser: the actor reads YouTube's public caption tracks, so a video takes one to three seconds and runs need little
memory. YouTube asks datacenter IPs to sign in ("confirm you're not a bot"), so the actor goes out through Apify
Residential exits by default; their traffic is included in the price. On Apify, 10 videos took 26 seconds; a video
that still meets the bot check is retried on another exit, up to three times. Each video is read on its own: a video
without captions, a private or deleted video or a refused request is reported in `OUTPUT` (and not charged) while the
other videos are still read. Invalid links and playlist or channel URLs are reported the same way.

With a target language, videos that have captions in that language work like the default mode. Videos that need
YouTube's machine translation often fail: YouTube answers those translation requests with HTTP 429, and the video is
reported as `blocked`.

### Not supported

- Videos without captions: no speech recognition is run, so a video without public captions (manual or auto-generated)
  has no transcript.
- Playlist and channel URLs: add the video URLs.
- Private, members-only and age-restricted videos, and video statistics (views, likes, comments).
- The video title when a target language is set.

### How much does it cost?

Pay per result: **$0.004 per transcript ($4 per 1,000 videos)** plus $0.001 per run. A transcript is one dataset row,
one per video; videos that return no transcript are free. The Apify platform usage, including the Residential proxy
traffic, is included, so there is nothing else to pay. Examples:

- the transcripts of 100 videos: about **$0.40**
- the transcripts of 1,000 videos: about **$4.00**

Apify's free plan includes monthly credit that covers many runs of this size, so you can try it without a subscription.

### Run it from your code, a schedule or another tool

- **API**: start a run and get the transcript rows in one call:

  ```bash
  curl -X POST "https://api.apify.com/v2/acts/shelfdata~youtube-transcript-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw", "https://youtu.be/IELMSD2kdmk"]}'
  ```

  The same works from the Apify Python and JavaScript clients.
- **Schedules**: run it on a schedule from Apify Console > Schedules, for example for a list of videos you update elsewhere.
- **Integrations**: send results to Google Sheets, Slack, email, Make, Zapier, n8n or a webhook from the actor's Integrations tab.
- **AI agents**: the actor is available as a tool through the Apify MCP server, so an assistant can read a video's transcript.

### FAQ

**Which language do I get without a target language?**
English captions when the video has them, otherwise the video's own caption track: for most videos the captions of the
spoken language, often auto-generated.

**Are auto-generated captions included?**
Yes: auto-generated captions count like manual ones, so most spoken videos have a transcript.

**How do I get one plain text per video?**
Use the `text` field; `transcript` keeps the timing of every segment, for subtitles or quotes with timestamps.

**Is it legal to scrape this data?**
The actor reads only publicly available captions, the same data any visitor sees, and no data behind a login. Transcripts
can include names and statements published by the creators; if you store them, handle them under the rules that apply to
you (such as copyright and the GDPR).

**Something is missing or broken?**
Open an issue on the actor's Issues tab: requests and bug reports are answered there.

# Actor input Schema

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

Videos to get transcripts for: watch, youtu.be, Shorts, live or embed URLs, or bare 11-character video IDs. Each video becomes one row; duplicates are read once. Playlist and channel URLs are not supported.

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

Language of the transcripts. Empty: English captions when the video has them, otherwise the video's own captions, and the video title is included. Set: that language's captions; when a video has none, YouTube's machine translation of its captions is tried (YouTube often refuses translation requests from datacenter IPs; such videos are listed in OUTPUT and not charged). The title is not returned in this mode.

## `proxySource` (type: `string`):

YouTube asks datacenter IPs to sign in ("confirm you're not a bot"), so Residential is the default; its traffic is included in the per-transcript price.

## `apifyProxyCountry` (type: `string`):

Two-letter country of the Residential exits.

## `apifyProxySessions` (type: `integer`):

Sticky sessions (exits) to rotate over when one is refused.

## `customProxyUrls` (type: `string`):

For `My custom proxy list`: one http(s)://user:password@host:port per line (semicolons or a JSON array also work).

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=IELMSD2kdmk",
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "proxySource": "apify_residential",
  "apifyProxyCountry": "US",
  "apifyProxySessions": 5
}
```

# Actor output Schema

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

Dataset rows: one per video with captions (timed segments and plain text).

## `summary` (type: `string`):

OUTPUT record: success, total rows, spending-limit stop and the videos that returned no transcript, with the reason.

# 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=IELMSD2kdmk",
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ]
};

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

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

```

## MCP server setup

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