# YouTube Transcript Scraper - Captions & Comments (`sweet_stickball/youtube-transcripts`) Actor

Scrape YouTube video transcripts (captions and auto-generated subtitles) with timestamps, video metadata and optional comments. YouTube transcript and subtitle extractor, one video per run, no API key.

- **URL**: https://apify.com/sweet_stickball/youtube-transcripts.md
- **Developed by:** [CrawlKit](https://apify.com/sweet_stickball) (community)
- **Categories:** Videos, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 94.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.10 / 1,000 video 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?

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 & Comments

Get the transcript of a YouTube video as timestamped text, together with video metadata and, optionally, its comments. One video per run, flat JSON output, no API key.

The actor reads the video's caption track (manual captions preferred, auto-generated as fallback; English preferred, otherwise the first available language) through YouTube's InnerTube endpoints. Requests go through Apify Proxy and are retried with exponential backoff on errors and rate limits. Comment author names are pseudonymized (first name + initial).

### Input

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `videoUrl` | string | Yes | — | YouTube video URL or 11-char video ID |
| `includeComments` | boolean | No | `false` | Also fetch video comments |
| `maxComments` | integer | No | `100` | Max comments to fetch (1-5000) |

### Output

```json
{
    "videoId": "aBcDeFgHiJk",
    "title": "How Solar Panels Work",
    "channel": "Example Science Channel",
    "channelId": "UCxxxxxxxxxxxxxxxxxxxxxx",
    "duration": 212,
    "durationFormatted": "3:32",
    "viewCount": 152000,
    "publishDate": "2024-03-12",
    "description": "In this video we explain...",
    "thumbnail": "https://i.ytimg.com/vi/aBcDeFgHiJk/maxresdefault.jpg",
    "isLive": false,
    "transcriptLanguage": "en",
    "transcriptSegmentCount": 45,
    "transcript": "[0:00] Today we look at how solar panels turn light into electricity\n[0:05] It starts with the photovoltaic cell...",
    "commentCount": 100,
    "comments": [
        {
            "author": "@jan***",
            "text": "Very clear explanation, thanks!",
            "publishedTime": "2 years ago",
            "likeCount": 1200,
            "replyCount": 15
        }
    ],
    "scrapedAt": "2024-12-01T10:30:00Z"
}
```

### Input Example

```json
{
    "videoUrl": "https://www.youtube.com/watch?v=aBcDeFgHiJk",
    "includeComments": true,
    "maxComments": 50
}
```

### Pricing

Pay-per-event, **no start fee**: **$3.50 per 1,000 video transcripts** on the Apify Free plan, with lower prices on paid plans. Comments (`includeComments`) are included at no extra charge.

| Event | Free | Starter | Scale | Business | Enterprise |
|-------|------|---------|-------|----------|------------|
| Video transcript (`TRANSCRIPT`) | $3.50 | $3.00 | $2.60 | $2.10 | $2.10 |

Prices in USD per 1,000 events.

#### Cost examples (Free plan)

| Usage | Cost |
|-------|------|
| 1 video transcript | $0.0035 |
| 100 video transcripts | $0.35 |
| Comments | included |

### Use cases

- **Content repurposing** — turn a video into a blog post, summary, or training document
- **Research** — search and analyze what's being said across hundreds of videos
- **Sentiment analysis** — pull comments at scale for audience insights
- **Accessibility** — extract transcripts for indexing, translation, or archiving
- **AI pipelines** — feed video content into LLMs for summarization, Q\&A, or retrieval-augmented generation

### Limitations

- **Captions required** — a transcript is returned only when the video has captions (manual or auto-generated). Without captions the record still contains the video metadata (and comments if requested), with an empty `transcript` and `transcriptSegmentCount: 0`.
- **One language** — the actor picks one caption track: English if available (manual before auto-generated), otherwise the first track listed. There is no language selection input.
- **One video per run** — run the actor once per video.
- **Comments** — top-level comments only, in YouTube's default order; `publishedTime` is relative ("2 years ago"). Videos with comments disabled return an empty list, and fewer than `maxComments` may be returned.
- **Privacy** — comment authors are pseudonymized: channel handles keep only their first 3 characters (`@jan***`), full names become first name + initial (`Jane D.`).
- **Unavailable videos** — private, deleted or region-blocked videos end the run FAILED.

### Related Actors

- [Google Trends Scraper - Interest Over Time & Related Queries](https://apify.com/sweet_stickball/google-trends-scraper) — Scrape Google Trends: interest over time and related queries for up to 5 compared keywords, by country, time range and category.
- [Telegram Channel Scraper API - Messages & Views, No Login](https://apify.com/sweet_stickball/telegram-public-channel-scraper) — Scrape public Telegram channel messages: text, dates, views, media and links. Telegram data API with no account, phone number or any API key needed.
- [Google News Scraper API - Articles by Keyword, No Login](https://apify.com/sweet_stickball/google-news-scraper) — Scrape Google News articles for any keyword: headlines, sources, dates and URLs by country and language. News monitoring API, no API key or login.

# Actor input Schema

## `videoUrl` (type: `string`):

YouTube video URL or video ID. Supports all URL formats: full watch URL, short youtu.be link, embed URL, or raw 11-character ID. Examples: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'dQw4w9WgXcQ'

## `includeComments` (type: `boolean`):

Whether to also fetch video comments (makes the run longer).

## `maxComments` (type: `integer`):

Maximum number of comments to fetch when includeComments is true. Keep small for speed.

## Actor input object example

```json
{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "includeComments": false,
  "maxComments": 100
}
```

# Actor output Schema

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

Dataset items shown with the 'results' view.

# 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 = {
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};

// Run the Actor and wait for it to finish
const run = await client.actor("sweet_stickball/youtube-transcripts").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 = { "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }

# Run the Actor and wait for it to finish
run = client.actor("sweet_stickball/youtube-transcripts").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 '{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}' |
apify call sweet_stickball/youtube-transcripts --silent --output-dataset

```

## MCP server setup

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

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/yGAXhqhLiWAccn0ZZ/builds/sUi1jemlJz2YZQI3F/openapi.json
