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

Scrape YouTube comments and replies from videos, Shorts, playlists and channels: text, likes, reply count, author, pinned and hearted flags. Sort by top or newest. Pay per comment.

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

## Pricing

$0.40 / 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?

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

Scrape the **comments and replies** of YouTube videos, Shorts, playlists and channels. Each comment comes with its **text, likes, reply count, author, verified and channel-owner badges, and pinned and hearted flags**. You can sort by **top comments** or **newest first**. Use the data for audience research, sentiment analysis, product feedback, community management, or as training and RAG data for AI.

You pay per comment. Proxies are included.

### Features

- **Any source:** videos, Shorts, `youtu.be` links, playlists and channels (their latest videos).
- **Sort:** top comments or newest first, the same as on YouTube.
- **Replies:** optional, with `parentCommentId` linking each reply to its comment.
- **Rich fields:** likes, reply count, pinned, hearted by the creator, edited, author verified, author is the channel owner.
- **Reliable:** blocked requests are retried with fresh proxy sessions, and residential IPs take over automatically.

### Input example

```json
{
  "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "maxComments": 500,
  "sortBy": "top",
  "includeReplies": true,
  "maxRepliesPerComment": 10
}
```

### Output example

```json
{
  "status": "ok",
  "videoId": "jNQXAC9IVRw",
  "videoTitle": "Me at the zoo",
  "totalComments": 10644455,
  "commentId": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw&lc=UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "text": "We're so honored that the first ever YouTube video was filmed here! …",
  "author": "@SanDiegoZoo",
  "authorChannelId": "UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "authorIsVerified": true,
  "authorIsChannelOwner": false,
  "likeCount": 4800000,
  "replyCount": 986,
  "publishedTimeText": "6 years ago",
  "isEdited": false,
  "isPinned": true,
  "isHeartedByCreator": true,
  "replyLevel": 0
}
```

A reply has `replyLevel: 1` and `parentCommentId` set.

### Notes

- YouTube shows rounded like counts for popular comments (for example `4.8M`), so `likeCount` is rounded the same way.
- Dates are relative, as on YouTube (for example `6 years ago`). Set **Interface language** to get them in another language.
- Videos with comments turned off appear once with `status: "no-comments"` and are not charged.

### Pricing

You pay a fixed price per comment or reply. Proxies are included. Set a maximum cost per run in the run options, and the Actor stops when it is reached.

### More YouTube tools by the same author

- **YouTube Scraper:** search results, channels, playlists and video stats.
- **YouTube Transcript Scraper:** transcripts, SRT and translations.

### Is scraping YouTube comments legal?

Comments are public, but they contain personal data such as usernames. Process them only for legitimate purposes, in line with GDPR and the other laws and terms that apply to you.

### Feedback

Found a bug or need another field? Open an issue on the **Issues** tab.

# Actor input Schema

## `urls` (type: `array`):

Videos, Shorts, playlists or channels. For playlists and channels, the latest videos are used.

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

Top-level comments. Replies are counted separately.

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

Same as the sort menu above YouTube comments.

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

Adds the replies to each comment, with parentCommentId set.

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

Only when replies are included.

## `maxVideosPerSource` (type: `integer`):

Channels use their latest uploads.

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

Language of relative dates such as "2 days ago", for example en, de, uk.

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

Higher is faster, but YouTube blocks more requests, so more of them are retried.

## `maxAttempts` (type: `integer`):

Each blocked request is retried with a new proxy session.

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

Apify Proxy is used by default. Residential IPs take over automatically when YouTube blocks a request. Proxy costs are included in the price.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxComments": 100,
  "sortBy": "top",
  "includeReplies": false,
  "maxRepliesPerComment": 20,
  "maxVideosPerSource": 10,
  "language": "en",
  "maxConcurrency": 4,
  "maxAttempts": 6,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All comments.

## `overview` (type: `string`):

The overview view of the dataset.

# 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 = {
    "urls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("deadmist/youtube-comments").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 = {
    "urls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("deadmist/youtube-comments").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 '{
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call deadmist/youtube-comments --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,deadmist/youtube-comments"
        }
    }
}
```

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/8RgAup8hWZ1xhuPSL/builds/7uie2FzFt2nMhwIix/openapi.json
