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

YouTube comments scraper, $0.30 per 1,000: public comments and replies with video metadata, numeric likes and parent thread links. Choose Top or Newest, download JSON or CSV, and keep raw display counts plus approximate dates. No API key, login or per-query fee.

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

## Pricing

from $0.15 / 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

For keyword search, channel uploads, Shorts and video metadata, use [YouTube Scraper](https://apify.com/sumitr_mardy/youtube-scraper).

Export **public YouTube comments and replies** with video metadata on every row. Choose **Top** or **Newest**, get numeric likes alongside raw display strings, and link replies to their parent with parentCommentId.

This independent actor is **not affiliated with or endorsed by YouTube or Google**. No API key, login, cookies or account token is required.

### Quick start

```json
{
  "videos": ["dQw4w9WgXcQ"],
  "maxComments": 100,
  "sort": "top",
  "includeReplies": false,
  "language": "en"
}
```

Download the dataset as JSON, CSV or Excel. Use it for public feedback analysis, discussion research or your own monitoring workflow.

### Input

| Field | Default | Behavior |
|---|---|---|
| videos | Required | 11-character ids, youtube.com/watch URLs, youtu.be links, shorts URLs, m.youtube.com or music.youtube.com URLs. Up to 100 videos; duplicates removed by id. |
| maxComments | 100 | Maximum saved comments per video, from 1 to 100,000. Includes replies when enabled. |
| sort | top | top or newest parent-comment order. |
| includeReplies | false | Fetch reply pages and link them to parent comments. |
| language | en | YouTube UI language (hl), affecting labels such as relative publication times. English recommended for date parsing. |

The daily Store example requests 20 top-level comments from one video, normally two JSON requests.

### Replies and limits

The actor saves a parent-comment page, then opens its reply threads before moving to the next parent page. The same maxComments limit includes parents and replies. A large first thread can fill a small limit before later threads are opened. Reply order comes from YouTube and is not independently sorted.

Deduplication is by commentId within each video. Pagination uses separate top-level and reply continuations; reply tokens are not treated as the next parent page. If a later page fails, saved comments remain and a free terminal failure row explains the stop.

### Output

One flat row per saved comment or reply. Missing strings are "", numbers 0 and booleans false. All keys are always present, never null.

| Fields | Meaning |
|---|---|
| inputIndex, input | Original video input position/value. |
| videoId, videoUrl, videoTitle | Normalized video metadata copied onto every row. |
| totalCommentsText | YouTube's header count as displayed, not a promise of returned rows. |
| commentId, commentUrl, text | Public comment identity, watch-page link with lc parameter and text. |
| authorName, authorChannelId, authorChannelUrl | Public display name and channel link. |
| isCreator, isVerified | Whether YouTube marks the author as video creator or verified. |
| likeCount, likeCountText | Numeric interpretation and raw displayed likes, including rounded K/M abbreviations. |
| replyCount, replyCountText | Displayed reply count and its raw string. |
| isReply, parentCommentId | Reply flag and parent id; parent id is empty for top-level comments. |
| publishedTimeText | YouTube's relative time label, preserved exactly. |
| publishedAtApprox, isEdited | Approximate UTC ISO date, and whether the label contains (edited). |
| sort | Requested parent-comment sort. |
| status, subStatus, error, scrapedAt | Result status, machine-readable detail, error and UTC ISO collection timestamp. |

### Dates and counts are approximate

YouTube supplies relative labels such as "7 years ago", not an exact comment timestamp. publishedAtApprox is calculated from scrape time. Months use 30 days and years 365 days, so it is suitable for rough ordering, not exact chronology. Unrecognized localized labels leave publishedAtApprox empty; publishedTimeText is always retained.

Like counts are rounded exactly as YouTube displays them: 70K becomes 70000 and 1.2M becomes 1200000. This does not recover an undisplayed exact count. Missing or unsupported count labels use 0 with the original string retained.

YouTube's header count may include comments that its public feed does not expose. The actor can return fewer than requested even when the header is larger. A platform spike requested up to 500 top comments on each of three videos and returned 500, 500 and 370; the recent video's continuation ended despite a larger header count.

### Pricing and statuses

One **comment** event per saved successful comment or reply. FREE $0.0003, BRONZE $0.00025, SILVER $0.0002, GOLD and above $0.00015 per row ($0.30 / $0.25 / $0.20 / $0.15 per 1,000). Replies have the same price.

Standard Actor start fee: $0.00005 per GB, minimum one event. There is no per-query fee or separate reply surcharge. Failed and empty rows have no comment charge; the start event still applies. No extra dataset-item event.

The actor saves a page batch before charging and honors the event spending cap.

| status / subStatus | Comment charge |
|---|---|
| ok / comment | Yes |
| no_comments / comments_disabled | No; video exists but has no comment continuation |
| no_comments / empty | No; comment feed returned no visible comments |
| failed / invalid_input, not_found | No |
| failed / http_CODE, blocked, parse_error, network_error | No |
| failed / free_work_limit | No; internal unpaid-work guard stopped collection |
| failed / cost_limit_reached | No; event spending cap reached |

### Honest limits

- Public comments only. No private videos, logged-in account data, deleted-comment recovery or authenticated access.
- Comments and replies can be hidden, moderated, removed, reordered or unavailable by region. No guarantee of every historical comment or full threads.
- YouTube can change its public web JSON format or rate-limit requests. Two videos run concurrently, with each video's page requests sequential.
- The actor uses the public watch-page JSON endpoint without an API key. It starts with a known WEB client version and refreshes that version once from public sw.js_data only after HTTP 400; no login token or cookie is extracted.
- A 403/429 or explicit bot notice gets one direct retry after backoff, then at most one Apify datacenter proxy attempt if available. Never residential, browser collection, fingerprint tricks or account cookies.
- Every request has a hard deadline. A free-work guard bounds repeated failures. The platform can also impose account-level spending limits.
- English UI labels give the most predictable relative-date parsing. Raw labels are preserved for other languages.
- No sentiment classification or private author/contact enrichment is performed.

### API examples

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/sumitr_mardy~youtube-comments-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videos":["dQw4w9WgXcQ"],"maxComments":20,"includeReplies":false}'
```

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("sumitr_mardy/youtube-comments-scraper").call(
    run_input={"videos": ["dQw4w9WgXcQ"], "maxComments": 20}
)
for comment in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(comment["text"], comment["likeCount"], comment["parentCommentId"])
```

### Use it from AI agents (MCP)

Hosted OAuth clients can sign in through [Apify MCP](https://mcp.apify.com/?tools=sumitr_mardy/youtube-comments-scraper):

```json
{"mcpServers":{"youtube-comments":{"url":"https://mcp.apify.com/?tools=sumitr_mardy/youtube-comments-scraper"}}}
```

Bearer clients can use local secret configuration:

```json
{"mcpServers":{"youtube-comments":{"url":"https://mcp.apify.com/?tools=sumitr_mardy/youtube-comments-scraper","headers":{"Authorization":"Bearer <YOUR_APIFY_TOKEN>"}}}}
```

For stdio clients with Node.js:

```json
{"mcpServers":{"youtube-comments":{"command":"npx","args":["-y","@apify/actors-mcp-server","--actors","sumitr_mardy/youtube-comments-scraper"],"env":{"APIFY_TOKEN":"<YOUR_APIFY_TOKEN>"}}}}
```

Agent tips: begin with 20 comments, check status, distinguish raw counts and approximate values, and use parentCommentId when rebuilding threads. Configure your own schedule for recurring monitoring and deduplicate by videoId + commentId.

Support: [Actor issues](https://apify.com/sumitr_mardy/youtube-comments-scraper/issues).

For public channel profiles, subscriber/view totals, creator links, keyword discovery and recent upload activity, use [YouTube Channel Info Scraper](https://apify.com/sumitr_mardy/youtube-channel-info). Business email is a prompt-presence boolean only; no addresses are revealed.

# Actor input Schema

## `videos` (type: `array`):

Video ids or YouTube watch,shorts,youtu.be,mobile/music URLs. Up to100 videos, deduplicated by id.

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

Maximum saved comments per video, including replies. Actual visible comments can be fewer than YouTube header count.

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

Top or Newest parent-comment order. Reply order is supplied by YouTube.

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

Follow reply pages; replies count toward maxComments and link to parentCommentId. A small limit can be filled by one thread.

## `language` (type: `string`):

YouTube UI language(hl). English recommended for relative-date parsing; raw labels are always preserved.

## Actor input object example

```json
{
  "videos": [
    "dQw4w9WgXcQ"
  ],
  "maxComments": 20,
  "sort": "top",
  "includeReplies": false,
  "language": "en"
}
```

# 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 = {
    "videos": [
        "dQw4w9WgXcQ"
    ],
    "maxComments": 20
};

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

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

```

## MCP server setup

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