# YouTube Transcripts Scraper (`xtracto/youtube-transcripts-scraper`) Actor

Fetch the full transcript (closed captions) of any YouTube video that has captions enabled. Returns time-aligned segments + joined text.

- **URL**: https://apify.com/xtracto/youtube-transcripts-scraper.md
- **Developed by:** [Farhan Febrian Nauval](https://apify.com/xtracto) (community)
- **Categories:** Videos, AI
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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?

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 Transcripts Scraper

Get the full transcript of YouTube videos: every caption line with its timestamp, the whole text joined for reading or feeding to an AI model, and basic video details. You choose the language you prefer.

### What you get

One row per video that has captions:

| Field | Meaning |
|---|---|
| `videoId`, `url`, `title` | The video |
| `channelName`, `channelId` | Who published it |
| `lengthSeconds`, `viewCount` | Duration and views |
| `language`, `languageName` | The caption track returned, for example `es` / `Spanish` |
| `isAutoGenerated` | `true` when the captions are YouTube's automatic ones, `false` when the creator provided them |
| `availableTracks` | Every caption language the video offers |
| `segmentCount` | Number of caption lines |
| `segments` | Caption lines: `startSeconds`, `durationSeconds`, `text` |
| `text` | All caption lines joined into one string |

#### Example row (shortened)

```json
{
  "videoId": "dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "channelName": "Rick Astley",
  "lengthSeconds": 213,
  "language": "en",
  "languageName": "English",
  "isAutoGenerated": false,
  "segmentCount": 61,
  "segments": [
    { "startSeconds": 18.64, "durationSeconds": 3.24, "text": "♪ We're no strangers to love ♪" },
    { "startSeconds": 22.64, "durationSeconds": 4.32, "text": "♪ You know the rules and so do I ♪" }
  ],
  "text": "[♪♪♪] ♪ We're no strangers to love ♪ ♪ You know the rules and so do I ♪ ..."
}
```

### Input

| Parameter | Default | Description |
|---|---|---|
| `videos` | (required) | Video URLs or ids: watch, youtu.be, Shorts and embed links all work |
| `language` | `en` | Preferred caption language, for example `es`, `de`, `id` |
| `proxyConfiguration` | Residential | Keep residential (see below) |

```json
{ "videos": ["https://www.youtube.com/watch?v=aircAruvnKk", "youtu.be/dQw4w9WgXcQ"], "language": "es" }
```

#### How the language is chosen

1. Creator captions in your language
2. Automatic captions in your language
3. English (creator, then automatic)
4. The first track the video has

So a request for `es` on a video with only Korean captions returns the Korean ones. Check `language` on each row, and `availableTracks` for what else exists.

### Good to know

- **Use the residential proxy.** YouTube answers most requests from Apify's own servers with "Sign in to confirm you're not a bot". Every video gets a fresh IP, and a blocked one is retried up to 4 times. Without a proxy most videos fail.
- **You pay only for transcripts.** A video without captions, private, removed or blocked is not saved as a row. It is listed in the run's status message instead, for example `12 of 13 transcript(s) saved. Failed: ...`. A run where no video works fails.
- **Captions come from the video.** Music videos often have lyric lines with ♪ marks, and some talks start with the translator's credit.
- **Long videos are long.** A 4-hour course gives about 1,900 lines and 270,000 characters of text.

### Use cases

- Build a searchable library or an AI knowledge base from lectures, tutorials and podcasts.
- Summarise videos or turn them into articles and notes.
- Study what channels say about a topic over time.
- Read a video's captions in another language when the creator provided them.

### Scope

The actor reads publicly available captions of public videos, the same ones any viewer can turn on. It uses no login and no YouTube account. Respect the rights of video creators and YouTube's terms when you use the text.

# Actor input Schema

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

Video URLs or 11-character ids. Watch, youtu.be, Shorts and embed links all work.

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

Language code such as en, es or id. Creator captions in this language are preferred, then auto-generated ones, then English, then the first track available. The tracks a video offers are listed in availableTracks.

## `proxyConfiguration` (type: `object`):

Residential is needed: YouTube answers Apify's own IPs with "Sign in to confirm you're not a bot" on most videos. Each video gets a new IP, and a blocked one is retried up to 4 times.

## Actor input object example

```json
{
  "videos": [
    "dQw4w9WgXcQ"
  ],
  "language": "en",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

One row per video that had a transcript: metadata, time-aligned segments and the joined text.

# 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": [
        "dQw4w9WgXcQ"
    ],
    "language": "en",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("xtracto/youtube-transcripts-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 = {
    "videos": ["dQw4w9WgXcQ"],
    "language": "en",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("xtracto/youtube-transcripts-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 '{
  "videos": [
    "dQw4w9WgXcQ"
  ],
  "language": "en",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call xtracto/youtube-transcripts-scraper --silent --output-dataset

```

## MCP server setup

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