# YouTube Scraper for AI Agents: Search, Channels, Comments (`henrycrawl/youtube-data-llm`) Actor

Scrape YouTube search results, channels, playlists and videos into clean, LLM-ready JSON: views, exact likes, comment count, subscribers, tags, category, ISO publish time and top comments. Date and sort filters. No API key. Pay only for rows delivered.

- **URL**: https://apify.com/henrycrawl/youtube-data-llm.md
- **Developed by:** [Henry Crawl](https://apify.com/henrycrawl) (community)
- **Categories:** AI, Videos, Social media
- **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 video (full details)s

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 Agents: Search, Channels, Comments

Get YouTube **search results, channel videos, playlists, single videos and public comments** as clean, strictly typed JSON that an LLM or AI agent can use directly. No API key, no login, no YouTube quota.

Every row tells you **how sure it is**: approximate numbers are flagged (`viewCountIsApprox`, `likeCountIsApprox`, ...), fields YouTube hides are listed in `missingFields`, and every row carries its `source` and `scrapedAt` time. Failed inputs come back as free error rows with a clear `status`, never as silent gaps.

### What you get per video

| Field | Example |
|---|---|
| `title`, `url`, `videoId` | `Rick Astley - Never Gonna Give You Up`, `https://www.youtube.com/watch?v=dQw4w9WgXcQ` |
| `viewCount` | `1837088651` (exact) |
| `likeCount` | `19504389` (exact, when the creator shows likes) |
| `commentCount` | `2400000` (+ `commentCountIsApprox: true` when YouTube rounds it) |
| `channel` | `{id, name, url, handle: "@RickAstleyYT", isVerified, subscriberCount: 4560000}` |
| `publishedAt` | `2009-10-24T23:57:33-07:00` (ISO 8601, exact time) |
| `durationSeconds`, `liveStatus`, `isShort` | `213`, `not_live`, `false` |
| `tags`, `category`, `isFamilySafe` | `["rick astley", ...]`, `Music`, `true` |
| `description` | full description text |
| `comments` (optional) | `[{text, likeCount, replyCount, publishedText, isPinned, isByChannelOwner, isHearted}]` |
| `source` | `{type: "search", input: "mechanical keyboard review", rank: 3}` |

Comment **author names and channels are not collected** (privacy by design). You get the text and its signals, which is what analysis needs.

### Use cases

- **AI agents / MCP tools**: "find this week's most viewed videos about X and summarise what viewers complain about".
- **Market & product research**: read the top comments under competitor reviews.
- **Creator & channel analytics**: track views, likes and engagement of any public channel.
- **Trend monitoring**: newest uploads for a keyword, filtered to the last hour, day or week.
- **RAG datasets**: pair with [YouTube Transcript for LLM & RAG](https://apify.com/henrycrawl/youtube-transcript-llm) for the spoken content.

### Input

```json
{
  "searchQueries": ["mechanical keyboard review"],
  "startUrls": ["@mkbhd", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "maxResultsPerSource": 20,
  "sortBy": "date",
  "uploadedWithin": "week",
  "includeDetails": true,
  "maxCommentsPerVideo": 50,
  "commentsSort": "top"
}
```

- **searchQueries**: keywords; videos only. Combine with `sortBy` (relevance, date, views, rating) and `uploadedWithin` (hour, today, week, month, year).
- **startUrls**: videos, Shorts, `@handles`, channel URLs, playlists or YouTube search URLs, mixed freely.
- **channelTab**: `videos`, `shorts` or `streams`.
- **includeDetails**: turn off for a fast, cheap list (title, views, duration, channel, description snippet; no publish date).
- **maxCommentsPerVideo**: 0 to 2000 top-level comments per video.

### Output example

```json
{
  "type": "video",
  "status": "OK",
  "dataLevel": "full",
  "videoId": "l5EaCVcfMr0",
  "url": "https://www.youtube.com/watch?v=l5EaCVcfMr0",
  "title": "Wobkey Rainy75 V2 Review – Is the Upgrade Worth It?",
  "viewCount": 3459,
  "viewCountIsApprox": false,
  "likeCount": 65,
  "likeCountIsApprox": false,
  "commentCount": 39,
  "commentCountIsApprox": false,
  "channel": {
    "id": "UCwmReIrvBneiqbiS30phlfw",
    "name": "LumeKeebs",
    "url": "http://www.youtube.com/@LumeKeebs",
    "handle": "@LumeKeebs",
    "isVerified": false,
    "subscriberCount": 8130,
    "subscriberCountIsApprox": true
  },
  "publishedAt": "2026-11-13T13:57:41-08:00",
  "publishedAtIsApprox": false,
  "durationSeconds": 785,
  "liveStatus": "not_live",
  "tags": [
    "Wobkey Rainy75 V2",
    "Wobkey Rainy75",
    "Rainy75 V2 review",
    "..."
  ],
  "category": "People & Blogs",
  "commentsFetched": 19,
  "comments": [
    {
      "commentId": "UgwXUvAx9mgDWcRbEmB4AaABAg",
      "text": "Having to take it apart to release the back plate to then get access to the receiver is a weird design choice. I would u",
      "likeCount": 4,
      "likeCountIsApprox": false,
      "replyCount": 3,
      "publishedText": "10 hours ago",
      "isEdited": false,
      "isPinned": false,
      "isByChannelOwner": false,
      "isHearted": false
    }
  ],
  "missingFields": [],
  "source": {
    "type": "search",
    "input": "mechanical keyboard review",
    "rank": 1
  },
  "scrapedAt": "2026-11-14T12:35:24.451478+00:00"
}
```

Error row (not charged):

```json
{"type": "error", "status": "INVALID_URL", "input": "https://example.com/x", "error": "Not a YouTube video, Shorts, channel, playlist or search URL / ID."}
```

### Pricing (pay per event)

| Event | Price | When |
|---|---|---|
| `video` | **$1.50 / 1,000 videos** | a video row with full details |
| `search-result` | **$0.50 / 1,000** | a video row with `includeDetails: false` |
| `comment` | **$0.40 / 1,000 comments** | each comment delivered |

Residential proxy is included. Error rows, duplicates and videos that could not be loaded are **free**. Set a maximum cost per run in Apify and the actor stops cleanly when it is reached.

### FAQ

**Is it legal?** The actor only reads public pages that any logged-out visitor sees. It does not log in, does not bypass captchas or bot checks, and does not collect comment authors. You are responsible for how you use the data (copyright, GDPR and YouTube's terms in your country).

**Why are some numbers approximate?** YouTube rounds some counts (e.g. "2.4M comments", "4.56M subscribers"). The actor gives the number and tells you it is approximate instead of pretending.

**Why does `commentsFetched` differ from `commentCount`?** `commentCount` includes replies; the actor returns top-level comments.

**Likes missing?** Some creators hide likes. Then `likeCount` is `null` and listed in `missingFields`.

**Rate limits?** The actor is polite (small concurrency, backoff, fresh IP on retry). If YouTube asks an IP to prove it is not a bot, the video is returned as a free `BOT_CHECK` row; it is never bypassed.

### Related actors

- [YouTube Transcript for LLM & RAG](https://apify.com/henrycrawl/youtube-transcript-llm)
- [App Store & Google Play Reviews for AI](https://apify.com/henrycrawl/app-store-reviews-ai)

# Actor input Schema

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

Search YouTube for these keywords (videos only). Each query returns up to 'Max results per source'.

## `startUrls` (type: `array`):

Any mix of: video / Shorts URLs or 11-character IDs, channel URLs or @handles (e.g. @mkbhd), playlist URLs, youtube.com/results?search_query=... URLs.

## `maxResultsPerSource` (type: `integer`):

Maximum videos taken from each search query, channel or playlist (1-1000). Duplicates across sources are output once.

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

Order of search results (only applies to search queries).

## `uploadedWithin` (type: `string`):

Only return search results uploaded in this period (only applies to search queries).

## `channelTab` (type: `string`):

Which list of a channel to read: long videos, Shorts or past live streams. Newest first.

## `includeDetails` (type: `boolean`):

On: exact likes, comment count, subscribers, full description, tags, category and exact publish time (charged as 'video'). Off: only what the search / channel list shows - title, views, duration, channel, description snippet; no publish date (charged as the cheaper 'search-result').

## `maxCommentsPerVideo` (type: `integer`):

How many public top-level comments to add to each video (0 = none, max 2000). Comment authors are not included (privacy). Each comment is charged as 'comment'.

## `commentsSort` (type: `string`):

Top comments (YouTube's ranking) or newest first.

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

Videos processed in parallel (1-10). Keep it low to stay polite to YouTube.

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

YouTube blocks most datacenter IPs. Default: Apify residential proxy (included in the price).

## Actor input object example

```json
{
  "searchQueries": [
    "how to make sourdough bread"
  ],
  "maxResultsPerSource": 10,
  "sortBy": "relevance",
  "uploadedWithin": "any",
  "channelTab": "videos",
  "includeDetails": true,
  "maxCommentsPerVideo": 0,
  "commentsSort": "top",
  "maxConcurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Video rows (with optional comments) and free error rows.

## `summary` (type: `string`):

Counts per status for this run (SUMMARY record).

# 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": [
        "how to make sourdough bread"
    ],
    "maxResultsPerSource": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("henrycrawl/youtube-data-llm").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": ["how to make sourdough bread"],
    "maxResultsPerSource": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("henrycrawl/youtube-data-llm").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": [
    "how to make sourdough bread"
  ],
  "maxResultsPerSource": 10
}' |
apify call henrycrawl/youtube-data-llm --silent --output-dataset

```

## MCP server setup

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

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/qJLi4jfBYNMYJr4oQ/builds/lqjPU2E8ot2bO1Zlx/openapi.json
