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

Extract YouTube comments data from one or multiple YouTube videos: full comment text, posting date, author username, video title, videoId. Download YouTube comments in JSON, CSV, and Excel.

- **URL**: https://apify.com/spectre\_scrape/youtube-comments-scraper.md
- **Developed by:** [Spectre](https://apify.com/spectre_scrape) (community)
- **Categories:** Videos, Social media, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.90 / 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/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 Comments Scraper

Extract YouTube video comments and replies at ultra-fast speeds using YouTube's internal InnerTube API — no official API key required, no quota limits.

Provide any YouTube video URL and instantly pull hundreds or thousands of comments along with all the metadata you need for analysis.

---

### What is YouTube Comments Scraper?

YouTube Comments Scraper is a data extraction tool that goes beyond the limitations of the standard YouTube Data API. It scrapes comments directly through YouTube's internal InnerTube endpoints, giving you:

- ✅ All comments and replies from any YouTube video
- ✅ Sort by **Newest First** or **Top Comments**
- ✅ Filter comments by date (only scrape comments newer than a given date)
- ✅ Comment text, author handle, publish time, vote count, and reply count
- ✅ Whether the comment has been **hearted by the creator**
- ✅ Whether the commenter **is the channel owner**
- ✅ Total comment count for the video
- ✅ Scrape both regular videos and YouTube Shorts

---

### Use Cases

- 📊 **Sentiment analysis** — understand how audiences feel about a video or topic
- 🔍 **Brand monitoring** — track mentions of your brand in YouTube comments
- 📈 **Trend discovery** — identify what topics and opinions are gaining traction
- 🚨 **Content moderation** — detect harmful, spammy, or illegal comments at scale
- 🧪 **Research & academia** — collect public comment datasets for NLP and social research
- 🎯 **Competitor analysis** — analyze what audiences say about competitors' content
- 💡 **Community insights** — understand what your viewers think and feel

---

### How to Use

1. [Create a free Apify account](https://console.apify.com/sign-up)
2. Open **YouTube Comments Scraper** on the Apify platform
3. Enter one or more YouTube video URLs in the **Start URLs** field
4. Set your desired **Max Comments**, **Sort Order**, and optional **Date Filter**
5. Click **Start** and wait for the run to complete
6. Download your data as **JSON, CSV, Excel, XML, or HTML**

---

### ⬇️ Input

The actor accepts the following input fields:

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` | Array | — | **Required.** One or more YouTube video or Shorts URLs to scrape |
| `maxComments` | Integer | `100` | Maximum number of comments/replies to scrape per video |
| `sortCommentsBy` | String | `NEWEST_FIRST` | Sort order: `NEWEST_FIRST` or `TOP_COMMENTS` |
| `oldestCommentDate` | String | — | Only return comments on or after this date. Format: `YYYY-MM-DD` |
| `maxConcurrency` | Integer | `3` | Number of concurrent workers (increase for faster runs) |
| `proxyConfiguration` | Object | Apify Proxy | Proxy settings — residential proxies recommended for reliability |

#### Input Example (JSON)

```json
{
  "startUrls": [
    { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }
  ],
  "maxComments": 500,
  "sortCommentsBy": "TOP_COMMENTS",
  "oldestCommentDate": "2024-01-01",
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
````

***

### ⬆️ Output

Each scraped comment or reply is stored as a separate item in the dataset. Results can be previewed in the Apify console and downloaded in multiple formats.

#### Output Fields

| Field | Type | Description |
|---|---|---|
| `comment` | String | Full text of the comment |
| `cid` | String | Unique comment ID |
| `publishedTimeText` | String | Time since comment was posted (e.g. "2 days ago") |
| `author` | String | Author's YouTube handle (e.g. `@username`) |
| `videoId` | String | YouTube video ID |
| `pageUrl` | String | Full URL of the video page |
| `commentsCount` | Integer | Total number of comments on the video |
| `replyCount` | Integer | Number of replies to this comment |
| `voteCount` | Integer | Number of likes on the comment |
| `authorIsChannelOwner` | Boolean | `true` if the commenter is the channel owner |
| `hasCreatorHeart` | Boolean | `true` if the creator hearted this comment |
| `type` | String | `"comment"` for top-level comments, `"reply"` for replies |
| `replyToCid` | String | ID of the parent comment (only present for replies) |
| `title` | String | Title of the YouTube video |

#### Output Example (JSON)

```json
{
  "comment": "This is one of the best videos I've ever seen.",
  "cid": "UgxRn0_LUxzRP2MybPR4AaABAg",
  "publishedTimeText": "3 days ago",
  "author": "@some_user",
  "videoId": "dQw4w9WgXcQ",
  "pageUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "commentsCount": 84321,
  "replyCount": 12,
  "voteCount": 4200,
  "authorIsChannelOwner": false,
  "hasCreatorHeart": true,
  "type": "comment",
  "replyToCid": null,
  "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)"
}
```

***

### Error Items

If a video is unavailable, has comments disabled, or cannot be scraped for any reason, the actor pushes an **error item** to the dataset instead of silently skipping it. Normal output items are never affected — you can identify error items by the presence of an `error` field.

***

### Integrations

YouTube Comments Scraper can be connected to virtually any tool or cloud service via the Apify platform integrations:

- **Make** (formerly Integromat)
- **Zapier**
- **Slack**
- **Airbyte**
- **Google Drive**
- **GitHub**
- **Webhooks** — trigger actions on every completed run

***

### API Access

You can run and manage this actor programmatically using the Apify API.

**Node.js:**

```javascript
const { ApifyClient } = require('apify-client');

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });

const run = await client.actor('YOUR_ACTOR_ID').call({
  startUrls: [{ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' }],
  maxComments: 200,
  sortCommentsBy: 'TOP_COMMENTS',
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**Python:**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("YOUR_ACTOR_ID").call(run_input={
    "startUrls": [{ "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }],
    "maxComments": 200,
    "sortCommentsBy": "TOP_COMMENTS",
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

***

### FAQ

#### Is YouTube comment scraping legal?

YouTube comments are publicly visible data. Scraping public data is generally legal, but you should ensure your use case complies with YouTube's Terms of Service and applicable data protection laws (e.g. GDPR). Never scrape private or personally sensitive data without a legitimate legal basis.

#### Do I need proxies?

Yes — for reliable scraping, **residential proxies** are strongly recommended. When running on the Apify platform, you can enable Apify Proxy directly in the input. Apify's Starter plan and above include residential proxy access.

#### Can I scrape multiple videos at once?

Yes. Add as many URLs as you want to the `startUrls` field. The actor will process them concurrently based on your `maxConcurrency` setting.

#### Can I filter comments by date?

Yes. Use the `oldestCommentDate` field (format: `YYYY-MM-DD`) to only return comments published on or after that date. Combine this with `sortCommentsBy: NEWEST_FIRST` for best results.

#### Can I scrape replies as well?

Yes. The actor scrapes both top-level comments and their replies. Replies are included in the same dataset and can be identified by `"type": "reply"` and the `replyToCid` field pointing to their parent comment.

***

### Feedback & Issues

Found a bug or have a feature request? Open an issue on the **Issues tab** of this actor on Apify, or reach out directly. We're always working to improve speed, reliability, and data coverage.

# Actor input Schema

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

Enter YouTube video or Shorts URLs.

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

Maximum number of comments/replies to scrape per video.

## `sortCommentsBy` (type: `string`):

How to sort comments (Newest first / Top comments).

## `oldestCommentDate` (type: `string`):

Filter to only scrape comments on or after this date. Format: YYYY-MM-DD

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

Maximum number of concurrent workers to spawn.

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

Apify Proxy configuration.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "maxComments": 100,
  "sortCommentsBy": "NEWEST_FIRST",
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

List of comments/replies scraped from YouTube comments

# 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": [
        {
            "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("spectre_scrape/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 = {
    "startUrls": [{ "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }],
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments Scraper",
        "description": "Extract YouTube comments data from one or multiple YouTube videos: full comment text, posting date, author username, video title, videoId. Download YouTube comments in JSON, CSV, and Excel.",
        "version": "1.0",
        "x-build-id": "sn2L3uIpKMDdvulXC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/spectre_scrape~youtube-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-spectre_scrape-youtube-comments-scraper",
                "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/spectre_scrape~youtube-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-spectre_scrape-youtube-comments-scraper",
                "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/spectre_scrape~youtube-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-spectre_scrape-youtube-comments-scraper",
                "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": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "Enter YouTube video or Shorts URLs.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxComments": {
                        "title": "Max comments",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of comments/replies to scrape per video.",
                        "default": 100
                    },
                    "sortCommentsBy": {
                        "title": "Sort comments by",
                        "enum": [
                            "NEWEST_FIRST",
                            "TOP_COMMENTS"
                        ],
                        "type": "string",
                        "description": "How to sort comments (Newest first / Top comments).",
                        "default": "NEWEST_FIRST"
                    },
                    "oldestCommentDate": {
                        "title": "Only scrape comments newer than (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Filter to only scrape comments on or after this date. Format: YYYY-MM-DD"
                    },
                    "maxConcurrency": {
                        "title": "Max concurrency",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of concurrent workers to spawn.",
                        "default": 3
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify Proxy configuration.",
                        "default": {
                            "useApifyProxy": true
                        }
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
