# YouTube Comments Scraper (`serentity/youtube-comments-scraper`) Actor

Get the comments of any YouTube video with replies: text, author and channel ID, likes, reply count, date, pinned and creator-hearted flags. Sort by top or newest, cap per video. No API key, no quota.

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

## Pricing

from $1.00 / 1,000 comment or replies

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

Get the comments of any YouTube video, with replies, as clean structured data. Each comment comes with its text, author handle and channel ID, like count, reply count, date, and whether it is pinned or hearted by the creator. Choose YouTube's Top ordering or newest first, cap the number per video, and decide how many replies to pull under each comment.

No YouTube API key, no quota, no login. Built for sentiment analysis, audience research, moderation, lead discovery and feeding comment threads into AI tools.

### What you get

| Field | Description |
|---|---|
| `videoId`, `videoUrl`, `videoTitle`, `channelName`, `channelId`, `videoCommentCount` | The video and its total comment count |
| `commentId`, `parentCommentId`, `isReply`, `position` | Replies carry the parent's ID; `position` is the rank among top-level comments |
| `text` | Comment text with emoji |
| `author`, `authorChannelId`, `authorUrl`, `authorAvatarUrl`, `isAuthorVerified`, `isAuthorCreator` | Who wrote it |
| `likeCount`, `likeCountText`, `replyCount` | Engagement |
| `publishedText`, `publishedAt` | "6 years ago" and an ISO date estimated from it |
| `isPinned`, `isHearted` | Pinned by the creator; hearted by the creator |
| `error`, `errorMessage` | Only on video-level failures |

### Sample output

```json
{
  "videoId": "jNQXAC9IVRw",
  "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "videoTitle": "Me at the zoo",
  "channelName": "jawed",
  "channelId": "UC4QobU6STFB0P71PMvOGN5A",
  "videoCommentCount": 10646593,
  "commentId": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "isReply": false,
  "position": 1,
  "text": "We're so honored that the first ever YouTube video was filmed here!",
  "author": "@SanDiegoZoo",
  "authorChannelId": "UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "authorUrl": "https://www.youtube.com/@SanDiegoZoo",
  "isAuthorVerified": true,
  "isAuthorCreator": false,
  "likeCount": 4800000,
  "likeCountText": "4.8M",
  "replyCount": 986,
  "publishedText": "6 years ago",
  "publishedAt": "2020-11-05T16:40:00.000Z",
  "isPinned": true,
  "isHearted": true,
  "input": "jNQXAC9IVRw",
  "fetchedAt": "2026-11-05T16:40:00.000Z"
}
```

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `videoUrls` | array of strings | required | Video URLs or IDs. |
| `maxCommentsPerVideo` | integer | `100` | Cap on top-level comments per video. `0` takes all. |
| `sortBy` | `top`, `newest` | `top` | YouTube's Top ordering or newest first. |
| `includeReplies` | boolean | `true` | Fetch replies under each comment as separate items. |
| `maxRepliesPerComment` | integer | `10` | Cap on replies per comment. `0` takes all. |
| `maxConcurrency` | integer | `3` | Videos in parallel. |
| `proxyConfiguration` | object | Apify datacenter proxy | Proxy for all requests. |
| `residentialFallback` | boolean | `true` | Retry a blocked video through residential proxies, only on a detected block. |

Minimal input:

```json
{ "videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"], "maxCommentsPerVideo": 200 }
```

### Errors

| `error` | Meaning | Charged? |
|---|---|---|
| `INVALID_INPUT` | Not a YouTube video URL or ID | no |
| `VIDEO_UNAVAILABLE` | Deleted, private or never existed | no |
| `COMMENTS_DISABLED` | The creator turned comments off, or the video is a live stream without a comment section | no |
| `NO_COMMENTS` | The video has no comments yet | no |
| `BLOCKED` | YouTube refused the request from every proxy tried | no |
| `FETCH_FAILED` | Network or parsing failure | no |

### Pricing

Pay per event: a small fixed amount per comment or reply item, plus Apify platform usage. Error items are free. Set a maximum total charge on the run and the actor stops cleanly when it is reached.

Typical cost: YouTube serves 20 comments per request and about 10 replies per request, so 1,000 comments with replies capped at 10 is roughly 50 to 150 requests and well under a minute.

### Notes

- Ordering is what YouTube shows an anonymous visitor: Top is YouTube's own ranking, Newest is chronological.
- `publishedAt` is estimated from the relative text YouTube provides, so it is as precise as that text.
- Like counts are rounded the way YouTube rounds them ("4.8M").
- Replies are fetched only for comments that have replies, and only up to `maxRepliesPerComment` each.

### Using it from code

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('serentity/youtube-comments-scraper').call({ videoUrls: ['jNQXAC9IVRw'], maxCommentsPerVideo: 500, sortBy: 'newest' });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

### Legal

Comments are public content shown to any visitor. The actor does not log in and collects only what the video page shows, including the public handle and channel ID of each author. Use it in line with YouTube's terms of service and applicable data protection law.

# Actor input Schema

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

YouTube video URLs or 11-character video IDs. Watch, youtu.be, Shorts, embed and live URLs all work.

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

Stop after this many top-level comments per video. Replies do not count towards it. 0 means all comments.

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

YouTube's Top comments ordering, or newest first.

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

Also fetch the replies under each comment. Replies are separate items with parentCommentId set.

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

Cap on replies fetched under each top-level comment. 0 means all replies.

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

Videos processed in parallel.

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

Proxy used for the requests. Apify datacenter proxies are used by default.

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

If YouTube blocks the datacenter proxy for a video, retry through Apify residential proxies. Only used on a detected block.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxCommentsPerVideo": 100,
  "sortBy": "top",
  "includeReplies": true,
  "maxRepliesPerComment": 10,
  "maxConcurrency": 3,
  "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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("serentity/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=jNQXAC9IVRw"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("serentity/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=jNQXAC9IVRw"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call serentity/youtube-comments-scraper --silent --output-dataset

```

## MCP server setup

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