# YouTube Transcript Extractor (`knowbaseai/youtube-transcript-extractor`) Actor

Professional YouTube transcript extraction tool. Features multi-language support, timestamped chunks in JSON format, and complete transcript text. Ideal for content analysis, research, and creating searchable video archives.

- **URL**: https://apify.com/knowbaseai/youtube-transcript-extractor.md
- **Developed by:** [knowbase](https://apify.com/knowbaseai) (community)
- **Categories:** Videos
- **Features:** Full permissions
- **Stats:** 197 total users, 0 monthly users, 81.1% runs succeeded, 5 bookmarks
- **User rating**: 1.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 Extractor

A powerful Apify actor for extracting transcripts/captions from YouTube videos.
The actor supports multiple languages, batch processing, and provides both structured JSON with timestamps and plain text formats.

### Features 🚀

- Extract transcripts from single or multiple YouTube videos
- Automatic language detection with English preference
- Support for various YouTube URL formats:
  - Regular videos (`youtube.com/watch?v=...`)
  - Short URLs (`youtu.be/...`)
  - Live streams (`youtube.com/live/...`)
- Structured output with:
  - Full transcript text
  - Timestamped segments
  - Available language information
  - Processing status and error handling

### Input Parameters 📝

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `youtube_urls` | array | Yes | List of YouTube video URLs to process |
| `preferredLanguage` | string | No | Preferred language code (default: 'en') |

#### Language Options

Supported languages include: English (en), Spanish (es), French (fr), German (de), Italian (it), Portuguese (pt), Russian (ru), Japanese (ja), Korean (ko), Chinese (zh), Polish (pl), Czech (cs), Slovak (sk), Swedish (sv), Dutch (nl), Hindi (hi), Norwegian (no), Arabic (ar)

### Output Format 📊

The actor saves results to its dataset with the following structure:

```json
{
    "url": "YouTube video URL",
    "video_id": "Video identifier",
    "language_used": "Language code of the extracted transcript",
    "available_languages": ["array", "of", "available", "language", "codes"],
    "transcript_json": {
        "text": "Complete transcript text",
        "chunks": [
            {
                "timestamp": [start_time, end_time],
                "text": "Segment text"
            }
        ]
    },
    "transcript_text": "Plain text transcript",
    "status": "success/error",
    "error": "Error message if any"
}
```

### Usage Examples 💡

#### Input Example

```json
{
    "youtube_urls": [
        "https://www.youtube.com/watch?v=v0sNkmiKsBU"
    ]
}
```

#### Output Example

```json
{
    "url": "https://www.youtube.com/watch?v=v0sNkmiKsBU",
    "video_id": "v0sNkmiKsBU",
    "language_used": "en",
    "available_languages": [
        "en"
    ],
    "transcript_json": {
        "text": "some people think that people who are so good at math are just nerds and they're whizzes and that's all they know how to do and zack has never been into that category at all...",
        "chunks": [
            {
                "timestamp": [2.639, 5.359],
                "text": "some people think that"
            },
            {
                "timestamp": [3.76, 7.44],
                "text": "people who are so good at math are just"
            }
            // ... more chunks
        ]
    },
    "transcript_text": "some people think that people who are so good at math are just nerds and they're whizzes and that's all they know how to do...",
    "status": "success"
}
```

Note: The output example shows a truncated version of the transcript for brevity. Actual output will contain the complete transcript with all timestamp chunks.

### Limitations ⚠️

- Videos must have captions/transcripts enabled
- Some videos might have restricted caption access
- Quality of transcripts depends on the original captions
- Rate limiting might apply for batch processing

### Error Handling 🔧

The actor provides clear error messages when:

- Video URL is invalid
- Transcripts are disabled or unavailable
- Preferred language is not available
- Any other processing errors occur

### Support 🤝

For bug reports, feature requests, or questions:

1. Create an issue in the [Issues tab](https://console.apify.com/actors/ZnLKRJb55EdVzljam/issues) on this actor
2. Visit us at [knowbase.ai](https://knowbase.ai)
3. Email us at <maciek@knowbase.ai>

### Changelog 📝

#### 0.1 \[Latest]

- Initial release
- Support for multiple video URLs
- Multi-language support
- Structured JSON and plain text output

# Actor input Schema

## `youtube_urls` (type: `array`):

List of YouTube video URLs to process. Supports regular videos, short URLs, and live streams.

## `preferredLanguage` (type: `string`):

Select preferred language for transcripts. If not available, will try English, then fall back to any available language.

## Actor input object example

```json
{
  "youtube_urls": [
    "https://www.youtube.com/watch?v=UF8uR6Z6KLc"
  ],
  "preferredLanguage": "en"
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("knowbaseai/youtube-transcript-extractor").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 = { "youtube_urls": ["https://www.youtube.com/watch?v=UF8uR6Z6KLc"] }

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

```

## MCP server setup

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

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/ZnLKRJb55EdVzljam/builds/CC4OOeiBDm7HtaVBS/openapi.json
