# YouTube Comments Scraper (+ Replies) (`zkill3r/youtube-comments-scraper`) Actor

Scrape public YouTube comments and replies from videos, Shorts, channels and playlists: text, author, likes, reply count, pinned/hearted/creator flags and dates. Top or newest sort, date cut-off. For sentiment analysis, audience research, lead finding and AI datasets.

- **URL**: https://apify.com/zkill3r/youtube-comments-scraper.md
- **Developed by:** [Zee Lex](https://apify.com/zkill3r) (community)
- **Categories:** Videos, Social media, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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)

Scrape public comments, and optionally their replies, from YouTube videos, Shorts, channels and playlists. Each comment comes with its author, likes, reply count, pinned, hearted and creator flags, and an estimated date. The Actor uses plain HTTP and YouTube's own InnerTube API, so it needs no browser and no login, and it runs fast at 512 MB.

### What you get

- **Comments and replies**: the text, author name and channel, avatar, verified badge, whether the author is the video owner, pinned and hearted (by the creator) flags, likes (`"1.2K"` is returned as `1200`), reply count, the relative date (`"3 weeks ago"`) plus an estimated ISO date, whether the comment was edited, and a direct link to the comment (`&lc=`).
- **Video info**, optional and attached to every comment: title, channel, view count, publish date and total comment count.
- **Status items**: one free item per video whose comments can't be scraped (comments turned off, private, unavailable or members-only, age-restricted, or error).
- **RUN_SUMMARY**: per-video counts (comments, replies, pages, blocks, proxy escalations, status), totals, the percentage of each field that came back empty, and an overall status of `ok`, `partial`, `no_results` or `failed`.

### Input examples

**Single video, top 100 comments**

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

**A Short, newest comments since a date**

```json
{
  "videoUrls": ["https://www.youtube.com/shorts/VIDEO_ID"],
  "sort": "newest",
  "commentsSince": "2026-10-01",
  "maxCommentsPerVideo": 0
}
```

**The latest 5 uploads of a channel**

```json
{
  "channelUrls": ["https://www.youtube.com/@3blue1brown"],
  "maxVideosPerChannel": 5,
  "maxCommentsPerVideo": 200
}
```

**With replies**

```json
{
  "videoUrls": ["https://youtu.be/aircAruvnKk"],
  "maxCommentsPerVideo": 50,
  "includeReplies": true,
  "maxRepliesPerComment": 10
}
```

Accepted video formats include `watch?v=`, `youtu.be/`, `/shorts/`, `/live/`, `/embed/` and `m.youtube.com` URLs, as well as bare 11-character IDs. Channels can be given as `@handle`, `/channel/UC…`, `/c/…` or `/user/…`. Playlists can be given as `playlist?list=…` URLs or as playlist IDs.

### Output sample

```json
{
  "type": "comment",
  "commentId": "UgzKxV3d9f2kLmNoPq4AaABAg",
  "videoId": "aircAruvnKk",
  "videoUrl": "https://www.youtube.com/watch?v=aircAruvnKk",
  "parentCommentId": null,
  "text": "This is the clearest explanation of neural networks I've ever seen.",
  "authorName": "@someviewer",
  "authorChannelId": "UCabc123def456ghi789jklm",
  "authorChannelUrl": "https://www.youtube.com/channel/UCabc123def456ghi789jklm",
  "authorAvatarUrl": "https://yt3.ggpht.com/…",
  "isVerified": false,
  "isCreator": false,
  "isPinned": false,
  "isHearted": true,
  "likeCount": 1200,
  "replyCount": 14,
  "publishedTimeText": "2 years ago",
  "publishedAtApprox": "2024-10-28T09:12:00.000Z",
  "isEdited": false,
  "commentUrl": "https://www.youtube.com/watch?v=aircAruvnKk&lc=UgzKxV3d9f2kLmNoPq4AaABAg",
  "scrapedAt": "2026-10-28T09:12:00.000Z",
  "videoTitle": "But what is a neural network?",
  "channelName": "3Blue1Brown",
  "channelId": "UCYO_jab_esuFRV4b17AJtAw",
  "videoViewCount": 21000000,
  "videoPublishedAt": "2017-10-05T00:00:00.000Z",
  "totalCommentCount": 10000
}
```

A reply has `"type": "reply"`, and its `parentCommentId` is set to the ID of the comment it answers.

```json
{ "type": "video_status", "videoId": "abcdefghijk", "videoUrl": "https://www.youtube.com/watch?v=abcdefghijk", "status": "comments_disabled", "message": "Comments are turned off." }
```

### Use cases

