# YouTube Transcript Scraper: Captions with Timestamps (`megomi/youtube-transcript-scraper`) Actor

Get the transcript of any public YouTube video or Short as timed lines and plain text, in the language you choose. Built for AI, summaries and search.

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

## Pricing

from $5.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: captions with timestamps

Give YouTube video links and get each video's **transcript** as timed lines (`text`, `startMs`, `endMs`, `startTimeText`) **and** as one block of plain text. Pick the caption language, or take the video's own spoken language. Works for regular videos, Shorts and live replays. Made for summaries, search indexes, RAG and other AI pipelines.

### What you get

```json
{
  "target": "https://www.youtube.com/watch?v=a1B2c3D4e5F",
  "status": "ok",
  "cached": false,
  "data": {
    "success": true,
    "videoId": "a1B2c3D4e5F",
    "type": "video",
    "url": "https://www.youtube.com/watch?v=a1B2c3D4e5F",
    "language": "English",
    "transcript_only_text": "welcome back to the farm and the backyard trails we built ...",
    "transcript": [
      { "text": "welcome back to the farm and the", "startMs": "160", "endMs": "1920", "startTimeText": "0:00" },
      { "text": "backyard trails we built", "startMs": "1920", "endMs": "3919", "startTimeText": "0:01" }
    ]
  }
}
```

Illustrative values. One dataset row per video, exportable as JSON, CSV or Excel, or readable through the Apify API. `startMs` and `endMs` are strings.

### Pricing

You pay **per transcript returned**. A video with **no captions** (or none in the language you asked for), a video that does not exist, an age-restricted or private video, and an answer while the service is busy are all **free**. Set a maximum cost per run and the Actor stops when it is reached.

### Input

| Field | Meaning |
|---|---|
| `targets` | Video links: `watch?v=`, `youtu.be/`, `/shorts/`, `/live/`, `/embed/`. Up to 1000 per run. The same video written two ways is looked up, and charged, once. |
| `language` | Optional. A code such as `en`, `es`, `pt-BR`. `en` takes any English track; `en-US` takes exactly `en-US` or plain `en`. |
| `originalAudio` | Optional. Only the captions in the video's spoken language. Overrides `language`. |
| `concurrency` | Parallel lookups, 1 to 5. Default 2. |
| `maxRetries` | Extra tries when the service is busy. Default 2. |

### Good to know

- **Nothing is translated or guessed.** If the video has no captions in the language you asked for, you get `transcript: null` and are not charged.
- A caption track written by a person is preferred over an automatic one.
- Very long captions (over 8 MB or 60,000 lines) are not returned.
- Results can be up to 15 minutes old (`cached: true`).

### Statuses per row

| `status` | Meaning | Charged |
|---|---|---|
| `ok` | Result in `data`. If `data.transcript` is `null`, there were no captions to give | only when a transcript is present |
| `not_found` | No such video | no |
| `unavailable` | The source was unavailable, asked to sign in, or was busy after retries. Try again later | no |
| `rejected` | The input was refused, for example a link that is not a video. `error` says why | no |

### Data and legal

Only publicly available captions are used, and no YouTube login is involved. You are responsible for using the results in line with YouTube's terms and the copyright and privacy law that applies to you. Not affiliated with YouTube or Google.

# Actor input Schema

## `targets` (type: `array`):

Video links: youtube.com/watch?v=..., youtu.be/..., /shorts/..., /live/... or /embed/.... The same video written two ways is looked up once.

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

A language code such as en, es, pt-BR or zh-Hans. Leave empty for the video's own spoken language. Nothing is translated: a video with no captions in this language returns no transcript, and is free.

## `originalAudio` (type: `boolean`):

Return only the captions in the language the video is spoken in. Overrides the language above.

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

How many videos are looked up at the same time.

## `maxRetries` (type: `integer`):

Extra tries when the service is busy. Busy answers are never charged, so retrying is safe.

## Actor input object example

```json
{
  "targets": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "language": "",
  "originalAudio": false,
  "concurrency": 2,
  "maxRetries": 2
}
```

# Actor output Schema

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

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

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

```

## MCP server setup

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