# YouTube Comments Scraper — Top, Newest & Replies (`datamule/youtube-comments-scraper`) Actor

First delivered comment: $0.0005; additional comments/replies: $0.000165 each. Export public YouTube comment text, author IDs and reply threads. Top/newest sorting, global output and spending caps. Zero-result runs have no Actor event charges.

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

## Pricing

from $0.17 / 1,000 additional 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.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## YouTube Comments Scraper — Comments & Replies

Export public YouTube comments and reply threads for audience research and content analysis. No API key or login required. Get comment text, author/channel IDs, parent IDs, source timestamps and URLs in JSON, CSV or Excel.

**Pricing per run: first delivered comment $0.0005; each additional comment $0.000165 ($0.165 per 1,000 additional comments).** This is NOT a flat per-comment rate. The first delivered comment includes a small fixed-compute premium. Comments and replies are billed identically. Runs delivering zero comments incur no Actor event charges; partial successful results remain billable if later extraction fails.

| Delivered comments and replies | Total Actor charge (USD) |
|---:|---:|
| 0 | $0 |
| 1 | $0.000500 |
| 10 | $0.001985 |
| 100 | $0.016835 |
| 1,000 | $0.165335 |
| 10,000 | $1.650335 |

The first-comment event replaces—not adds to—the regular comment event for that row. There is no charge merely for starting a run. Set `maxComments` and a **positive** Apify maximum-charge amount to control spending; a positive budget below $0.0005 delivers no rows. **Do not enter zero as the Apify maximum charge:** the platform treats zero as an unset limit and substitutes its default/account allowance. For a zero-output spending gate, use a positive limit below the first-comment price (for example $0.000499).

### Quick start

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

Use `sort: "newest"` for recent audience feedback or `includeReplies: true` for bounded thread context. Analyze exported text in your own workflow; this Actor does not invent sentiment scores, leads or inferred personal attributes.

### Input and coverage

- `videoUrls`: 1–10 HTTPS YouTube video URLs or 11-character IDs. Duplicate videos are deduplicated. Shorts/live URLs are accepted, but livestream chat is not supported.
- `maxComments`: integer 1–10,000, default 100; a **global** hard cap across all videos and replies, not per video. Inputs are processed sequentially; the first video may consume the cap. No unlimited mode.
- `sort`: `top` (default) or `newest`. The source may put a pinned comment first even in newest mode. There is no chronological sorting of relative dates by this Actor.
- `includeReplies`: false by default. When true, each page of top-level comments is emitted before following its reply threads in source order; a popular first thread may consume the remaining cap. Comments and replies count equally toward the cap and price.

### Output and provenance

Every row retains the source `commentId`, requested `videoId`, explicit `parentCommentId` for replies, and `commentUrl`. `publishedTimeText` is the exact relative source string; `publishedAt` is null because this source does not provide an absolute posting date. `scrapedAt` is the actual UTC observation time, **not** posting time. `likeCountText` and `replyCountText` retain source display values; numeric fields are null for rounded values such as `312K`.

### Limits and diagnostics

Uses the anonymous YouTube WEB comments surface. It is undocumented and may change, block cloud IPs, omit comments, or personalize ranking. No completeness or continuous-availability guarantee is made. No retries, proxy rotation or access-control workarounds. Age-gated, private, unavailable, restricted and members-only sources are out of scope.

`SUMMARY` in the default key-value store describes videos and stop reasons. Explicit comments-disabled responses produce no dataset row and no event. Unavailable/restricted/unrecognized sources fail rather than look like an empty success. Partial rows may remain after failure; inspect run status and SUMMARY. Mixed unavailable input fails after preserving valid rows.

Finite safety bounds: 150 HTTP requests, 8 MB decoded per response, 80 MB decoded total and 240 seconds of extraction per process lifetime; platform timeout 300 seconds. A safety-limit failure is not source exhaustion. Failed storage/charging calls propagate; they are never swallowed. Diagnostic records are not billed comments.

On restart, physical dataset rows restore the global cap and dedupe keys. Paid runs also reconcile stored event counts; ambiguous billing/storage history fails for operator review instead of replaying charges. Storage and charging are not a distributed exactly-once transaction. Do not blindly resurrect a failed run; inspect its records first.

Independent implementation; not affiliated with YouTube or Google. Use public content lawfully and respect privacy and platform terms.

# Actor input Schema

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

1–10 public YouTube video URLs or IDs. Global cap across videos.

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

Hard cap including replies, across all videos. No unlimited mode.

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

YouTube source order. Pinned comments may lead newest.

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

Follow reply threads; replies count toward global cap.

## Actor input object example

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

# 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"
    ],
    "maxComments": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("datamule/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=dQw4w9WgXcQ"],
    "maxComments": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("datamule/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=dQw4w9WgXcQ"
  ],
  "maxComments": 100
}' |
apify call datamule/youtube-comments-scraper --silent --output-dataset

```

## MCP server setup

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