# Youtube Comments (`broto.tech/youtube-comments`) Actor

Extract YouTube comments and optional replies into clean datasets for research, sentiment analysis, content strategy, and AI workflows. Limit comments, track progress in logs, avoid duplicates, and download results from Apify.

- **URL**: https://apify.com/broto.tech/youtube-comments.md
- **Developed by:** [Broto Tech](https://apify.com/broto.tech) (community)
- **Categories:** Developer tools, Social media, Videos
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.00 / 1,000 comment or replies

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 Video Comments Scraper

🚀 **Fast and reliable scraper for extracting YouTube comments and optional replies**

Get structured YouTube comment data for audience research, sentiment analysis, content strategy, competitive monitoring, and AI workflows.

### 💰 Simple Pay-per-Use Pricing

**No monthly fees • No setup costs • Pay only for comments and replies fetched**

| What You Get | Cost | Example |
|--------------|------|---------|
| **Comments** | $0.001 per comment | 1,000 comments = $1.00 |
| **Replies** | $0.001 per reply | 500 replies = $0.50 |
| **Video Info in Logs** | Included | Used for progress and coverage reporting, not saved as a dataset item |

### 📊 What Data You'll Get

Every dataset item is an actual YouTube comment or reply. Video metadata is shown in the run logs for context, but it is not added to the result dataset.

#### 💬 Comment Data
For each comment, you'll receive:
- **Comment ID**
- **Author name**
- **Author thumbnail**
- **Comment text**
- **Like count**
- **Reply count**

#### ↩️ Reply Data (Optional)
When you enable replies, reply records include:
- **Reply comment ID**
- **Parent comment ID**
- **Reply author, text, thumbnail, and like count**
- **Reply marker** so replies are easy to separate from top-level comments

### 🚀 How to Use

#### Step 1: Add a YouTube Video

Paste any supported YouTube video URL or video ID:
- Standard videos: `https://www.youtube.com/watch?v=VIDEO_ID`
- Short links: `https://youtu.be/VIDEO_ID`
- Shorts: `https://www.youtube.com/shorts/VIDEO_ID`
- Live videos: `https://www.youtube.com/live/VIDEO_ID`
- Raw 11-character video IDs

#### Step 2: Choose What to Fetch

**Option A: Comments** ⚡ *Recommended for most users*
- **Best for**: Research, sentiment analysis, audience insights
- **Speed**: Fastest full-data mode
- **Cost**: $0.001 per comment
- **Use cases**: Comment exports, topic mining, engagement analysis

**Option B: Comments + Replies** 📋 *Complete conversation data*
- **Best for**: Conversation analysis and community research
- **Speed**: Slower because reply threads require extra requests
- **Cost**: $0.001 per comment or reply
- **Use cases**: Thread analysis, creator-audience interaction, support monitoring

**Option C: Video Check Only** 🎥 *Logs only*
- **Best for**: Quick video checks before scraping comments
- **Speed**: Fastest mode
- **Cost**: No comment-result events and no dataset records
- **Use cases**: Video lookup, metadata validation, pre-scrape planning

#### Step 3: Run and Download
- Real-time progress updates while comments are fetched
- Automatic retry handling for temporary network or YouTube errors
- Download results from the Apify dataset in JSON, CSV, Excel, or other supported formats

### 📈 Use Cases

#### 🧠 **Audience Research**
- **Sentiment Analysis**: Analyze how viewers react to a video
- **Topic Discovery**: Find repeated questions, requests, complaints, and praise
- **Community Insights**: Understand what viewers care about most

#### 📣 **Content Strategy**
- **Video Feedback**: Extract suggestions and reactions from viewers
- **Creator Research**: Compare audience response across videos or channels
- **Trend Mining**: Identify emerging topics in comment sections

#### 🏢 **Business Intelligence**
- **Competitor Monitoring**: Track reactions to competitor launches and campaigns
- **Brand Monitoring**: Find customer feedback in YouTube discussions
- **Product Research**: Collect feature requests and pain points from viewers

#### 🤖 **AI and Data Pipelines**
- **Training Datasets**: Build structured comment datasets
- **RAG Inputs**: Feed comments into knowledge bases or analysis workflows
- **Automations**: Connect Apify datasets to Make, n8n, Zapier, or custom scripts

### 📋 Sample Output

#### Comment Record
```json
{
  "commentId": "Ugxyz123",
  "author": "Jane Viewer",
  "authorThumbnail": "https://yt3.ggpht.com/...",
  "text": "This explanation was exactly what I needed.",
  "likeCount": 128,
  "replyCount": 4
}
````

#### Reply Record

```json
{
  "commentId": "Ugyreply456",
  "author": "Another Viewer",
  "authorThumbnail": "https://yt3.ggpht.com/...",
  "text": "Same here, this helped a lot.",
  "likeCount": 12,
  "replyCount": 0,
  "parentCommentId": "Ugxyz123",
  "isReply": true
}
```

### ⚡ Performance

- **Simple setup**: Paste a YouTube video URL and run
- **Large-video support**: Designed for videos with busy comment sections
- **Duplicate prevention**: Keeps repeated comments out of the dataset
- **Progress recovery**: Helps preserve results during longer runs
- **Reliable output**: Saves fetched records as the run progresses
- **Partial results retained**: Keeps data already collected if a later step fails

### 🎯 Pricing Examples

#### Small Projects

- **100 comments**: $0.10
- **Perfect for**: Testing, quick checks, small videos

#### Medium Projects

- **1,000 comments**: $1.00
- **Perfect for**: Audience research and sentiment analysis

#### Large Projects

- **10,000 comments**: $10.00
- **Perfect for**: Large-scale analysis, data pipelines, AI workflows

Replies are charged the same way as comments because each reply is saved as its own dataset item.

### 🔧 Configuration

#### Required Settings

- **YouTube Video URL**: The video URL or 11-character video ID to scrape

#### Optional Settings

- **Fetch Comments**: Enable or disable comment scraping
- **Include Replies**: Also fetch replies to top-level comments
- **Maximum Comments**: Stop after a specific number of comments; use `0` to fetch as many as possible
- **Enable Checkpointing**: Helps preserve progress during longer runs
- **Target Coverage**: Target percentage of known comments to fetch, from `0.5` to `1.0`

### ❓ Frequently Asked Questions

**Q: Do I need a YouTube API key?**\
A: No. Just provide a YouTube video URL or video ID.

**Q: Does the dataset include a video metadata record?**\
A: No. The dataset contains only comment and reply records. Video title, channel, view count, publish date, and reported comment count are shown in the logs.

**Q: Can it fetch every comment on very large videos?**\
A: It tries to fetch as much as possible, but YouTube may limit access on very large videos. You can tune the target coverage setting.

**Q: Can I limit the number of comments?**\
A: Yes. Set **Maximum Comments** to any number above `0`. Leave it at `0` to fetch as many comments as possible.

**Q: Are replies included automatically?**\
A: No. Replies are optional because they require extra requests and can slow down scraping.

**Q: What happens if YouTube or the network fails during a run?**\
A: The Actor retries temporary failures and keeps partial results when possible.

**Q: What formats can I download?**\
A: Apify datasets can be downloaded in JSON, CSV, Excel, XML, RSS, and HTML formats.

### 📞 Support

Need help? Contact us at **contact@broto.tech**

***

*This Actor is built and maintained by independent developers. Not affiliated with YouTube or Google.*

# Actor input Schema

## `videoUrl` (type: `string`):

URL of the YouTube video to fetch comments from

## `fetchComments` (type: `boolean`):

Enable to fetch comments from the video

## `fetchReplies` (type: `boolean`):

Also fetch replies to comments. May slow down the scraping process.

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

Maximum number of comments to fetch (0 = unlimited, fetch as many as possible)

## `enableCheckpointing` (type: `boolean`):

Save progress periodically for potential resume in subsequent runs

## `targetCoverage` (type: `number`):

Target percentage of comments to fetch (0.8 = 80%, 0.95 = 95%). Note: InnerTube API may limit actual coverage to ~40-50% for very large videos.

## Actor input object example

```json
{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "fetchComments": true,
  "fetchReplies": false,
  "maxComments": 0,
  "enableCheckpointing": true,
  "targetCoverage": 0.95
}
```

# Actor output Schema

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

Default dataset items. Top-level comments include commentId, author, authorThumbnail, text, likeCount, and replyCount. Reply records include those fields plus parentCommentId and isReply=true.

# 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 = {
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};

// Run the Actor and wait for it to finish
const run = await client.actor("broto.tech/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 = { "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }

# Run the Actor and wait for it to finish
run = client.actor("broto.tech/youtube-comments").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}' |
apify call broto.tech/youtube-comments --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=broto.tech/youtube-comments",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Youtube Comments",
        "description": "Extract YouTube comments and optional replies into clean datasets for research, sentiment analysis, content strategy, and AI workflows. Limit comments, track progress in logs, avoid duplicates, and download results from Apify.",
        "version": "2.0",
        "x-build-id": "e11Gcph3cFsRqI1Dl"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/broto.tech~youtube-comments/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-broto.tech-youtube-comments",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/broto.tech~youtube-comments/runs": {
            "post": {
                "operationId": "runs-sync-broto.tech-youtube-comments",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/broto.tech~youtube-comments/run-sync": {
            "post": {
                "operationId": "run-sync-broto.tech-youtube-comments",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "videoUrl"
                ],
                "properties": {
                    "videoUrl": {
                        "title": "YouTube Video URL",
                        "type": "string",
                        "description": "URL of the YouTube video to fetch comments from"
                    },
                    "fetchComments": {
                        "title": "Fetch Comments",
                        "type": "boolean",
                        "description": "Enable to fetch comments from the video",
                        "default": true
                    },
                    "fetchReplies": {
                        "title": "Include Replies",
                        "type": "boolean",
                        "description": "Also fetch replies to comments. May slow down the scraping process.",
                        "default": false
                    },
                    "maxComments": {
                        "title": "Maximum Comments",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Maximum number of comments to fetch (0 = unlimited, fetch as many as possible)",
                        "default": 0
                    },
                    "enableCheckpointing": {
                        "title": "Enable Checkpointing",
                        "type": "boolean",
                        "description": "Save progress periodically for potential resume in subsequent runs",
                        "default": true
                    },
                    "targetCoverage": {
                        "title": "Target Coverage",
                        "minimum": 0.5,
                        "maximum": 1,
                        "type": "number",
                        "description": "Target percentage of comments to fetch (0.8 = 80%, 0.95 = 95%). Note: InnerTube API may limit actual coverage to ~40-50% for very large videos.",
                        "default": 0.95
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