- **Sentiment analysis**: see how viewers react to launches, ads, trailers or competitors' videos.
- **Audience research**: find recurring questions, objections, feature requests and content ideas.
- **Lead finding**: identify people asking for tools, services or help in your niche, with links to their channels.
- **Giveaways**: export every commenter with `maxCommentsPerVideo: 0`, then dedupe by `authorChannelId`.
- **AI datasets**: build clean, deduplicated comment and reply text with engagement signals.

### Limitations

- Only public comments are collected. The Actor never logs in, so members-only and private videos come back as status items.
- **Dates are approximate.** YouTube only shows relative times such as "3 weeks ago", so `publishedAtApprox` is estimated (1 month is counted as 30 days and 1 year as 365 days). `commentsSince` is equally approximate. With `sort: "top"` the date is only used as a filter, while with `sort: "newest"` paging stops as soon as older comments appear. Pinned comments are ignored for that stop.
- `maxCommentsPerVideo` counts top-level comments only. Replies are limited separately by `maxRepliesPerComment`, so a run can save more items in total than `maxCommentsPerVideo`.
- `totalCommentCount` is YouTube's rounded header value, for example `"1.2K"`.
- YouTube can show slightly different comment sets from one session to the next, and it hides some comments (spam filtering or "held for review").
- YouTube changes its page layout often. All layout knowledge is kept in `src/mappings.ts`, so a change usually needs a small edit to that one file.
- Heavy runs can trigger YouTube's "confirm you're not a bot" check. Blocked requests are retried on a fresh session with exponential backoff, and from the second retry onwards they move to RESIDENTIAL proxy (up to 4 retries). If your RUN_SUMMARY shows many blocks, lower `maxConcurrency`.

### Pricing

Pay per event: **$0.80 per 1,000 comments** on the Free plan ($0.70 Bronze, $0.60 Silver, $0.50 Gold and above). Each comment and each reply is charged as the custom event `comment`. Status items are free. The run stops cleanly once your maximum charge is reached.

### Development

```bash
npm install
npm test                 # unit tests (fixtures) and live-fixture tests if captured
npm run mock-server      # offline YouTube mock on :4599
YT_BASE_URL=http://localhost:4599 npx apify-cli run   # end-to-end against the mock
npm run capture-fixtures # save real YouTube responses to test/fixtures/live/ (needs network)
```

# Actor input Schema

## `videoUrls` (type: `array`):

YouTube videos or Shorts: watch URLs, youtu.be links, /shorts/, /live/ and embed URLs, or bare 11-character video IDs.

## `channelUrls` (type: `array`):

Optional. Channel URLs (https://www.youtube.com/@handle, /channel/UC..., /c/...) or a bare @handle. Comments of the latest uploads are scraped.

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

How many of each channel's latest uploads to scrape comments from.

## `playlistUrls` (type: `array`):

Optional. Playlist URLs (https://www.youtube.com/playlist?list=...) or playlist IDs.

## `maxVideosPerPlaylist` (type: `integer`):

How many videos of each playlist to scrape comments from, in playlist order.

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

Maximum top-level comments per video. 0 = all comments YouTube shows. Replies are limited separately.

## `sort` (type: `string`):

"Top" = YouTube's top comments order; "Newest" = most recent first (needed for "Comments since" to stop early).

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

Also scrape replies to each comment (type "reply", with parentCommentId).

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

Maximum replies saved per comment. Only used when "Include replies" is on.

## `commentsSince` (type: `string`):

Optional ISO date (e.g. 2026-10-01). Only comments posted on or after this date (approximate: YouTube shows "3 weeks ago"). With sort "Newest" paging stops as soon as older comments appear.

## `includeVideoInfo` (type: `boolean`):

Attach the video's title, channel, views, published date and total comment count to every comment.

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

Parallel requests across videos. Lower it if RUN_SUMMARY shows many blocks.

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

Apify datacenter proxy by default. Blocked requests are retried on a new session and, from the 2nd retry, on RESIDENTIAL proxy (if your plan includes it).

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=aircAruvnKk"
  ],
  "maxVideosPerChannel": 10,
  "maxVideosPerPlaylist": 10,
  "maxCommentsPerVideo": 100,
  "sort": "top",
  "includeReplies": false,
  "maxRepliesPerComment": 20,
  "includeVideoInfo": true,
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `comments` (type: `string`):

Comments, replies and per-video status items (field "type").

## `allFields` (type: `string`):

Every field of every item.

## `runSummary` (type: `string`):

Per-video counts (comments, replies, pages, blocks, escalations, status), totals, % missing per field and overall status.

# 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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=aircAruvnKk"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("zkill3r/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 = {
    "videoUrls": ["https://www.youtube.com/watch?v=aircAruvnKk"],
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zkill3r/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/KuQ3fPckF5uknsYaF/builds/6lVb3lh61wn8ty7BJ/openapi.json
