# YouTube Comments Scraper — Comments & Replies Export (`leadsbrary/youtube-comments-replies-export`) Actor

YouTube comments scraper that exports comments and full reply threads from videos, Shorts, playlists and channels: text, author, likes, parentId, pinned/hearted flags, time estimate. JSON, CSV, Excel. From $0.20 per 1,000 results.

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

## Pricing

from $0.20 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 — Comments & Replies Export

### What does it do?

#### Overview

This YouTube comments scraper collects the public comments **and their reply threads** from YouTube videos, Shorts, playlists and channels, and returns one flat row per comment or reply. Every row links back to its parent (`parentId`, `threadDepth`), so conversations are easy to rebuild. Results can be downloaded as JSON, CSV, Excel, XML or HTML, or read through the Apify API.

It uses YouTube's own public web responses. No login, no cookies and no YouTube API key are needed. Only comments visible to any visitor are collected.

### Use cases

- **Brand and community managers** — read what viewers say under your videos and your competitors' videos.
- **Researchers and data teams** — build comment datasets for sentiment analysis, topic modelling or LLM fine-tuning.
- **Creators and agencies** — find questions, feature requests and pinned or creator-hearted comments.
- **Moderation and audits** — export a full thread with author channel IDs for review.

### Features

- Top-level comments **and replies** in one dataset (replies on by default).
- Accepts video URLs (watch, youtu.be, Shorts, embed), bare 11-character video IDs, playlist URLs and channel URLs (`@handle`, `/channel/UC…`). Playlists and channels expand to their latest videos.
- Sort by **Top** or **Newest**, as offered by YouTube.
- Thread fields: `parentId`, `threadDepth`, and `threadText` (the whole thread as plain text on each top-level comment, handy for LLM prompts).
- Flags: `isPinned`, `isHeartedByCreator`, `isChannelOwner`, `isVerifiedAuthor`, `isMember`, `isEdited`.
- `publishedAtEstimate`: YouTube only shows relative times ("6 years ago"), so an approximate ISO date is computed from it. It is an estimate, and only for English (`language: "en"`).
- Hard caps (`maxResults`, `maxCommentsPerVideo`, `maxRepliesPerComment`) to control cost.

### Input

