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

Retrieve available YouTube captions as text, timestamped segments, SRT, or VTT with optional video metadata.

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

## Pricing

Pay per event

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

Retrieve captions from public YouTube videos without customer authentication or
browser automation. Results are saved to the default dataset; videos without
available captions are reported as item errors and do not create transcript
charges.

The Actor supports watch, shorts, live, embed, and `youtu.be` URLs. It can
return plain text, timestamped segments, SRT, or VTT and can optionally include
the title, channel, and publication date returned by YouTube.

### Input

Provide `urls` (one or more YouTube video URLs). Optional settings are
`languages` (priority-ordered language codes, default `en`), `output_format`
(`text`, `segments`, `srt`, or `vtt`), `include_metadata`, `concurrency` from 1
to 20, `max_run_seconds` from 1 to 3600, and an HTTP `proxy_url`.

Example:

```json
{
  "urls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "languages": ["en"],
  "output_format": "segments",
  "include_metadata": true
}
```

### Output and pricing

Each successful dataset item contains the video ID, selected language, output
format, transcript, and one transcript billing event. The Actor also records a
memory-scaled `apify-actor-start` event for each run. Invalid, unavailable,
captionless, blocked, and failed videos are returned as error items and carry
no transcript event. Duplicate video IDs are processed once per run.

YouTube's public caption and player endpoints are undocumented and may change.
Some videos may require a proxy, may be blocked for datacenter traffic, or may
not expose captions. Age-restricted and private videos are not authenticated.

### Functional input contract

Call `scrape_transcripts(ScrapeInput(...))` with:

- `urls`: one or more YouTube watch, short, live, embed, or `youtu.be` URLs;
- `languages`: language codes in priority order (default `en`);
- `output_format`: `text`, `segments`, `srt`, or `vtt`;
- `include_metadata`: include title, channel, and publication date when available;
- `concurrency`: 1–20 (default 5);
- `max_run_seconds`: 1–3600 (default 900);
- `proxy_url`: optional HTTP proxy URL supplied by the platform adapter.

Duplicate video IDs are processed once so a successful video cannot produce
duplicate output or duplicate transcript charges within a batch.

### Functional output and billing contract

The returned object has `results` and `errors` arrays. Every successful result
contains the video identity, selected language, requested transcript format,
and exactly one `{event: "transcript", quantity: 1}` billing signal. Invalid,
unavailable, captionless, blocked, and failed videos appear only in `errors` and
never carry that signal. One video's failure does not stop the batch.

`start_billable_events(memory_mb)` emits the separate `apify-actor-start` signal:
one event per configured GiB, rounded up, with a minimum of one. Deploy owns the
mapping of these neutral signals to Apify charging and dataset operations.

### Development verification

```sh
PYTHONPATH=src python3 -m unittest discover -s tests -v
```

# Actor input Schema

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

One or more public YouTube watch, shorts, live, embed, or youtu.be URLs.

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

Language codes tried in order, such as en or es.

## `output_format` (type: `string`):

Transcript representation written to each successful dataset item.

## `include_metadata` (type: `boolean`):

Include each video's title, channel, and publication date when available.

## `concurrency` (type: `integer`):

Maximum number of videos processed at the same time.

## `max_run_seconds` (type: `integer`):

Stop processing after this many seconds.

## `proxy_url` (type: `string`):

Optional HTTP proxy URL supplied by Apify.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "languages": [
    "en"
  ],
  "output_format": "text",
  "include_metadata": true,
  "concurrency": 5,
  "max_run_seconds": 900
}
```

# Actor output Schema

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

No description

# 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"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("daftvader/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=dQw4w9WgXcQ"] }

# Run the Actor and wait for it to finish
run = client.actor("daftvader/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=dQw4w9WgXcQ"
  ]
}' |
apify call daftvader/youtube-transcript-scraper --silent --output-dataset

```

## MCP server setup

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