# YouTube Comments, Channel & Search Scraper (`randy-tools/youtube-data-scraper`) Actor

One YouTube scraper, four modes: comments (top or newest, with replies), channel videos, Shorts and live streams with channel stats, search results (videos, channels, playlists, with filters), and full video details. Fast HTTP-only, clean schema, pay per result.

- **URL**: https://apify.com/randy-tools/youtube-data-scraper.md
- **Developed by:** [AICORP Tools](https://apify.com/randy-tools) (community)
- **Categories:** Social media, Videos
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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 Comments, Channel & Search Scraper

**One Actor for the four things people scrape from YouTube:** comments (with replies), channel videos, Shorts and streams (with the channel's profile), search results, and full video details. One input, one clean schema, no API key, no browser.

Built for **reliability**: plain HTTP requests start on fast datacenter IPs. When YouTube bot-checks one, that request is retried on residential IPs and the run carries on from the same page, so nothing is duplicated or lost. In our test runs, **every requested comment page, channel page and search page was delivered**.

### What you can do with it

- **Sentiment and audience research:** pull the comments under any video, sorted by top or newest, with replies
- **Competitor and creator tracking:** list a channel's videos, Shorts and streams with views, duration and age, plus subscribers and links
- **Lead and trend discovery:** search YouTube with the same filters as the site (upload date, type, length, popularity)
- **Datasets and monitoring:** video details with likes, tags, category, chapters and publish date

### Modes

| Mode | Input | You get |
|---|---|---|
| **Video comments** | `videos` | comment text, author name, likes, replies count, published time, pinned / hearted / by-creator flags, comment id and parent id |
| **Channel videos** | `channels` | one channel profile record (subscribers, video count, total views, description, country, joined date, links) and the channel's videos, Shorts or streams: title, id, views, duration, published time, thumbnail |
| **Search results** | `searchQueries` | videos, Shorts, channels and playlists; filters for upload date, type, length and popularity |
| **Video details** | `videos` | title, full description, views, exact likes, comment count, category, tags, publish date, duration, chapters, channel and subscribers |

Every record has a `type` (`comment`, `video`, `short`, `channel`, `playlist`, or `error`) so mixed outputs are easy to split.

### Input example

```json
{
  "mode": "comments",
  "videos": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "maxComments": 500,
  "commentSort": "newest",
  "includeReplies": true,
  "maxRepliesPerComment": 20
}
```

```json
{
  "mode": "search",
  "searchQueries": ["python tutorial"],
  "resultType": "video",
  "uploadDate": "week",
  "duration": "medium",
  "sortBy": "popularity",
  "maxResults": 100
}
```

### Output examples

Comment:

```json
{
  "type": "comment",
  "commentId": "Ugzge340dBgB75hWBm54AaABAg",
  "parentId": null,
  "author": "@YouTube",
  "authorChannelId": "UCBR8-60-B28hp2BmDPdntcQ",
  "authorChannelUrl": "https://www.youtube.com/@YouTube",
  "authorIsVerified": true,
  "text": "can confirm: he never gave us up",
  "likes": 321000,
  "replyCount": 963,
  "publishedTime": "1 year ago",
  "isEdited": false,
  "isReply": false,
  "isPinned": true,
  "isHearted": true,
  "isCreator": false,
  "videoId": "dQw4w9WgXcQ",
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "videoTitle": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "scrapedAt": "2026-09-28T19:08:52+00:00"
}
```

Channel video:

```json
{
  "type": "video",
  "contentKind": "video",
  "videoId": "PXC_PYeB6F8",
  "url": "https://www.youtube.com/watch?v=PXC_PYeB6F8",
  "title": "Rick Astley - Angels On My Side (Live at The O2, London, April 2026)",
  "channelName": "Rick Astley",
  "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "channelUrl": "https://www.youtube.com/@RickAstleyYT",
  "viewCount": 100000,
  "viewCountText": "100K views",
  "duration": "3:51",
  "durationSeconds": 231,
  "publishedTime": "3 months ago",
  "isLive": false
}
```

Channel profile:

```json
{
  "type": "channel",
  "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "url": "https://www.youtube.com/@RickAstleyYT",
  "handle": "@RickAstleyYT",
  "title": "Rick Astley",
  "subscribers": 4550000,
  "videoCount": 437,
  "totalViews": 2570271276,
  "country": "United Kingdom",
  "joinedDate": "Feb 1, 2015",
  "links": [{ "title": "Website", "url": "https://www.rickastley.co.uk/" }],
  "isVerified": true
}
```

Export results as JSON, CSV, Excel or HTML, or pull them via the Apify API, webhooks, Make, Zapier, n8n or MCP.

### Good to know

- **Comment counts:** the number YouTube shows under a video includes comments it no longer serves (deleted, held for review, filtered as spam). In our tests the Actor returned **86% to 98% of that number** on videos with up to a few hundred comments, and **every reply** listed under a returned comment. The log prints both numbers per video.
- **Likes on comments** are rounded by YouTube above 1,000 (`321K`), so `likes` is approximate for popular comments. Video `likeCount` is exact.
- **Search sorting:** YouTube's search offers Relevance and Popularity only; there is no sort by upload date any more. To get recent videos, set *Upload date* to today, this week or this month.
- **Times are relative** (`3 months ago`): that is all YouTube exposes for comments and listings. Video details include the exact `publishDate`.
- **Channel listings** carry no description (YouTube does not send one there). Turn on *Add full video details* to get description, likes, tags and chapters for each video; it is slower because each video needs extra requests.
- **Comments turned off, private or removed videos** produce a free `error` record with the reason.
- **No logins, no cookies.** Only public data is read; author names are the public display names shown under comments.

### Pricing

Pay only for results: a small fee per **comment**, per **video** (channel listing or video details) and per **search result**. The channel profile record counts as one result. Error records are free. Proxy costs, including the residential fallback, are included.

### FAQ

**How many comments can I get?** Set `maxComments` per video (up to 1,000,000). Replies count toward it when included.

**Does it work for Shorts and live replays?** Yes. Paste any watch, Shorts, live or youtu.be link.

**Which channel URLs work?** `@handle` URLs, `/channel/UC...`, `/c/name`, `/user/name`, bare `@handles` and channel ids.

**Is this legal?** The Actor reads publicly available data without logins. You are responsible for using it in line with applicable laws, privacy rules and YouTube's terms.

**Something broke?** Open an issue on the Issues tab. We monitor the Actor daily and usually respond within 24 hours.

# Actor input Schema

## `mode` (type: `string`):

Comments of videos, videos of channels, search results, or details of single videos. Only the input list for the chosen mode is used.

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

Used by the comments and video details modes. YouTube video URLs or ids: watch, youtu.be, shorts, embed and live links all work.

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

Used by the channel mode. Channel URLs (@handle, /channel/UC..., /c/name, /user/name), bare @handles or channel ids.

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

Used by the search mode. One YouTube search per line, exactly as you would type it on youtube.com.

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

Comments mode. Stop after this many comments per video. Replies count toward the limit when they are included.

## `commentSort` (type: `string`):

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

## `includeReplies` (type: `boolean`):

Also fetch the replies under each comment. Replies come right after their parent comment and have parentId set.

## `maxRepliesPerComment` (type: `integer`):

Stop after this many replies under one comment. Leave empty for all replies.

## `channelContent` (type: `string`):

Which channel tab to list: regular videos, Shorts, past live streams, or all three.

## `maxVideosPerChannel` (type: `integer`):

Stop after this many items per channel and tab.

## `channelSort` (type: `string`):

Newest first, most popular first, or oldest first.

## `includeChannelInfo` (type: `boolean`):

Add one channel record per channel: subscribers, video count, total views, description, country, joined date and links. Billed as one result.

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

Search mode. Stop after this many results per search query.

## `resultType` (type: `string`):

Only videos, only Shorts, only channels, only playlists, or a mix of everything YouTube returns.

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

Only videos uploaded within this period.

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

Only videos of this length: under 3 minutes, 3 to 20 minutes, or over 20 minutes.

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

Relevance (YouTube's default) or popularity. YouTube no longer offers sorting by upload date; use the Upload date filter to get recent videos.

## `includeVideoDetails` (type: `boolean`):

Channel and search modes. Add description, likes, category, tags, chapters and publish date to every video (two extra requests per video, so runs are slower).

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

Videos, channels or queries processed in parallel.

## `residentialFallback` (type: `boolean`):

If YouTube bot-checks a datacenter IP, retry that request through residential proxy and carry on from where it stopped. Keeps runs reliable at scale; proxy cost is included in the price.

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

Apify Proxy, exiting from the US unless you pick another country (results and availability vary by region). Datacenter proxy (the default) is fast and cheap; with 'Residential fallback' on, blocked requests are retried on residential IPs automatically.

## Actor input object example

```json
{
  "mode": "comments",
  "videos": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channels": [
    "https://www.youtube.com/@RickAstleyYT"
  ],
  "searchQueries": [
    "python tutorial"
  ],
  "maxComments": 100,
  "commentSort": "top",
  "includeReplies": false,
  "channelContent": "videos",
  "maxVideosPerChannel": 50,
  "channelSort": "latest",
  "includeChannelInfo": true,
  "maxResults": 50,
  "resultType": "any",
  "uploadDate": "any",
  "duration": "any",
  "sortBy": "relevance",
  "includeVideoDetails": false,
  "maxConcurrency": 8,
  "residentialFallback": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (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 = {
    "videos": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "channels": [
        "https://www.youtube.com/@RickAstleyYT"
    ],
    "searchQueries": [
        "python tutorial"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("randy-tools/youtube-data-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": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
    "channels": ["https://www.youtube.com/@RickAstleyYT"],
    "searchQueries": ["python tutorial"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("randy-tools/youtube-data-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": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channels": [
    "https://www.youtube.com/@RickAstleyYT"
  ],
  "searchQueries": [
    "python tutorial"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call randy-tools/youtube-data-scraper --silent --output-dataset

```

## MCP server setup

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