# YouTube Comment Scraper (`datascrapers/youtube-comment-scraper`) Actor

Scrape comments from YouTube videos and playlists. Supports multiple video or playlist URLs, comment sorting, and a global comment limit.

- **URL**: https://apify.com/datascrapers/youtube-comment-scraper.md
- **Developed by:** [Farhan Ali](https://apify.com/datascrapers) (community)
- **Categories:** Videos, Social media, MCP servers
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.70 / 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/platform/actors/running/actors-in-store#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 Comment Scraper** creates a structured dataset of comments collected from public [YouTube](https://www.youtube.com) videos and playlists. Each dataset item represents one comment and can include the comment text, author, likes, reply status, publish timestamp, and the source video's title, URL, view count, and channel. Query the source by video or playlist URL, control the result limit with `maxItems`, and retrieve records through the Apify Dataset API or export them as JSON, CSV, or Excel.

### Dataset at a glance

| Property | Value |
|---|---|
| Source | youtube.com (public videos and playlists) |
| Record unit | One comment (or reply) |
| Input methods | Video or playlist URLs (`videoUrls`) |
| Main identifiers | `commentId`, `videoId` |
| Delivery | Apify Dataset and API |
| Export formats | JSON, CSV, Excel |
| Update model | Fresh records per Actor run |
| Pricing | $2.50 per 1,000 comments |

### Coverage and available records

The Actor collects comments from one or more YouTube videos or playlists.

- **Video input**: `videoUrls` accepts individual video URLs. Playlist URLs are expanded into their videos automatically; a video URL carrying both `v=` and `list=` parameters is treated as a single video.
- **Sort order**: `commentSort` selects `new` (newest first) or `top` (top comments).
- **Result limit**: `maxItems` caps the total number of comments collected across all videos (`0` = unlimited).
- **Parallelism**: `maxConcurrency` controls how many videos are processed at once (1–10).
- **Replies**: Replies are collected as individual records and carry `isReply` and `parentCommentId`.

Known exclusions: comments are limited to what YouTube returns for the chosen sort order; each run captures comment state at run time (no historical snapshots); the Actor does not retrieve the full nested reply tree beyond returned replies.

### Data dictionary

Field names below match dataset record JSON properties exactly.

| Field | Type | Nullable | Description | Example |
|---|---:|---|---|---|
| `commentId` | string | No | YouTube comment identifier; best stable deduplication key | `UgzuC3zzpRZkjc5Qzsd4AaABAg` |
| `text` | string | No | Comment text content | `We're so honored...` |
| `author` | string | Yes | Display name of the comment author | `@SanDiegoZoo` |
| `authorChannelId` | string | Yes | Channel ID of the comment author | `UCC5NfQ6Mf0dq_eEwv4P_hWA` |
| `likeCount` | integer | Yes | Number of likes on the comment | `4600000` |
| `isFavorited` | boolean | Yes | Whether the video creator hearted the comment | `true` |
| `isReply` | boolean | Yes | Whether the comment is a reply to another comment | `false` |
| `parentCommentId` | string | Yes | Parent comment ID when `isReply` is true | `UgzuC3zzpRZkjc5Qzsd4AaABAg` |
| `publishedAt` | string | Yes | ISO 8601 timestamp of the comment | `2020-07-09T00:00:00+00:00` |
| `videoId` | string | Yes | YouTube video ID of the source video | `jNQXAC9IVRw` |
| `videoUrl` | string | Yes | Canonical URL of the source video | `https://www.youtube.com/watch?v=jNQXAC9IVRw` |
| `videoTitle` | string | Yes | Title of the source video | `Me at the zoo` |
| `channelName` | string | Yes | Name of the channel that published the video | `jawed` |
| `channelId` | string | Yes | Channel ID of the video publisher | `UC4QobU6STFB0P71PMvOGN5A` |
| `videoPublishedAt` | string | Yes | Publication date of the source video | `2005-04-24` |
| `videoViewCount` | integer | Yes | View count of the source video at scrape time | `398675009` |
| `videoCommentCount` | integer | Yes | Total comment count reported for the source video | `10` |

### Example dataset record

A representative record produced from the video `https://www.youtube.com/watch?v=jNQXAC9IVRw`:

```json
{
  "commentId": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "text": "We're so honored that the first ever YouTube video was filmed here!",
  "author": "@SanDiegoZoo",
  "authorChannelId": "UCC5NfQ6Mf0dq_eEwv4P_hWA",
  "likeCount": 4600000,
  "isFavorited": true,
  "isReply": false,
  "parentCommentId": null,
  "publishedAt": "2020-07-09T00:00:00+00:00",
  "videoId": "jNQXAC9IVRw",
  "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "videoTitle": "Me at the zoo",
  "channelName": "jawed",
  "channelId": "UC4QobU6STFB0P71PMvOGN5A",
  "videoPublishedAt": "2005-04-24",
  "videoViewCount": 398675009,
  "videoCommentCount": 10
}
```

### Query and input reference

| Input | Type | Required | Default | Accepted values | Description |
|---|---|---|---|---|---|
| `videoUrls` | array\[string] | Yes | — | YouTube video or playlist URLs | Source videos; playlists are expanded automatically |
| `maxItems` | integer | No | `100` | `0` or a positive integer | Maximum comments across all videos; `0` = unlimited |
| `commentSort` | string | No | `new` | `new`, `top` | Newest first, or top comments |
| `maxConcurrency` | integer | No | `3` | `1`–`10` | Number of videos processed in parallel |
| `proxyConfiguration` | object | No | Apify residential proxy | Apify proxy groups or custom proxies | Residential proxies are recommended |

Minimal request:

```json
{ "videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"] }
```

Advanced request:

```json
{
  "videoUrls": ["https://www.youtube.com/playlist?list=..."],
  "maxItems": 1000,
  "commentSort": "top",
  "maxConcurrency": 3,
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

### Retrieve the data through the API

1. Start the Actor with a JSON input (console or API).
2. Wait for the run to finish, or use a synchronous endpoint for an inline response.
3. Retrieve items from the run's default dataset.
4. Paginate or export the dataset.

Python example:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR-APIFY-TOKEN")

run = client.actor("datascrapers/youtube-comment-scraper").call(run_input={
    "videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxItems": 1000,
    "commentSort": "new",
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["commentId"], item["author"], item["likeCount"])
```

Apify generates ready-to-run Python, JavaScript, and cURL examples on the Actor's API tab. Do not put a real API token in shared code or URLs.

### Data quality and record handling

- **Conditional fields**: Reply records carry `isReply` and `parentCommentId`; top-level comments have `parentCommentId` null. Fields YouTube does not expose are returned as null.
- **Source changes**: YouTube page structure and values can change; unreadable fields are returned as null rather than fabricated.
- **Deduplication**: Each run appends fresh records; the Actor does not deduplicate across runs. Use `commentId` as the stable key and filter repeated runs against previously stored IDs.
- **Rate limits**: YouTube rate-limits automated traffic. Residential proxies (enabled by default) and bounded concurrency are used to maintain coverage.
- **Normalization**: `publishedAt` is normalized to ISO 8601; view and like counts are read as integers.

### Export and pipeline examples

| Destination | Recommended method | Typical use |
|---|---|---|
| PostgreSQL / Supabase | Dataset API poll or webhook consumer | Store comments for sentiment pipelines |
| Google Sheets | Apify Google Sheets integration | Share comment threads with community teams |
| S3 / cloud storage | Scheduled export via Apify scheduler | Archival of comment snapshots |
| BI tools | CSV / JSON export | Audience and sentiment analysis |

### Pricing and cost examples

The Actor uses pay-per-event pricing, billed per comment record:

| Event | Trigger | Rate |
|---|---|---|
| Comment | Every comment pushed to the dataset | $2.50 per 1,000 comments |

A one-time Actor start event of $0.00005 applies to each run (effectively $0).

| Comments | Estimated base cost |
|---:|---:|
| 1,000 | $2.50 |
| 10,000 | $25.00 |
| 100,000 | $250.00 |

Compute units consumed by the run are billed by your Apify plan. Estimates depend on the verified pricing model and the options selected for the run.

### Limitations and responsible data use

- The Actor collects publicly accessible comment data from YouTube only.
- Field availability depends on what YouTube returns at run time; some values can be null or missing, and site changes can alter fields.
- The Actor does not provide historical snapshots unless you store them yourself.
- Large runs require residential proxies; without them, coverage may degrade due to rate limiting.
- You are responsible for compliance with YouTube's terms of service, applicable privacy law, and any contractual obligations before using the data.

### Dataset questions

#### What does one dataset item represent?

One comment or reply. Replies are separate records linked to their parent via `parentCommentId`.

#### Which field should I use as a unique identifier?

`commentId` is the stable YouTube comment identifier and the recommended deduplication key.

#### Are fields nullable or conditional?

Yes. Reply records carry `isReply` and `parentCommentId`; top-level comments have `parentCommentId` null. Fields YouTube does not expose for a given comment are returned as null.

#### Can I retrieve the records as CSV or JSON?

Yes. The dataset can be exported as JSON, CSV, or Excel from the Apify Console, and queried through the Dataset API.

#### Does the Actor return historical data?

No. Each run captures the state of the comments at run time. To track changes, schedule repeated runs and store the outputs yourself.

#### What counts as a billable result?

Each comment pushed to the dataset is one billable result, charged at $2.50 per 1,000 comments. Use `maxItems` to control cost per run.

### Related datasets from Data Scrapers

- **[YouTube Channel Scraper](https://apify.com/datascrapers/youtube-channel-scraper)** — Channel and video metadata that can be joined to comment data by channel or video ID.
- **[TripAdvisor Reviews Scraper](https://apify.com/datascrapers/tripadvisor-reviews-scraper)** — User review text for sentiment and reputation analysis.
- **[Google Play Store App Reviews Scraper](https://apify.com/datascrapers/playstore-app-reviews)** — App review text for product feedback analysis.
- **[Twitter X Profile Scraper](https://apify.com/datascrapers/twitter-x-profile-scraper)** — Public post data for cross-platform audience research.

### Data Scrapers support

Need an additional field, record type, or export workflow? Contact Data Scrapers at stardustspotlight@gmail.com. Include a sample source URL, required fields, expected record volume, and preferred delivery format.

# Actor input Schema

## `videoUrls` (type: `array`):

YouTube video or playlist URLs to scrape comments from. Playlist URLs are expanded into individual videos automatically. Video URLs with both v= and list= parameters are treated as single videos.

## `maxItems` (type: `integer`):

Maximum number of comments to scrape across all videos (0 = unlimited)

## `commentSort` (type: `string`):

How comments are ordered when extracted

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

How many videos to process at the same time. Higher values are faster for multiple URLs but use more resources.

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

Proxy settings for anti-bot protection

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxItems": 30,
  "commentSort": "new",
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Dataset containing scraped YouTube comments

## `runStats` (type: `string`):

Aggregate statistics for the scrape run

# 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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ],
    "maxItems": 30,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("datascrapers/youtube-comment-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 = {
    "videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
    "maxItems": 30,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("datascrapers/youtube-comment-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 '{
  "videoUrls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "maxItems": 30,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call datascrapers/youtube-comment-scraper --silent --output-dataset

```

## MCP server setup

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