# YouTube Scraper for AI: Videos, Comments and Transcripts (`wilanibe/youtube-scraper-ai`) Actor

Scrape YouTube search results, channels and playlists into clean video data: views, likes, dates, description, tags. Add top comments and transcripts with token chunks in the same item. Pay only for successful results.

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

## Pricing

from $1.50 / 1,000 videos

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 Scraper for AI: Videos, Comments and Transcripts

Scrape YouTube search results, channels and playlists into clean, structured video data: title, views, likes, exact publish time, duration, description, tags and category. You can add each video's top comments and its transcript, with token-sized chunks for AI, in the same result. Every video comes back with a clear status, and you pay only for what was extracted.

### What you can use it for

- **AI and RAG pipelines.** Get a video's details, transcript chunks and top comments together in one item, ready to embed or pass to a language model.
- **Market and competitor research.** Track what a channel publishes, how fast videos gain views and likes, and which tags and categories competitors use.
- **Trend and topic discovery.** Search any keyword, filtered by upload date and length or sorted by view count, to see what is working right now.
- **Audience research.** Read what viewers say in top comments, with like and reply counts, for sentiment analysis or product feedback.
- **Influencer and creator lists.** Collect videos and channel links for any niche from search results.

### What you can give it

| Input | Examples |
|---|---|
| Search terms | `sourdough bread recipe`, `electric car review` |
| Channels | `https://www.youtube.com/@NASA`, `@kurzgesagt`, `UCAuUUnT6oDeKwE6v1NGQxug` |
| Playlists | `https://www.youtube.com/playlist?list=PL...` or the playlist ID |
| Videos | watch, youtu.be, Shorts, embed or live URLs, or 11-character IDs |

You can mix all four in one run. A video found by more than one source is returned and charged once.

### Sample output

One item per video. This is a real result, shortened where marked with `...`:

```json
{
  "videoId": "-moW9jvvMr4",
  "url": "https://www.youtube.com/watch?v=-moW9jvvMr4",
  "title": "A Simple Way to Break a Bad Habit | Judson Brewer | TED",
  "description": "Visit http://TED.com to get our entire library of TED Talks, ...",
  "channelName": "TED",
  "channelId": "UCAuUUnT6oDeKwE6v1NGQxug",
  "channelUrl": "https://www.youtube.com/@TED",
  "durationSeconds": 565,
  "viewCount": 17385956,
  "likeCount": 332765,
  "commentCount": 5700,
  "publishedAt": "2016-02-24T09:53:22-08:00",
  "publishedDate": "2016-02-24",
  "category": "Science & Technology",
  "keywords": ["TED Talk", "Judson Brewer", "addiction", "mindfulness", "..."],
  "isLiveContent": false,
  "isLiveNow": false,
  "isFamilySafe": true,
  "isUnlisted": false,
  "thumbnailUrl": "https://i.ytimg.com/vi/-moW9jvvMr4/maxresdefault.jpg?...",
  "sourceType": "video",
  "source": "https://www.youtube.com/watch?v=-moW9jvvMr4",
  "position": 1,
  "comments": [
    {
      "commentId": "UgyeZeqG1BVfIq_4Z-B4AaABAg",
      "text": "I quit smoking 12 years ago. The physical withdraw just lasted the first 48 hours, ...",
      "author": "@PorteñaAzul",
      "authorChannelId": "UCwOeAC_gEhXGQHXJRrlusVA",
      "isCreator": false,
      "isVerified": false,
      "likeCount": 7500,
      "replyCount": 120,
      "publishedTimeText": "8 years ago"
    },
    "..."
  ],
  "commentsStatus": "ok",
  "transcript": "When I was first learning to meditate, the instruction was to simply pay attention to my breath, ...",
  "transcriptLanguage": "en",
  "transcriptIsAutoGenerated": false,
  "transcriptWordCount": 1509,
  "chunks": [
    { "index": 0, "text": "When I was first learning to meditate, ...", "start": 12.76, "end": 80.616, "tokenCount": 274 },
    "..."
  ],
  "transcriptStatus": "ok",
  "status": "ok",
  "statusReason": "Video details extracted"
}
```

