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

Export YouTube comments & replies to a structured dataset in minutes. Get author, text, likes, timestamps, and more—ready for analysis, dashboards, or archiving. Built for speed and reliability.

- **URL**: https://apify.com/api-ninja/youtube-comments-scraper.md
- **Developed by:** [API ninja](https://apify.com/api-ninja) (community)
- **Categories:** Automation, Social media, Videos
- **Stats:** 565 total users, 144 monthly users, 97.3% runs succeeded, 26 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.40 / 1,000 results

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?

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

A powerful Apify actor that extracts comments from YouTube videos with advanced filtering and customization options. Perfect for sentiment analysis, market research, content analysis, and social media monitoring.

### ✨ Features

- **🎯 Multi-Video Support**: Scrape comments from multiple YouTube videos in a single run
- **📊 Flexible Comment Limits**: Choose specific comment counts or extract all available comments
- **💬 Reply Extraction**: Include comment replies for comprehensive conversation analysis
- **🔄 Smart Sorting**: Order comments by "top" (most popular) or "newest" (most recent)
- **🌍 Localization**: Specify country and language for region-specific content
- **⚡ High Performance**: Optimized scraping with intelligent data extraction

### 🚀 Quick Start

#### Basic Usage

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

#### Advanced Configuration

```json
{
    "videoUrls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "https://www.youtube.com/watch?v=9bZkp7q19f0"
    ],
    "commentsPerVideo": 500,
    "scrapeAllComments": false,
    "includeReplies": true,
    "orderBy": "top",
    "geo": "US",
    "lang": "en"
}
```

### 📋 Input Configuration

The actor accepts the following configuration parameters:

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| **videoUrls** | `array` | ✅ Yes | - | YouTube video URLs or video IDs to scrape. Supports both full URLs (`https://www.youtube.com/watch?v=VIDEO_ID`) and video IDs (`VIDEO_ID`) |
| **commentsPerVideo** | `integer` | ❌ No | `100` | Number of comments to extract per video. Ignored when `scrapeAllComments` is enabled. Minimum: 100 |
| **scrapeAllComments** | `boolean` | ❌ No | `false` | Extract all available comments from the video when enabled |
| **includeReplies** | `boolean` | ❌ No | `false` | Include comment replies (approximately 10 replies per comment) |
| **orderBy** | `string` | ❌ No | `top` | Sort comments by popularity: `top` or `newest` |
| **geo** | `string` | ❌ No | - | ISO 3166-2 country code (e.g., `US`, `GB`, `IN`) for region-specific results |
| **lang** | `string` | ❌ No | - | ISO 639-1 language code (e.g., `en`, `es`, `fr`) for localized content |

#### Input Validation

- `videoUrls` must contain at least one valid YouTube URL or video ID
- `geo` must be a valid 2-letter country code (uppercase)
- `lang` must be a valid 2-letter language code (lowercase)
- `commentsPerVideo` must be at least 100 when specified

### 📤 Output Structure

The actor generates a structured dataset with the following fields for each comment:

```json
{
    "commentId": "UgwYX91Z7rTb7a6jGux4AaABAg",
    "text": "This is an amazing video! Really helped me understand the concept better.",
    "published": "2 days ago",
    "likes": 42,
    "author": "John Doe",
    "authorThumb": "https://yt3.ggpht.com/ytc/AKedOLQexample",
    "authorId": "UC123456789012345678",
    "authorUrl": "/channel/UC123456789012345678",
    "isEdited": false,
    "isPinned": false,
    "replyCount": 3,
    "replyToken": "Eg0SC1Vnd1lXOTFaN3JUYjdhNmpHdXg0QWFBQUJBZw",
    "isReply": false
}
```

#### Field Descriptions

| Field | Type | Description |
|-------|------|-------------|
| **commentId** | `string` | Unique identifier for the comment |
| **text** | `string` | The comment content |
| **published** | `string` | Relative time when the comment was posted |
| **likes** | `integer` | Number of likes the comment received |
| **author** | `string` | Display name of the comment author |
| **authorThumb** | `string` | URL to the author's profile thumbnail |
| **authorId** | `string` | YouTube channel ID of the author |
| **authorUrl** | `string` | Relative URL to the author's channel |
| **isEdited** | `boolean` | Whether the comment has been edited |
| **isPinned** | `boolean` | Whether the comment is pinned by the creator |
| **replyCount** | `integer` | Number of replies to this comment |
| **replyToken** | `string` | Token for fetching replies (if applicable) |
| **isReply** | `boolean` | Whether this item is a reply to another comment |

### 🔧 Use Cases

#### Market Research

Analyze customer sentiment and feedback on product-related videos to understand market trends and user preferences.

#### Content Analysis

Study engagement patterns and popular discussion topics to optimize content strategy.

#### Academic Research

Collect data for social media analysis, communication studies, and behavioral research.

#### Competitor Monitoring

Track comments on competitor videos to gather insights about their audience engagement.

### 🔌 Integrations

This actor seamlessly integrates with popular automation platforms:

- **[Make](https://www.make.com)**: Create automated workflows with YouTube comment data
- **[Zapier](https://zapier.com)**: Connect YouTube comments to 3000+ apps
- **[Google Sheets](https://sheets.google.com)**: Direct export to spreadsheets for analysis
- **[Airtable](https://airtable.com)**: Organize comment data in relational databases

### ⚠️ Important Notes

- **Rate Limiting**: The actor implements intelligent delays to respect YouTube's rate limits
- **Comment Availability**: Some videos may have comments disabled or limited by the creator
- **Reply Limitations**: Approximately 10 replies per comment are extracted to balance completeness and performance
- **Geographic Restrictions**: Some content may be region-restricted based on `geo` and `lang` settings

### 🤝 Support

For questions, bug reports, or feature requests drop an issue on the page.

**Built with ❤️**

# Actor input Schema

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

An array of YouTube video URLs or video IDs to scrape comments from. You can input full URLs like 'https://www.youtube.com/watch?v=9bZkp7q19f0' or just video IDs like 'e-ORhEE9VVg'.

## `commentsPerVideo` (type: `integer`):

Number of comments to scrape per video. If 'Scrape all comments' is enabled, this will be ignored.

## `scrapeAllComments` (type: `boolean`):

If enabled, all comments from the video will be scraped.

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

If enabled, replies to comments will be included. Only about 10 replies per comments will be parsed.

## `orderBy` (type: `string`):

The order to scrape comments by.

## `geo` (type: `string`):

ISO 3166-2 country code (e.g., US, GB, IN).

## `lang` (type: `string`):

Language code (e.g., en, es, fr).

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=9bZkp7q19f0",
    "e-ORhEE9VVg"
  ],
  "commentsPerVideo": 100,
  "scrapeAllComments": false,
  "includeReplies": false,
  "orderBy": "top"
}
```

# 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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=9bZkp7q19f0",
        "e-ORhEE9VVg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("api-ninja/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 = { "videoUrls": [
        "https://www.youtube.com/watch?v=9bZkp7q19f0",
        "e-ORhEE9VVg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("api-ninja/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 '{
  "videoUrls": [
    "https://www.youtube.com/watch?v=9bZkp7q19f0",
    "e-ORhEE9VVg"
  ]
}' |
apify call api-ninja/youtube-comments-scraper --silent --output-dataset

```

## MCP server setup

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