# YouTube Comments Scraper: Replies, Shorts, Channels (`zhtech/youtube-comments-scraper`) Actor

Scrape YouTube comments and replies from videos, Shorts, channels, playlists and search. Top or newest sort, keyword and date filters, pinned and creator-hearted flags, likes, reply counts, comment IDs and dates. Only delivered comments are charged.

- **URL**: https://apify.com/zhtech/youtube-comments-scraper.md
- **Developed by:** [ZH Tech](https://apify.com/zhtech) (community)
- **Categories:** 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 $0.30 / 1,000 comments

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 Comments Scraper: Replies, Shorts, Channels

Scrape **YouTube comments and replies in bulk** from videos, Shorts, whole channels, playlists and YouTube search, in one run. Every comment row comes with its comment ID, the full text, author name and channel, like count, reply count, **pinned** and **hearted by creator** flags, whether the author is the video creator, the parent comment ID for replies, the relative time YouTube shows plus a **best effort absolute date**, and the video it belongs to.

You only pay for comments that were actually delivered. Videos with comments turned off, videos without comments, removed videos and anything else that fails come back as free rows with a clear error code, so you always know why.

Built and maintained by **ZH Tech**.

### What can this YouTube Comments Scraper do?

- **Every kind of input in one field**: watch links, youtu.be links, Shorts and live links, bare video IDs, channels (`@handle`, `/channel/UC...`, `/c/`, `/user/`, or a tab such as `/@name/shorts`), playlists and YouTube search URLs. Add plain search queries in a separate field. Duplicate videos are removed.
- **Whole comment sections**: set a limit per video or use 0 to get every comment. Comments are paged with the same protocol the YouTube website uses and de-duplicated by comment ID.
- **Replies done right**: turn on replies and each reply becomes its own row with `isReply: true` and `parentCommentId`, placed right after its parent, with a separate limit per thread.
- **Top or Newest first**: YouTube's own ranking, or newest first for monitoring brand mentions and new feedback.
- **Filters that save money**: keep only comments containing your keywords, or only comments newer than a date (with Newest first the actor stops paging as soon as comments get too old). Filtered comments are never charged.
- **Channels, playlists and searches**: scrape the comments of the newest videos of a channel (videos, Shorts, past live streams), any playlist, or the top results of a search, with a max videos per source and a video age filter.
- **Rich flags**: pinned comment, creator heart, comment by the channel owner, verified author, artist channel, edited comment.
- **Works on age restricted videos**: their comments are public and returned without login.
- **Built to avoid blocking**: Apify Proxy with session rotation, retries, and automatic escalation from datacenter to residential IPs only for requests YouTube blocks. Responses are trimmed with field masks, so runs are fast and cheap.
- **Never crashes on a bad video**: each problem becomes a free row with an `errorCode`.

### Use cases

- **Sentiment analysis and audience research**: collect thousands of comments on your videos or a competitor's and feed them to an LLM or a sentiment model.
- **Product feedback and brand monitoring**: schedule Newest first runs with a date filter and a keyword list (your brand, product or feature names) and push new mentions to Slack or Google Sheets.
- **Market research**: search a topic (for example "robot vacuum review") and analyze what viewers praise and complain about across the top videos.
- **Creator tools**: find the questions your audience asks, the comments you hearted, and the threads with the most replies.
- **Influencer and lead research**: see which channels comment on videos in your niche (author channel URL on every row).
- **AI training data**: build datasets of real conversations with thread structure intact.

### How to use it

1. Click **Try for free**.
2. Paste video or Shorts URLs into **YouTube URLs or IDs**. You can also paste a channel, playlist or search URL, or add **Search queries**.
3. Set **Max comments per video**, choose **Top** or **Newest first**, and turn on **Include replies** if you need them.
4. Click **Start**. Comments appear in the **Output** tab within seconds. Download them as JSON, CSV, Excel, XML or HTML, or fetch them via the API.

### Input examples

All comments of one video, newest first:

```json
{
  "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "maxCommentsPerVideo": 0,
  "sortBy": "newest"
}
```

Top 200 comments with up to 5 replies each, for the 10 newest videos of a channel:

```json
{
  "urls": ["https://www.youtube.com/@3blue1brown"],
  "maxVideosPerSource": 10,
  "channelContentTypes": ["videos"],
  "maxCommentsPerVideo": 200,
  "includeReplies": true,
  "maxRepliesPerThread": 5
}
```

Brand monitoring: comments from the last 7 days that mention a product, across the top search results:

```json
{
  "searchQueries": ["pixel 10 review"],
  "maxVideosPerSource": 15,
  "sortBy": "newest",
  "commentsPublishedAfter": "7 days",
  "keywords": ["battery", "camera", "price"],
  "maxCommentsPerVideo": 0
}
```

#### All input options

| Field | Type | Default | What it does |
|---|---|---|---|
| `urls` | array | | Videos, Shorts, channels, playlists or search URLs, or bare video IDs |
| `searchQueries` | array | | Plain search queries |
| `maxVideosPerSource` | integer | 10 | Videos per channel, playlist or search (0 = all) |
| `channelContentTypes` | array | videos, shorts, streams | Which channel uploads to include |
| `searchSort` | string | relevance | relevance or views (popularity). YouTube no longer sorts searches by upload date or rating: old inputs with `date` run as relevance, `rating` as views, with a log note |
| `videoPublishedAfter` | string | | Skip older videos from channels, playlists and searches (date or "30 days") |
| `maxCommentsPerVideo` | integer | 100 | Top level comments per video (0 = all). Replies have their own limit |
| `sortBy` | string | top | top or newest |
| `includeReplies` | boolean | false | Add replies as separate rows |
| `maxRepliesPerThread` | integer | 10 | Replies per comment (0 = all) |
| `keywords` | array | | Only comments containing at least one of these (not case sensitive) |
| `commentsPublishedAfter` | string | | Only comments newer than this date or period |
| `skipPinnedComment` | boolean | false | Leave out the pinned comment |
| `includeErrorItems` | boolean | true | Free rows for videos without comments |
| `maxComments` | integer | 0 | Stop the run after this many rows in total (0 = no limit) |
| `maxConcurrency` | integer | 8 | Videos in parallel |
| `maxRetries` | integer | 5 | Retries per request with a fresh proxy session |
| `proxyConfiguration` | object | Apify Proxy | Proxy settings |
| `residentialFallback` | boolean | true | Retry blocked requests on residential IPs |

### Output example

One row per comment or reply:

```json
{
  "status": "success",
  "commentId": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "videoId": "jNQXAC9IVRw",
  "videoTitle": "Me at the zoo",
  "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "commentUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw&lc=UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "text": "We're so honored that the first ever YouTube video was filmed here!",
  "authorName": "@SanDiegoZoo",
  "authorHandle": "@SanDiegoZoo",
  "authorChannelId": "UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "authorChannelUrl": "https://www.youtube.com/channel/UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "authorAvatarUrl": "https://yt3.ggpht.com/...",
  "authorIsVerified": true,
  "authorIsChannelOwner": false,
  "authorIsArtist": false,
  "likeCount": 4800000,
  "likeCountText": "4.8M",
  "replyCount": 986,
  "isPinned": true,
  "isHeartedByCreator": true,
  "isReply": false,
  "parentCommentId": null,
  "isEdited": false,
  "publishedTimeText": "6 years ago",
  "publishedAt": "2020-11-17",
  "publishedAtPrecision": "year",
  "position": 1,
  "sortedBy": "top",
  "videoChannelId": "UC4QobU6STFB0P71PMvOGN5A",
  "videoChannelName": "jawed",
  "videoCommentCount": 10000000,
  "videoCommentCountText": "10M",
  "input": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "source": "video:jNQXAC9IVRw",
  "scrapedAt": "2026-11-16T03:21:48+00:00"
}
```

A reply has `isReply: true`, `parentCommentId` set to the top level comment, and a `commentId` like `PARENTID.REPLYID`.

A video without comments returns a free row:

```json
{
  "status": "error",
  "errorCode": "COMMENTS_DISABLED",
  "errorMessage": "Comments are turned off for this video. Not charged.",
  "videoId": "XXXXXXXXXXX",
  "videoUrl": "https://www.youtube.com/watch?v=XXXXXXXXXXX"
}
```

The **Output** tab has ready made views: Overview, Threads (IDs to rebuild conversations), Authors, and Videos without comments.

#### Error codes

| Code | Meaning |
|---|---|
| `COMMENTS_DISABLED` | The creator turned comments off |
| `NO_COMMENTS` | The video has no comments yet |
| `NO_MATCHING_COMMENTS` | Comments exist, but none matched your keyword or date filters |
| `VIDEO_UNAVAILABLE` | The video does not exist, is private or was removed |
| `BLOCKED` | YouTube kept refusing requests after all retries (rare) |
| `FETCH_FAILED` | Unexpected error for this video |
| `LISTING_FAILED`, `CHANNEL_NOT_FOUND` | A channel, playlist or search could not be listed |
| `INVALID_INPUT` | The input is not a YouTube URL or ID |

Each run also saves a `RUN_SUMMARY` record in its key-value store with counts, pages fetched, time taken and proxy statistics.

### How much does it cost to scrape YouTube comments?

This actor uses **pay per event** pricing:

- **Comment**: charged once per comment or reply row delivered (`status: "success"`). Error rows and filtered comments are free.
- **Actor start**: a tiny fixed fee per run.

The exact prices are on the **Pricing** tab. Platform usage (compute and proxy) is included, so the price you see is the price you pay. Cap your spend with **Max comments in total** or the "Maximum cost per run" setting: the actor checks the remaining budget before every batch and stops cleanly instead of overspending.

Tips to keep costs low:

- Set **Max comments per video** to what you really need. The top 100 comments usually carry most of the signal.
- Use keyword and date filters: non matching comments are never charged.
- Replies can multiply the row count on popular videos. Keep **Max replies per comment** small unless you need full threads.

### Use with the API, integrations, LLMs and MCP

#### API

Run the actor and get the results in one request (replace `YOUR_TOKEN`):

```bash
curl -X POST "https://api.apify.com/v2/acts/zhtech~youtube-comments-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"], "maxCommentsPerVideo": 50}'
```

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("zhtech/youtube-comments-scraper").call(run_input={
    "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxCommentsPerVideo": 500,
    "includeReplies": True,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item["status"] == "success":
        print(item["likeCount"], item["text"][:80])
```

JavaScript:

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_TOKEN' });
const run = await client.actor('zhtech/youtube-comments-scraper').call({
    urls: ['https://www.youtube.com/shorts/V_uq3v6xK-4'],
    sortBy: 'newest',
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length, 'comments');
```

#### Integrations

Connect the actor to Make, Zapier, n8n, Google Sheets, Slack, Airtable, webhooks and more from the **Integrations** tab. A typical flow: schedule a daily Newest first run with `commentsPublishedAfter: "1 day"` on your latest videos, then send new comments to a sentiment or summary step and post the result to Slack.

#### Using it with LLMs and AI agents (MCP)

The actor works as a tool for AI agents through the Apify MCP server (mcp.apify.com). Add `zhtech/youtube-comments-scraper` as a tool in Claude, Cursor, VS Code or any other MCP client, then ask things like "What do viewers complain about in the comments of this video?" or "Find comments that mention pricing on the last 5 videos of @mkbhd". Keep `maxCommentsPerVideo` modest (100 to 300) for LLM prompts; the `text`, `likeCount` and `isReply` fields are usually all a model needs.

### FAQ

**Can I get all comments of a video?**
Yes. Set **Max comments per video** to 0. Very large videos (millions of comments) take a while; YouTube serves about 20 comments per page.

**Why is the number of comments lower than the count shown on YouTube?**
YouTube's count includes replies and comments that were later deleted or held for review. Turn on replies (with Max replies per comment set to 0) to get as close as possible. Comments hidden by YouTube's spam filter are never shown to anyone.

**Does it scrape replies?**
Yes, when **Include replies** is on. Each reply is its own row with `parentCommentId`, so you can rebuild every thread.

**Are the dates exact?**
YouTube only shows relative times such as "3 weeks ago". The actor keeps that text in `publishedTimeText` and computes `publishedAt` from it, with `publishedAtPrecision` telling you how precise it is (minute, hour, day, week, month or year). With Newest first, recent comments are accurate to the minute or hour.

**Are like counts exact?**
For counts below 1,000 yes. Above that YouTube only shows rounded values such as 4.8M; `likeCount` is that value as a number and `likeCountText` is the original.

**Can I get dislikes?**
No. YouTube does not show dislike counts for comments to anyone.

**Does it work for Shorts and live stream replays?**
Yes. Shorts comments and the comments of past live streams work like any video. Live chat messages are not comments and are not included.

**Can I scrape comments of private or members only videos?**
No. The actor never logs in and only reads public comments. Age restricted videos do work.

**Is it legal to scrape YouTube comments?**
The actor only collects publicly visible data. Comments contain personal data such as usernames, so make sure you have a legitimate purpose, store data responsibly and follow YouTube's terms and privacy laws like GDPR. If you are unsure, consult a lawyer.

### Limitations

- Comment dates are relative on YouTube; `publishedAt` is computed with the precision shown in `publishedAtPrecision`.
- Large like and comment counts are rounded by YouTube (for example 4.8M, 9.5K).
- Comments on community posts and live chat messages are not supported.
- With a keyword filter (or a date filter with Top sort) the actor scans up to 25 times your per video limit, at least 2,000 comments, per video before moving on.
- `videoPublishedAfter` uses the upload age YouTube shows in listings (for example "2 weeks ago"), so it is approximate at the edges.

### Support

Found a problem or need a feature? Open an issue on the **Issues** tab with the run ID and the video URL.

# Actor input Schema

## `urls` (type: `array`):

Video, Shorts or live URLs, youtu.be links, bare 11 character video IDs, channel URLs or @handles, playlist URLs, or YouTube search result URLs. For channels, playlists and searches the actor scrapes the comments of the first videos (see Max videos per channel, playlist or search).

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

Search YouTube and scrape the comments of the top videos for each query.

## `maxVideosPerSource` (type: `integer`):

How many videos to take from each channel, playlist or search query. 0 means all. Single video URLs are always scraped.

## `channelContentTypes` (type: `array`):

Which uploads of a channel to include, newest first. A channel URL that names a tab (for example /@name/shorts) uses only that tab.

## `searchSort` (type: `string`):

Order of videos for search queries. These are the only two orders YouTube still applies. YouTube removed sorting by upload date and rating in 2025 (it silently ignores them): for recent videos use "Only videos published after". Old saved inputs with "date" run in relevance order and "rating" runs as popularity, with a note in the log.

## `videoPublishedAfter` (type: `string`):

For channels, playlists and searches: skip videos older than this (based on the upload age YouTube shows in listings). Example: 30 days.

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

Maximum top level comments per video. Replies do not count toward this limit (they have their own limit). 0 means all comments.

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

Top is the YouTube ranking. Newest first is best for monitoring and for date filters (the actor stops paging as soon as comments get older than your date).

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

Also scrape replies to each comment. Every reply is its own row with isReply = true and parentCommentId set, placed right after its parent comment.

## `maxRepliesPerThread` (type: `integer`):

Maximum replies per top level comment when replies are on. 0 means all replies.

## `keywords` (type: `array`):

Keep only comments whose text contains at least one of these words or phrases (not case sensitive). Non matching comments are skipped and not charged. With a keyword filter the actor scans up to 25 times your per video limit (at least 2,000 comments) per video.

## `commentsPublishedAfter` (type: `string`):

Skip comments older than this date or period (for example 7 days). Works best with Newest first, which stops paging early. YouTube only shows relative times such as 3 days ago, so the comparison uses that precision.

## `skipPinnedComment` (type: `boolean`):

Leave out the comment the creator pinned to the top.

## `includeErrorItems` (type: `boolean`):

Add a free (never charged) row for each video with comments turned off, no comments, or an error, so you can see why.

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

Stop the whole run after this many comment rows (comments plus replies). 0 means no limit. Your maximum cost per run setting is always respected too.

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

How many videos to scrape at the same time.

## `maxRetries` (type: `integer`):

Retries with a fresh proxy session when YouTube refuses a request.

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

Apify Proxy datacenter IPs work for most runs. Requests that YouTube blocks are retried on residential IPs automatically (see below).

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

When YouTube blocks the datacenter proxy, retry those requests on residential IPs. Recommended.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "https://youtu.be/dQw4w9WgXcQ",
    "https://www.youtube.com/shorts/V_uq3v6xK-4",
    "https://www.youtube.com/@3blue1brown",
    "https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi"
  ],
  "searchQueries": [
    "iphone 17 review",
    "best budget espresso machine"
  ],
  "maxVideosPerSource": 10,
  "channelContentTypes": [
    "videos",
    "shorts",
    "streams"
  ],
  "searchSort": "relevance",
  "maxCommentsPerVideo": 100,
  "sortBy": "top",
  "includeReplies": false,
  "maxRepliesPerThread": 10,
  "keywords": [
    "price",
    "battery"
  ],
  "skipPinnedComment": false,
  "includeErrorItems": true,
  "maxComments": 0,
  "maxConcurrency": 8,
  "maxRetries": 5,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "residentialFallback": 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 = {
    "urls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "maxVideosPerSource": 10,
    "maxCommentsPerVideo": 100,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("zhtech/youtube-comments-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 = {
    "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxVideosPerSource": 10,
    "maxCommentsPerVideo": 100,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("zhtech/youtube-comments-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 '{
  "urls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxVideosPerSource": 10,
  "maxCommentsPerVideo": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call zhtech/youtube-comments-scraper --silent --output-dataset

```

## MCP server setup

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