`comments` and the transcript fields are filled only when you turn them on. Otherwise `commentsStatus` and `transcriptStatus` are `not_requested`.

### How much does it cost?

You pay per result, never for failures:

| Event | Price | When it is charged |
|---|---:|---|
| Video | $1.50 per 1,000 ($0.0015 each) | A video whose details were extracted |
| Comment | $0.50 per 1,000 ($0.0005 each) | Each comment returned |
| Transcript | $4.00 per 1,000 ($0.004 each) | A video whose transcript was returned |

There is also a tiny charge of $0.00005 when a run starts.

Examples:

- 1,000 videos from a search, details only: **$1.50**
- 100 videos with 20 top comments each: $0.15 + $1.00 = **$1.15**
- 500 channel videos with transcripts: $0.75 + $2.00 = **$2.75**

Deleted, private or blocked videos, unreadable sources, videos without comments and videos without a transcript are **not charged**. If you set a maximum charge per run, the run stops cleanly at that limit and never charges more.

### Input options

- **Max videos per search, channel or playlist** (`maxResults`): default 50, up to 10,000.
- **Search filters:** sort by relevance, view count or rating; upload date (last hour, today, this week, this month, this year); length (under 4 minutes, 4 to 20 minutes, over 20 minutes).
- **Channel content** (`channelContent`): any of `videos`, `shorts` and `streams`. Channels are listed newest first.
- **Top comments per video** (`maxComments`): 0 (off) to 5,000. Comments come in the order YouTube shows as Top comments.
- **Include transcript** (`includeTranscript`) with preferred **languages**, a **format** (`text`, `segments` with timings, or `markdown` with chapter headings) and an optional **chunk size in tokens** for RAG.
- **Proxy:** residential proxy is the default and is recommended. Search, listings and comments are tried without the proxy first to keep runs fast.

Example input:

```json
{
  "searchQueries": ["home workout no equipment"],
  "uploadDate": "month",
  "sortBy": "viewCount",
  "channels": ["@kurzgesagt"],
  "maxResults": 100,
  "maxComments": 20,
  "includeTranscript": true,
  "chunkTokens": 500
}
```

### Statuses

Every video gets a `status`, plus a `statusReason` in plain words:

| status | Meaning | Charged |
|---|---|---|
| `ok` | Details extracted | Yes |
| `deleted` | Video removed or never existed | No |
| `private` | Private or members-only video | No |
| `age_restricted` | Video needs sign-in to confirm age | No |
| `blocked` | YouTube refused the request after all retries | No |
| `error` | Something else went wrong after all retries | No |
| `source_not_found` | Channel or playlist does not exist | No |
| `source_error` | A search, channel or playlist could not be listed | No |
| `invalid_input` | Input not recognised as a channel, playlist or video | No |

`commentsStatus` is `ok`, `none` (no comments yet), `disabled` (the creator turned comments off, or a live stream using live chat), `error`, or `cut_by_charge_limit`. `transcriptStatus` is `ok`, `no_captions`, `language_not_available`, `live_not_finished`, `unavailable`, `blocked`, `error`, or `cut_by_charge_limit`.

### Output views and run summary

The dataset has four views: **Overview** (rank, title, channel, views, likes, duration, date, status), **Details** (thumbnail, description, tags, category), **Comments** and **Transcripts**. You can export as JSON, CSV, Excel or XML, or read results through the Apify API.

Each run also saves a `SUMMARY` record with counts per status, the number of charged videos, comments and transcripts, and whether the run stopped at your maximum charge.

### Reliability

- Failed requests are retried with new proxy sessions and backoff. Transcripts fall back to a second, independent extraction method.
- If Apify restarts or migrates the run, it resumes where it stopped without processing or charging finished videos twice.
- Sources that fail are reported as their own result with a reason, so nothing silently goes missing.

