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

Scrape YouTube comments and their replies with no API key or quota. Returns comment text, author name and channel, like count, reply count, publish time, and pinned or creator-hearted markers. Sort by top or newest using YouTube's own ordering, and page as deep as you need.

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

## Pricing

from $0.35 / 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.

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

Scrapes the comment section of YouTube videos in bulk. Give it a list of videos
and it returns one row per comment, with the author, the like count, the
published time, and the pin and heart markers the site shows.

### Input

| Field | Type | Notes |
|---|---|---|
| `videoIds` | array | Bare IDs, watch URLs, `youtu.be` links, or `/shorts/` links. Mixed input is fine. |
| `maxComments` | integer | Per video, default 100. Replies count towards this budget when enabled. |
| `sortBy` | string | `top` (default) or `newest`. This selects YouTube's own sort, not a local re-sort. |
| `includeReplies` | boolean | Off by default. Expands the reply thread under each top-level comment. |
| `proxyConfiguration` | object | Recommended. YouTube refuses datacenter addresses with a bot check. |

### Output

One dataset item per comment:

```json
{
  "comment_id": "Ugzge340dBgB75hWBm54AaABAg",
  "video_id": "dQw4w9WgXcQ",
  "text": "can confirm: he never gave us up",
  "author_name": "@YouTube",
  "author_channel_id": "UCBR8-60-B28hp2BmDPdntcQ",
  "author_avatar_url": "https://yt3.ggpht.com/...=s88-c-k-c0x00ffffff-no-rj",
  "author_is_verified": true,
  "author_is_creator": false,
  "like_count_text": "305K",
  "like_count": 305000,
  "published_time_text": "1 year ago",
  "is_reply": false,
  "parent_comment_id": null,
  "is_hearted": true,
  "hearted_by": "❤ by @RickAstleyYT",
  "is_pinned": true,
  "pinned_by_text": "Pinned by @RickAstleyYT",
  "reply_count_text": "963",
  "reply_count": 963
}
```

Replies carry `is_reply: true` and `parent_comment_id` set to the id of the
top-level comment they answer.

### What the source does and does not give

- **Like counts are abbreviated at the source.** YouTube renders `305K`, never
  the exact number. `like_count_text` is that string verbatim and `like_count`
  is it expanded, so anything above a thousand is rounded by YouTube before we
  ever see it. The exact figure is not available at any public endpoint.
- **Published times are relative.** `published_time_text` is `"1 year ago"`,
  which is all the response carries. No absolute timestamp is exposed, so none
  is invented.
- **There is no separate "channel owner liked" signal.** YouTube's creator
  acknowledgement is the heart, and that is what `is_hearted` and `hearted_by`
  report. A comment can be pinned without being hearted and the other way
  round, so both markers are emitted separately.
- **Anything missing is `null`**, never `0` and never `""`. A zero in a dataset
  reads as a measurement.
- **Comments turned off is a normal outcome, not an error.** The video is
  skipped, the reason is written to the run log, and nothing is charged for it.
  The same holds for videos that no longer exist.

### Charging

One `comment-scraped` event per comment after it has been written to the
dataset, plus one `actor-start` per run. Comment ids are de-duplicated across
pages before anything is charged, so a comment repeated by YouTube across a page
boundary is never billed twice.

### How it works

Comments are not on the watch page. They come from YouTube's InnerTube `next`
endpoint in two steps: the first response for a video carries only a
continuation token, hidden in the `itemSectionRenderer` whose
`sectionIdentifier` is `comment-item-section`; posting that token back to the
same endpoint returns the first page of comments and the token for the next. The
sort submenu in the comment engagement panel supplies a different starting token
for `top` and for `newest`, which is how `sortBy` is honoured.

If YouTube changes that shape, the live contract test under `tests/contract/` is
what will say so.

# Actor input Schema

## `videoIds` (type: `array`):

Bare video IDs, watch URLs, youtu.be links, or /shorts/ links. Mixed input is fine, and each entry is scraped independently.

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

How many comments to return for each video before moving on to the next one. Replies count towards this budget when they are enabled. Default 100.

## `sortBy` (type: `string`):

Which order YouTube should return comments in. 'top' is the default the site itself shows; 'newest' returns the most recent comments first.

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

Also expand the reply thread under each top-level comment. Replies are marked with isReply and carry the id of the comment they answer. Off by default because replies consume the same per-video budget.

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

Recommended. YouTube refuses datacenter addresses with a bot check, and a residential address clears it.

## Actor input object example

```json
{
  "videoIds": [
    "dQw4w9WgXcQ"
  ],
  "maxComments": 100,
  "sortBy": "top",
  "includeReplies": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `comments` (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 = {
    "videoIds": [
        "dQw4w9WgXcQ"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("superslowsloth/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 = {
    "videoIds": ["dQw4w9WgXcQ"],
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

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