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

Extract YouTube comments, threaded replies, author details, sentiment, spam scores, and video analytics at scale.

- **URL**: https://apify.com/rexreus/youtube-comments-scraper.md
- **Developed by:** [REXREUS D.O](https://apify.com/rexreus) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 results

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

<p align="center">
  <h1 align="center">YouTube Comments Scraper</h1>
  <img src="https://res.cloudinary.com/ewnqk3k9/image/upload/f_auto,q_auto/v1791153088/apify-actors/banners/youtube-comments-scraper-banner.png" alt="Fast HTTP-first YouTube comments scraper with threaded replies, sentiment, spam scores, and engagement analytics" align="center">
  <p align="center"><strong>Extract YouTube comments, threaded replies, author details, sentiment, spam scores, and video analytics at scale.</strong></p>
  <p align="center"><em>Direct HTTP InnerTube client · zero browser overhead · privacy-friendly public data</em></p>
  <p align="center">
    <a href="#quick-start"><img src="https://img.shields.io/badge/Quick_Start-Apify_Console-green?style=flat-square" alt="Quick Start"></a>
    <a href="https://apify.com"><img src="https://img.shields.io/badge/Runs_on-Apify-ff443e?style=flat-square" alt="Apify"></a>
    <a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node.js-%E2%89%A520-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node.js"></a>
  </p>
</p>

### Why this Actor?

| Feature | What you get |
|---|---|
| **Threaded Replies** | Complete discussion threads linked via `parentCommentId` with full nested hierarchy. |
| **Sentiment Analysis** | Pre-scored sentiment (`POSITIVE`, `NEUTRAL`, `NEGATIVE`) evaluated via deterministic lexicon analysis. |
| **Spam & Bot Detection** | Automated `spamScore` (0.00 to 1.00) detecting promotional spam, bot repetition, and suspicious links. |
| **Language Detection** | ISO 639-1 language tags (`en`, `id`, `es`, `ja`, etc.) on every comment for multilingual analysis. |
| **Influencer & Creator Badges** | Instant identification of verified accounts, channel owners (`isOwner`), and high-engagement influencers. |
| **Engagement Statistics** | Comprehensive per-video summary records with reply rate, sentiment distribution, and view/like ratios. |
| **Keyword & Metric Filtering** | Pre-filter comments by inclusion/exclusion keywords, language codes, and minimum like counts. |
| **Zero Browser Overhead** | Direct HTTP streaming architecture running on 256 MB memory with ultra-low compute unit consumption. |

### Quick start

1. Open **YouTube Comments Scraper** on Apify Console.
2. In the **YouTube Video URLs** field, enter one or more YouTube video URLs (e.g. `https://www.youtube.com/watch?v=dQw4w9WgXcQ`).
3. Click **Start** and monitor the live progress.
4. Export your clean dataset in **JSON**, **CSV**, or **Excel** format.

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 100,
  "includeReplies": true,
  "sort": "top"
}
```

### How it works

1. **Watch-Page Bootstrap:** Resolves video metadata and client tokens directly via lightweight HTTP GET requests.
2. **InnerTube Next Stream:** Streams top-level comment batches and threaded replies using native YouTube endpoints.
3. **Analytics Pipeline:** Enriches each comment with sentiment ratings, spam scores, language identification, and creator flags.
4. **Structured Delivery:** Pushes clean, buyer-focused records (`comment`, `video`, `stats`) to the Apify dataset in batched memory-safe flushes.

### Input parameters

#### Basic Input

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 500,
  "includeReplies": true
}
```

