# Youtube Comment Scraper (`scrapeai/youtube-comment-scraper`) Actor

Extract YouTube comments from one or more videos without API limits. Get full comment text, date, author, video title, and video ID. Download results in JSON, CSV, or Excel.

- **URL**: https://apify.com/scrapeai/youtube-comment-scraper.md
- **Developed by:** [ScrapeAI](https://apify.com/scrapeai) (community)
- **Categories:** Videos, Social media, Developer tools
- **Features:** Full permissions
- **Stats:** 1 total users, 0 monthly users, 96.4% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $2.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Comment Scraper

Collect real public **top-level YouTube comments** using anonymous watch-page JSON and native comment continuations. Exact video IDs, comment entities and rendered thread keys are bound together. No source scripts, login, browser cookies, challenge solving or identity rotation.

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "outputMode": "comments",
  "maxComments": 10,
  "maxItems": 10,
  "sort": "top",
  "maxConcurrency": 2,
  "minDelayBetweenRequestsMs": 1000,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

Use `apify run --input-file input.json`. Local storage is separate from production; cloud runs obtain fresh native responses.

### Input and limits

`videoUrls` accepts 1–50 public watch/youtu.be/shorts/embed/live URLs; video aliases are deduplicated. `maxComments` is a per-video ceiling (default100, max10,000). The smallest supplied root/nested `maxItems`, `maxResults` or `limit` is the global record cap (default10,000). Legacy `actorInput` accepts the same native fields; explicit root fields win and schema prefills do not mask nested input.

`sort` is `top` (default) or the source's **Newest first** selector. `maxPagesPerVideo` limits native pages (default30/max100). `maxConcurrency` bounds concurrent videos (default2/max5); starts are globally spaced by `minDelayBetweenRequestsMs` (default1,000/minimum300). Output preserves input/native order. The HTTP runtime has no browser/headless setting and does not retry failed source requests. Optional proxy configuration uses one fixed session without silent fallback to another route.

### Output modes and fields

**`videos` preserves the legacy default:** one video object containing a `comments` array. A single supplied video produces at most one video record. `commentCount` is the number collected; separate `totalCommentCount`/`totalCommentCountText` preserve the source total when observed.

**`comments` is explicit flat output:** one distinct native comment ID per record with its video metadata. The example local input requests this mode. `commentPosition` is the collected position within that video. The global cap can stop output before the immutable snapshot is exhausted; no extra entities are added to fill a cap.

Video fields include native video/channel IDs, title, channel name/URL, available publication/upload date strings, description, thumbnails, exact source views and duration seconds. Native date representations are not given invented timestamp precision. Video likes are omitted until an exact native count is supported.

Comment fields include ID, author name/channel ID/source-bound handle URL, avatar URL, original text, native relative `publishedTime`, observed verification/creator flags, engagement labels and direct comment URL. **70K stays a label** in `likeCountText`; numeric `likeCount` is included only for an exact integer. Reply counts use the same rule. Unknown fields stay absent; observed zero/false survive. Relative dates are not converted to guessed timestamps. Only `replyLevel=0` is fetched: replies and private/authenticated/moderated views are outside this public-comment scope.

`hasMoreComments` means a source continuation or unconsumed comments remain in the fetched page. Exhausted public sources can yield fewer than a requested ceiling. Missing/disabled comments, ID mismatch, source errors or an incomplete requested video fail explicitly; they do not produce fake rows or a full-success claim.

### Evidence and resume

`SOURCE_WATCH_<videoId>` preserves public native metadata. `SOURCE_COMMENTS_<videoId>_<page>` preserves sanitized comment entities, thread-key bindings, source count/sort labels and continuation hashes. Visitor/logging state, cookies and routing tokens are not exported/stored in receipts. Only public client-version and anonymous continuation fields are used in memory.

`NATIVE_SNAPSHOT` checkpoints the completed scan before dataset publication. Same-input `apify run --no-purge` resumes that immutable snapshot and deduplicates rows without new source requests. Changed resume input is rejected; fresh storage starts a fresh live scan. `RUN_SUMMARY` records mode, sort, video/page coverage and diagnostics.

Apify compute/storage and optional proxy usage incur the account's ordinary charges. Source availability can change. The Actor reads public comments and never posts, reacts, subscribes or sends messages.

# Actor input Schema

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

Watch, youtu.be, shorts, embed or live aliases. Canonical video IDs are deduplicated.

## `outputMode` (type: `string`):

videos (legacy default) returns one video object with a comments array; comments returns one record per genuine comment with video metadata.

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

top or the source-published newest selector. Replies are not fetched.

## `actorInput` (type: `object`):

Same native fields; explicit root fields win and the smallest root/nested global cap applies.

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

Direct public HTTP by default. Optional one fixed configured proxy session for this run. No silent route fallback or identity rotation.

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

Maximum real top-level comments per supplied video; no padding.

## `maxItems` (type: `integer`):

Global record ceiling for selected output mode; no filler.

## `maxPagesPerVideo` (type: `integer`):

Bounded native runtime setting.

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

Bounded native runtime setting.

## `minDelayBetweenRequestsMs` (type: `integer`):

Bounded native runtime setting.

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

Bounded native runtime setting.

## `limit` (type: `integer`):

Bounded native runtime setting.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "outputMode": "comments",
  "sort": "top",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxComments": 100,
  "maxItems": 10000,
  "maxPagesPerVideo": 30,
  "maxConcurrency": 2,
  "minDelayBetweenRequestsMs": 1000,
  "maxResults": 10000,
  "limit": 10000
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (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=dQw4w9WgXcQ"
    ],
    "outputMode": "comments",
    "sort": "top",
    "proxyConfiguration": {
        "useApifyProxy": false
    },
    "maxComments": 100,
    "maxItems": 10000,
    "maxPagesPerVideo": 30,
    "maxConcurrency": 2,
    "minDelayBetweenRequestsMs": 1000,
    "maxResults": 10000,
    "limit": 10000
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeai/youtube-comment-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=dQw4w9WgXcQ"],
    "outputMode": "comments",
    "sort": "top",
    "proxyConfiguration": { "useApifyProxy": False },
    "maxComments": 100,
    "maxItems": 10000,
    "maxPagesPerVideo": 30,
    "maxConcurrency": 2,
    "minDelayBetweenRequestsMs": 1000,
    "maxResults": 10000,
    "limit": 10000,
}

# Run the Actor and wait for it to finish
run = client.actor("scrapeai/youtube-comment-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=dQw4w9WgXcQ"
  ],
  "outputMode": "comments",
  "sort": "top",
  "proxyConfiguration": {
    "useApifyProxy": false
  },
  "maxComments": 100,
  "maxItems": 10000,
  "maxPagesPerVideo": 30,
  "maxConcurrency": 2,
  "minDelayBetweenRequestsMs": 1000,
  "maxResults": 10000,
  "limit": 10000
}' |
apify call scrapeai/youtube-comment-scraper --silent --output-dataset

```

## MCP server setup

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