### Notes and limits

- Only public data is collected. The scraper never signs in, so private, members-only and age-restricted videos are reported, not scraped.
- View, like and comment counts come from YouTube at the time of the run. `commentCount` and comment like counts are rounded the way YouTube shows them, for example 5.7K becomes 5700.
- Comments are top-level comments only, without replies. `replyCount` tells you how many replies each has.
- Durations of ongoing live streams are not reported.
- No video or audio is downloaded.
- You are responsible for using the data in line with YouTube's terms and the laws that apply to you, especially for personal data such as commenter names.

### Questions and feedback

Open an issue on the Actor's **Issues** tab if something does not work or a field you need is missing. Reports with a run ID get fixed fastest.

# Changelog

This Actor's version history is a separate document: https://apify.com/wilanibe/youtube-scraper-ai/changelog.md

# Actor input Schema

## `searchQueries` (type: `array`):

What you would type into the YouTube search box. Each term returns up to the maximum below.

## `channels` (type: `array`):

Channel URLs, @handles or channel IDs, for example https://www.youtube.com/@NASA, @kurzgesagt or UCAuUUnT6oDeKwE6v1NGQxug. Newest videos first.

## `playlists` (type: `array`):

Playlist URLs or IDs, for example https://www.youtube.com/playlist?list=PL... Videos are returned in playlist order.

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

Individual video URLs or 11-character IDs. Accepts watch, youtu.be, Shorts, embed and live URLs.

## `maxResults` (type: `integer`):

Upper limit for each search term, channel tab and playlist. A video found by several sources is returned once.

## `sortBy` (type: `string`):

Applies to search terms only.

## `uploadDate` (type: `string`):

Only return search results uploaded within this period.

## `duration` (type: `string`):

Only return search results of this length.

## `channelContent` (type: `array`):

Which channel tabs to list. Each tab returns up to the maximum above.

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

How many top-level comments to include for each video, in the order YouTube shows as Top comments. 0 means no comments. Each returned comment is charged as a comment event.

## `includeTranscript` (type: `boolean`):

Add the video transcript to each result. Charged as a transcript event only when a transcript is returned. Needs a residential proxy.

## `transcriptLanguages` (type: `array`):

Language codes in order of preference, for example en, es. If none are available, another available language is returned.

## `transcriptFormat` (type: `string`):

text: one plain string. segments: list of start, duration and text. markdown: title heading, chapter headings, then paragraphs.

## `chunkTokens` (type: `integer`):

When set, also returns the transcript split into chunks of about this many tokens with start and end times, breaking at sentence ends. Useful for embeddings and RAG.

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

Used for transcripts, and as a fallback whenever YouTube refuses a direct request. Residential proxy is recommended.

## `tryWithoutProxyFirst` (type: `boolean`):

Search, listings, details and comments are first requested without the proxy, which is faster. Requests YouTube refuses are retried through the proxy.

## `maxConcurrency` (type: `integer`):

How many videos to process at the same time. Lowered automatically on small memory settings.

## Actor input object example

```json
{
  "searchQueries": [
    "sourdough bread recipe"
  ],
  "maxResults": 20,
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "channelContent": [
    "videos"
  ],
  "maxComments": 0,
  "includeTranscript": false,
  "transcriptLanguages": [
    "en"
  ],
  "transcriptFormat": "text",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "tryWithoutProxyFirst": true,
  "maxConcurrency": 10
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "searchQueries": [
        "sourdough bread recipe"
    ],
    "maxResults": 20,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("wilanibe/youtube-scraper-ai").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 = {
    "searchQueries": ["sourdough bread recipe"],
    "maxResults": 20,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("wilanibe/youtube-scraper-ai").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 '{
  "searchQueries": [
    "sourdough bread recipe"
  ],
  "maxResults": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call wilanibe/youtube-scraper-ai --silent --output-dataset

```

## MCP server setup

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

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/UlLzq1MjegvWFt1VO/builds/vcRWfoC8iuJbfJGUa/openapi.json