#### Full Input with Advanced Filtering

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 1000,
  "includeReplies": true,
  "maxRepliesPerComment": 50,
  "sort": "top",
  "concurrency": 2,
  "includeKeywords": ["song", "legend"],
  "excludeKeywords": ["subscribe", "check out my channel"],
  "languages": ["en"],
  "minLikes": 5
}
```

#### Input Fields Table

| Parameter | Type | Default | Description |
|---|---|---|---|
| `startUrls` | Array | *Required* | List of YouTube URLs (`watch?v=`, `/shorts/`, `/live/`, `youtu.be/`). Max 50 per run. |
| `maxComments` | Integer | `1000` | Maximum top-level comments to fetch per video (1 - 50,000). |
| `includeReplies` | Boolean | `true` | When enabled, fetches nested replies under each top-level comment. |
| `maxRepliesPerComment` | Integer | `50` | Maximum replies to fetch per comment thread (0 - 500). |
| `sort` | String | `"top"` | Comment sort order: `"top"` (popular comments) or `"newest"` (recent comments). |
| `concurrency` | Integer | `2` | Parallel video scraping workers (1 - 4). |
| `includeKeywords` | Array | `[]` | Filter to only export comments containing any of these keywords (case-insensitive). |
| `excludeKeywords` | Array | `[]` | Exclude comments containing any of these keywords. |
| `languages` | Array | `[]` | Filter by ISO language codes (e.g. `["en", "id", "es"]`). |
| `minLikes` | Integer | `null` | Export comments with at least this many likes. |

### Output data structure

The Actor pushes three clean record types into the default dataset:

#### 1. Comment Record (`recordType: "comment"`)

```json
{
  "recordType": "comment",
  "commentId": "Ugzge340dBgB75hWBm54AaABAg",
  "videoId": "dQw4w9WgXcQ",
  "parentCommentId": null,
  "text": "can confirm: he never gave us up",
  "publishedTime": "1 year ago",
  "publishedAt": null,
  "authorName": "@YouTube",
  "authorChannelId": "UCBR8-60-B28hp2BmDPdntcQ",
  "authorAvatarUrl": "https://yt3.ggpht.com/3s6evpqAiDU9tQR4sC2siJippbH2RWVPnwHgyl4V0th2iuQz0VDQZbUhQBGmsxLYo-mjG6TqZQ=s88-c-k-c0x00ffffff-no-rj",
  "isVerified": true,
  "isOwner": false,
  "isPinned": false,
  "isHearted": true,
  "likeCount": 323000,
  "replyCount": 962,
  "sentiment": "NEUTRAL",
  "spamScore": 0,
  "language": "en",
  "isInfluencer": true,
  "authorSubscribers": null,
  "status": "SUCCESS",
  "httpStatus": 200
}
```

#### 2. Video Metadata Record (`recordType: "video"`)

```json
{
  "recordType": "video",
  "videoId": "dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "channelName": "Rick Astley",
  "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "viewCount": 1823312249,
  "likeCount": 19000000,
  "commentCount": 2400000,
  "publishedAt": "2009-10-24T23:57:33-07:00",
  "durationSeconds": 213,
  "category": "Music",
  "status": "PARTIAL",
  "httpStatus": 200
}
```

#### 3. Engagement Summary Record (`recordType: "stats"`)

```json
{
  "recordType": "stats",
  "videoId": "dQw4w9WgXcQ",
  "fetched": 100,
  "totalComments": 2400000,
  "replyRate": 0.8,
  "sentimentPos": 17,
  "sentimentNeu": 82,
  "sentimentNeg": 1,
  "spamMean": 0.0095,
  "viewsPerComment": 18233122.49,
  "likesPerComment": 190000,
  "status": "PARTIAL"
}
```

### Cost, limits & performance

- **Compute Memory:** 256 MB (minimal tier).
- **Execution Speed:** Up to 100 comments per second via HTTP pipelining.
- **Compute Unit Efficiency:** Typically consumes under 0.002 CU per 1,000 comments.
- **Proxy Requirements:** None required for standard workloads.
- **Pagination Boundary:** YouTube anonymous endpoints reliably return up to ~1,200 comments per video. When this threshold is reached, runs are marked with `status: "PARTIAL"` to inform data pipelines accurately.

### Recipes

#### Recipe 1: Brand Sentiment & Competitor Audit

Analyze viewer perception on competitor product reviews or announcements:

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 1000,
  "sort": "top",
  "includeReplies": true
}
```