#### Configuration

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` (required) | array | — | Video, Shorts, playlist or channel URLs, or bare video IDs. |
| `maxVideosPerSource` | integer | 5 | Videos to expand per playlist or channel (1–500). |
| `maxCommentsPerVideo` | integer | 100 | Max top-level comments per video (1–100000). Replies are counted separately. |
| `includeReplies` | boolean | true | Fetch the reply thread under each comment. |
| `maxRepliesPerComment` | integer | 50 | Max replies per top-level comment (0 = none). |
| `sortBy` | string | `top` | `top` or `newest`. |
| `maxResults` | integer | 200 | Hard cap on total rows (comments + replies) for the run. |
| `language` | string | `en` | Interface language (`hl`). Date estimates only work for English. |
| `proxyConfiguration` | object | Apify datacenter | Switch to residential only if YouTube shows consent or "unusual traffic" pages. |

#### Example input

```json
{
  "startUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "maxCommentsPerVideo": 20,
  "includeReplies": true,
  "maxRepliesPerComment": 5,
  "sortBy": "top",
  "maxResults": 60
}
```

### Output

#### Example output

Each row is a `comment` or a `reply`. Sample (shortened, author data replaced by placeholders):

```json
[
  {
    "type": "comment",
    "commentId": "UgxExampleCommentId000",
    "parentId": null,
    "threadDepth": 0,
    "videoId": "jNQXAC9IVRw",
    "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "videoTitle": "Me at the zoo",
    "text": "Example comment text.",
    "authorName": "@example-author",
    "authorChannelId": "UCxxxxxxxxxxxxxxxxxxxxxx",
    "authorChannelUrl": "https://www.youtube.com/channel/UCxxxxxxxxxxxxxxxxxxxxxx",
    "isChannelOwner": false,
    "isVerifiedAuthor": true,
    "isMember": false,
    "likeCount": 120,
    "replyCount": 3,
    "isHeartedByCreator": true,
    "isPinned": true,
    "isEdited": false,
    "publishedTimeText": "6 years ago",
    "publishedAtEstimate": "2020-10-04T00:00:00.000Z",
    "threadText": "@example-author: Example comment text.\n@example-replier: Example reply. …",
    "position": 1,
    "sortBy": "top",
    "scrapedAt": "2026-10-04T07:44:20.368Z",
    "error": null
  },
  {
    "type": "reply",
    "commentId": "UgxExampleCommentId000.ExampleReplyId",
    "parentId": "UgxExampleCommentId000",
    "threadDepth": 1,
    "text": "Example reply.",
    "authorName": "@example-replier",
    "likeCount": 5,
    "replyCount": null,
    "threadText": null,
    "position": 2
  }
]
```

#### Output fields and fill rates

Fill rates are measured on a real Apify run (41 rows, run `rXFDAUvYaN4UMicDJ`). Lower values are expected: `parentId` is only set on replies, and `replyCount` / `threadText` only on top-level comments.

| Field | Fill rate | Notes |
|---|---|---|
| `type`, `commentId`, `text`, `threadDepth`, `position`, `sortBy` | 100% | `type` is `comment` or `reply`. |
| `videoId`, `videoUrl`, `videoTitle`, `sourceUrl` | 100% | |
| `authorName`, `authorChannelId`, `authorChannelUrl` | 100% | |
| `likeCount`, `publishedTimeText`, `publishedAtEstimate` | 100% | Date is an estimate. |
| `isChannelOwner`, `isVerifiedAuthor`, `isMember`, `isPinned`, `isHeartedByCreator`, `isEdited` | 100% | |
| `scrapedAt` | 100% | |
| `replyCount` | 80% | Top-level comments only. |
| `threadText` | 80% | Top-level comments only. |
| `parentId` | 20% | Replies only. |
| `error` | 0% | `null` on normal rows. |

### How to use via API

#### Calling the Actor

Replace `YOUR_APIFY_TOKEN` with your token. Actor ID: `prosoralex~youtube-comments-replies-export` (check the exact owner/name on the Actor page).

**curl**

```bash
curl -X POST "https://api.apify.com/v2/acts/prosoralex~youtube-comments-replies-export/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls":["https://www.youtube.com/watch?v=jNQXAC9IVRw"],"maxResults":60}'
```

**JavaScript**

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('prosoralex/youtube-comments-replies-export').call({
  startUrls: ['https://www.youtube.com/watch?v=jNQXAC9IVRw'],
  includeReplies: true,
  maxResults: 60,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length);
```

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("prosoralex/youtube-comments-replies-export").call(run_input={
    "startUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "includeReplies": True,
    "maxResults": 60,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(len(items))
```

### Pricing

#### Pay per result

Pay per result: you are charged per dataset row (a comment or a reply). The price per 1,000 results depends on your Apify plan:

| Plan | Price per 1,000 results |
|---|---|
| Free | $0.30 |
| Bronze | $0.26 |
| Silver | $0.23 |
| Gold and above | $0.20 |

Apify platform usage (compute) is billed separately by Apify. In our test runs it was a fraction of a cent for 25–41 rows. Set `maxResults` to cap your spending.

### Troubleshooting

#### Common issues

- **Fewer rows than expected** — `maxResults`, `maxCommentsPerVideo` or `maxRepliesPerComment` stopped the run, or the video has comments disabled or few comments.
- **Consent or "unusual traffic" pages** — switch `proxyConfiguration` to Apify residential proxies.
- **`publishedAtEstimate` is empty** — it is only computed for English; keep `language` at `en`.
- **Input error "startUrls is required"** — provide at least one URL or video ID.
- **Private, deleted or age-restricted videos** — only publicly visible comments are available; no login is used.

### FAQ

#### Frequently asked questions

**Do I need a YouTube API key?** No.

**Are replies included?** Yes, by default. Set `includeReplies` to false to get top-level comments only.

**Is the date exact?** No. YouTube shows relative times, so `publishedAtEstimate` is approximate; the original text is in `publishedTimeText`.

**Can I scrape a whole channel?** Yes: give a channel URL and set `maxVideosPerSource`. The latest videos are expanded.

**Is it legal?** The Actor collects only publicly visible data. Comments contain personal data (names, channel IDs), so handle them according to GDPR and local law, and respect YouTube's terms. Use is at your own responsibility.

### Keywords

youtube comments scraper, youtube replies scraper, youtube comments export, youtube comment replies, export youtube comments to csv, youtube comments dataset, youtube comments sentiment analysis, youtube comments api alternative, youtube shorts comments

### Hashtags

\#youtube #youtubecomments #commentsscraper #webscraping #sentimentanalysis #dataset #socialmedia #apify

# Changelog

This Actor's version history is a separate document: https://apify.com/leadsbrary/youtube-comments-replies-export/changelog.md

# Actor input Schema

## `startUrls` (type: `array`):

YouTube video URLs (watch, youtu.be, Shorts, embed), bare 11-character video IDs, playlist URLs, or channel URLs (@handle, /channel/UC…). Playlists and channels expand to their latest videos.

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

For playlist and channel inputs: how many videos to expand (latest first for channels).

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

Maximum top-level comments collected per video (replies are counted separately).

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

Fetch the reply thread under each top-level comment.

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

Maximum replies fetched per top-level comment (0 = none).

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

Comment ordering as offered by YouTube.

## `maxResults` (type: `integer`):

Hard cap on total dataset rows (comments + replies) for the whole run. Also protects your spending.

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

Interface language (hl) sent to YouTube, e.g. en. Absolute time estimates are only computed for English.

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

Apify datacenter proxy by default. Switch to residential only if YouTube shows consent or 'unusual traffic' pages.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxVideosPerSource": 3,
  "maxCommentsPerVideo": 20,
  "includeReplies": true,
  "maxRepliesPerComment": 5,
  "sortBy": "top",
  "maxResults": 60,
  "language": "en",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (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 = {
    "startUrls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "maxVideosPerSource": 3,
    "maxCommentsPerVideo": 20,
    "includeReplies": true,
    "maxRepliesPerComment": 5,
    "maxResults": 60,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/youtube-comments-replies-export").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 = {
    "startUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxVideosPerSource": 3,
    "maxCommentsPerVideo": 20,
    "includeReplies": True,
    "maxRepliesPerComment": 5,
    "maxResults": 60,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/youtube-comments-replies-export").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 '{
  "startUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxVideosPerSource": 3,
  "maxCommentsPerVideo": 20,
  "includeReplies": true,
  "maxRepliesPerComment": 5,
  "maxResults": 60,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call leadsbrary/youtube-comments-replies-export --silent --output-dataset

```

## MCP server setup

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

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/ULv8rRoKpFzih0DGd/builds/hnwKCTC2fMdj1X7na/openapi.json
