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

Scrape comments and replies from YouTube videos and Shorts: text, author, likes, reply count, pinned and creator-hearted flags. Top or newest first. No API key needed.

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

## Pricing

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

Scrapes comments, and optionally replies, from YouTube videos and Shorts. Each comment has its text, author, like and reply counts, pinned and creator-hearted flags, plus the video's title and exact total comment count. No YouTube API key or quota is needed.

For a quick one-off check without an Apify account, a free web version with a small daily limit is available at [purfled.com/youtube-comments-export](https://purfled.com/youtube-comments-export/).

### Input

| Field | Description |
|---|---|
| `videos` | Video URLs (`watch?v=`, `youtu.be/`, `/shorts/`, `/live/`) or video IDs. Several URLs on one line separated by spaces are split. |
| `maxCommentsPerVideo` | Top-level comments per video. Default 100. |
| `sort` | `top` (YouTube's default ranking) or `newest`. |
| `includeReplies` | Also collect replies. Default `false`. |
| `maxRepliesPerComment` | Reply limit per comment when replies are included. Default 20. |

```json
{
  "videos": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "maxCommentsPerVideo": 500,
  "sort": "newest",
  "includeReplies": true,
  "maxRepliesPerComment": 10
}
```

### Output

Example from a real run:

```json
{
  "videoId": "jNQXAC9IVRw",
  "videoTitle": "Me at the zoo",
  "videoCommentCount": 10643771,
  "input": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "commentId": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "parentCommentId": null,
  "isReply": false,
  "text": "We're so honored that the first ever YouTube video was filmed here!",
  "author": "@SanDiegoZoo",
  "authorChannelId": "UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "authorIsVerified": true,
  "authorIsChannelOwner": false,
  "likes": 4800000,
  "replyCount": 986,
  "publishedTimeText": "6 years ago",
  "publishedAtApprox": "2020-10-25T00:39:38.215Z",
  "isEdited": false,
  "isPinned": true,
  "isHeartedByCreator": true,
  "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw&lc=UgzuC3zzpRZkjc5Qzsd4AaABAg"
}
```

Field notes:

- `videoCommentCount` is the exact total YouTube shows above the comments (including replies).
- Replies have `isReply: true` and `parentCommentId` set.
- YouTube shows only relative times ("3 days ago"), so `publishedAtApprox` is an estimate.
- Comment `likes` above 1,000 are rounded by YouTube (for example 4.8M).
- With `sort: "newest"`, a pinned comment still comes first, as on YouTube.

Errors: a video that cannot be scraped gives one item with `videoId`, `input` and an `error`, and the run carries on with the other videos. Error items are not charged. The messages are:

- "Comments are turned off for this video"
- "Live streams have live chat, not comments"
- "Age-restricted: comments need sign-in"
- "Video not found, private or removed"
- "Not a YouTube video URL or ID"
- "This video has no comments yet"

### API usage

```bash
curl -X POST "https://api.apify.com/v2/acts/solarg~youtube-comments-scraper/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videos": ["jNQXAC9IVRw"], "maxCommentsPerVideo": 200}'
```

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("solarg/youtube-comments-scraper").call(run_input={"videos": ["jNQXAC9IVRw"], "maxCommentsPerVideo": 200})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

### Pricing

$0.30 per 1,000 comments (replies count as comments). Error items are free. Apify paid plans get lower prices: 10% off on Bronze, 20% on Silver and 30% on Gold and above. Platform usage is included in the price.

### Limitations

- Comment order and availability are what YouTube shows publicly. Held-for-review and deleted comments are not visible.
- Very large videos can take several minutes per 10,000 comments.

Report problems in the Issues tab.

# Actor input Schema

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

YouTube video URLs (watch, youtu.be, Shorts, live) or 11-character video IDs.

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

Top-level comments to collect per video (replies are counted separately).

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

Order in which comments are collected: YouTube top comments or newest first.

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

Also collect replies to each comment.

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

Maximum replies to collect under each top-level comment. Only used when replies are included.

## Actor input object example

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxCommentsPerVideo": 50,
  "sort": "top",
  "includeReplies": false,
  "maxRepliesPerComment": 20
}
```

# Actor output Schema

## `comments` (type: `string`):

Comments and replies in table form (the Comments view).

## `results` (type: `string`):

Every item in the default dataset, including error items.

# 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": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "maxCommentsPerVideo": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("solarg/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": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxCommentsPerVideo": 50,
}

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

```

## MCP server setup

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