#### Recipe 2: Influencer & Community Creator Discovery

Identify high-impact commenters and verified channel creators in your niche:

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 500,
  "minLikes": 25,
  "includeReplies": false
}
```

#### Recipe 3: Multilingual Campaign Monitoring

Track English and Indonesian feedback while filtering out promotional bot spam:

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 800,
  "languages": ["en", "id"],
  "excludeKeywords": ["t.me/", "whatsapp", "crypto", "free gift"]
}
```

### Troubleshooting

| Status | HTTP Code | Cause & Recommended Action |
|---|---|---|
| `NOT_FOUND` | `404` | Video does not exist, is private, or has been removed. Check the input URL. |
| `PARTIAL` | `200` | Requested comment cap reached or YouTube anonymous pagination threshold encountered. Scraped rows remain valid. |
| `BLOCKED` | `403` / `429` | Temporary YouTube rate limiting. Lower concurrency or pause before re-running. |
| `ERROR` | `400` / `500` | Invalid URL format or internal network failure. Verify URL allowlist. |

### Frequently asked questions (FAQ)

#### 1. Does this scraper require a YouTube API key or login account?

No. The scraper accesses publicly available YouTube data without requiring an API key, Google login, or browser session cookies.

#### 2. How many comments can I extract per video?

You can request up to 50,000 comments. Due to YouTube's public pagination boundaries, anonymous streams generally reach up to approximately 1,200 top-level comments and replies. The scraper marks capped runs as `PARTIAL` without dropping existing records.

#### 3. Can I export comments in CSV format?

Yes. Apify Console allows instant downloads in CSV, JSON, Excel, and XML formats. The dataset schema includes pre-flattened fields specifically optimized for spreadsheet analysis.

#### 4. How does the sentiment and spam analysis work?

Sentiment and spam analysis run locally in-memory during extraction using specialized linguistic lexicons. They do not make external API calls, ensuring high execution speed and zero extra latency.

#### 5. Is it safe and compliant for commercial use?

The Actor extracts only publicly visible data without bypassing authentication walls or accessing private user profiles, following Apify's standard compliance guidelines.

### Run on Apify Console

Start extracting comments immediately on the [Apify Platform](https://apify.com).

### License

Proprietary. All Rights Reserved. Copyright (c) 2026 REXREUS. See [LICENSE](file:///LICENSE) for full legal terms.

# Actor input Schema

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

One or more YouTube video URLs (watch?v=, /shorts/, /live/, or youtu.be/<id>). Maximum 50 videos per run.

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

Maximum number of top-level comments to fetch per video (1 - 50,000). YouTube anonymous pagination typically caps around 1,200 comments; the actor marks capped runs PARTIAL.

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

Fetch threaded replies under each top-level comment.

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

Maximum replies to fetch per comment thread (0 - 500).

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

Sort order of comments: 'top' (top comments) or 'newest' (newest first).

## `concurrency` (type: `integer`):

Number of videos processed in parallel (1 - 4). Internal delay between requests respects YouTube limits.

## `includeKeywords` (type: `array`):

Only export comments containing at least one of these keywords (case-insensitive, max 100).

## `excludeKeywords` (type: `array`):

Drop comments containing any of these keywords (case-insensitive, max 100).

## `languages` (type: `array`):

Only export comments detected in these languages (ISO 639-1 / BCP-47 codes: 'en', 'id', 'es', 'fr', 'de', 'pt', 'ja', 'ko', 'zh', etc.).

## `minLikes` (type: `integer`):

Only export comments with at least this many likes. Comments with unstated likes are excluded when set.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "maxComments": 1000,
  "includeReplies": true,
  "maxRepliesPerComment": 50,
  "sort": "top",
  "concurrency": 2
}
```

# Actor output Schema

## `dataset` (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 = {
    "startUrls": [
        {
            "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rexreus/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 = { "startUrls": [{ "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }] }

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

```

## MCP server setup

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