# Youtube Comments Scraper (`dbott23/youtube-comments-scraper`) Actor

Scrape comments from any YouTube video using the official YouTube Data API v3. Extract comment text, author, likes, reply count, timestamps, and more. Supports replies, sorting by newest or most relevant, and up to 10,000 comments per video. No proxies required.

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

## Pricing

from $1.00 / 1,000 comment scrapeds

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/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 Comments Scraper

Scrape comments from any YouTube video using the **official YouTube Data API v3**. No proxies, no browser, no blocks — just a free API key and clean structured data.

### Features

- Scrape up to **10,000 comments per video**
- Process **multiple videos** in a single run
- Includes **replies** to top-level comments (optional)
- Sort by **newest first** or **most relevant**
- Returns author, comment text, like count, reply count, timestamps, and more
- Works with any YouTube URL format — full URLs, short URLs, or bare video IDs
- Fast and reliable: uses the official API, not browser scraping or proxies
- Export as JSON, CSV, or Excel

### Use Cases

- **Sentiment analysis** — Understand how audiences feel about a video, product, or topic
- **Market research** — Gather unfiltered audience feedback on competitors' content
- **Content strategy** — Discover what questions viewers are asking so you can create better content
- **Social listening** — Monitor brand mentions, product reviews, and customer pain points on YouTube
- **AI training data** — Build labelled comment datasets for sentiment, toxicity, or topic models
- **Academic research** — Collect social media data at scale for NLP studies
- **Influencer vetting** — Gauge real engagement quality and audience sentiment before partnerships

### Getting a YouTube API Key (free)

The YouTube Data API v3 is free and includes 10,000 quota units per day — enough for ~10,000 comment fetches daily.

1. Go to [console.cloud.google.com](https://console.cloud.google.com)
2. Create a new project (or select an existing one)
3. Open **APIs & Services → Library** and enable **YouTube Data API v3**
4. Go to **APIs & Services → Credentials → Create Credentials → API Key**
5. Copy the key and paste it into the `youtubeApiKey` input

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `videoUrls` | Array | — | YouTube video URLs or bare video IDs |
| `youtubeApiKey` | String | — | Your YouTube Data API v3 key (required) |
| `maxCommentsPerVideo` | Number | 100 | Comments to fetch per video (max 10,000) |
| `includeReplies` | Boolean | false | Also fetch replies to top-level comments |
| `sortBy` | String | `time` | `time` (newest first) or `relevance` |

### Output

Each comment is saved as a dataset item:

```json
{
  "video_id": "dQw4w9WgXcQ",
  "video_title": "Rick Astley - Never Gonna Give You Up",
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "comment_id": "UgxABCDEF123",
  "text": "This song never gets old!",
  "author": "MusicFan42",
  "author_channel_id": "UCxxxxxx",
  "like_count": 42,
  "reply_count": 3,
  "published_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z",
  "is_reply": false,
  "parent_id": null
}
```

### Frequently Asked Questions

**Do I need a YouTube account?**
No account needed — just a free API key from Google Cloud Console.

**Is it free to use the YouTube API?**
Yes. The YouTube Data API v3 has a free daily quota of 10,000 units. Fetching a page of 100 comments costs approximately 1 unit, so 10,000 comments costs ~100 units — well within the free tier.

**Can I scrape comments from multiple videos at once?**
Yes. Add as many video URLs or IDs as you need to the `videoUrls` array.

**Does it get replies to comments?**
Yes — enable `includeReplies` to fetch replies nested under top-level comments. Each reply is a separate dataset item with `is_reply: true` and its parent's ID in `parent_id`.

**Why use this instead of scraping YouTube directly?**
The official API is faster, more reliable, and avoids IP blocks entirely. No proxies required.

**What's the maximum comments per video?**
10,000 per video per run. For videos with more comments, re-run with a different sort order or filter.

### Pricing

- **$1.00 per 1,000 comments** scraped
- Actor start: $0.00005 per run

Example: 500 comments from each of 2 videos = 1,000 comments = **$1.00** total.

# Actor input Schema

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

List of YouTube video URLs or video IDs to scrape comments from. Supports youtube.com/watch?v=..., youtu.be/..., and bare 11-character video IDs.

## `youtubeApiKey` (type: `string`):

Your YouTube Data API v3 key. Free to get at console.cloud.google.com — enable 'YouTube Data API v3', create credentials, and paste the key here.

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

Maximum number of comments to scrape per video (top-level comments + replies if enabled). Max 10,000.

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

If enabled, also fetches replies to top-level comments. Each reply counts toward the maxCommentsPerVideo limit.

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

Order in which comments are returned. 'time' returns newest first; 'relevance' returns most-liked/pinned comments first.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxCommentsPerVideo": 100,
  "includeReplies": false,
  "sortBy": "time"
}
```

# Actor output Schema

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

All scraped comments with video, author, text, likes, replies and publish date.

# 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=dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dbott23/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=dQw4w9WgXcQ"] }

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

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/6KXxpgmREPzq3UjVu/builds/bGF9ee2AbwpRLxYU6/openapi.json
