# YouTube Comments Scraper Pro (`scraping_solutions/youtube-comments-scraper-pro`) Actor

Scrape YouTube comments from multiple videos with retries, API key failover, pagination, and clean structured output. Ideal for research, sentiment analysis, and audience insights.

- **URL**: https://apify.com/scraping\_solutions/youtube-comments-scraper-pro.md
- **Developed by:** [Scraping Solutions](https://apify.com/scraping_solutions) (community)
- **Categories:** Videos, Social media, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.33 / 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 comments from one or many YouTube videos in a simple, scalable way.

This actor is built for creators, marketers, researchers, agencies, and data teams that need structured YouTube comment data without dealing with manual scraping or unstable workflows.

Just provide a list of YouTube video URLs or video IDs, choose how many comments you want per video, and the actor will handle the rest.

It supports:

- multiple videos in one run
- automatic pagination
- retries with exponential backoff
- API key failover
- duplicate protection
- pay-per-event budget protection

---

### Why use this actor

YouTube comments are one of the best sources for understanding:

- audience sentiment
- customer feedback
- community reactions
- trend signals
- engagement quality
- competitor audience behavior

This actor helps you collect that data in a clean, structured format that is ready for export, analysis, enrichment, or automation.

---

### What this actor does

For each YouTube video you provide, the actor:

1. extracts the video ID
2. requests comments from the API
3. paginates through additional comment pages
4. retries automatically if the API has a temporary failure
5. fails over to another API key if the main one fails
6. removes duplicates
7. saves structured results to the dataset

---

### Main features

- Scrape comments from **one or many YouTube videos**
- Accepts **video URLs or raw video IDs**
- Supports comment sorting by:
  - **newest**
  - **top**
- Handles **pagination automatically**
- Uses **retry + exponential backoff** for resilience
- Supports **multiple API keys with failover**
- Stops safely when the **run budget limit** is reached
- Returns **clean, structured, export-ready data**

---

### Input

This actor uses a simple input structure.

#### `videos`
A list of YouTube video URLs or raw video IDs.

Examples:

- `https://www.youtube.com/watch?v=1gxf6flnvNA`
- `https://youtu.be/1gxf6flnvNA`
- `1gxf6flnvNA`

#### `resultsLimit`
Maximum number of **unique comments** to download **per video**.

If you provide 3 videos and set `resultsLimit = 1000`, the actor will try to return up to **1000 unique comments per video**.

#### `sortBy`
Choose the comment sorting mode:

- `newest`
- `top`

#### `rapidApiKeys`
A list of RapidAPI keys.

The actor always starts with the **first key** and only switches to the next one if the current key fails.

#### `requestDelaySec`
Delay between pagination requests for the same video.

#### `maxRetries`
Maximum retry attempts per provider before failover.

#### `baseBackoffSec`
Base delay used for exponential backoff.

#### `minimumResultsRequired`
Minimum number of chargeable comments required before the actor starts scraping a video.

#### `requireFullFirstVideo`
If enabled, the actor will not start unless the run budget can cover the full requested comment limit for the first video.

#### `timeoutSecs`
HTTP timeout for API requests.

---

### Example input

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=1gxf6flnvNA",
    "1gxf6flnvNA"
  ],
  "resultsLimit": 1000,
  "sortBy": "newest"

}
````

***

### Output

Each dataset item represents one YouTube comment.

#### Output fields

- `video_id`
- `video_url`
- `sort_by`
- `commentId`
- `authorText`
- `authorChannelId`
- `authorThumbnail`
- `textDisplay`
- `publishedTimeText`
- `publishDate`
- `publishedAt`
- `likesCount`
- `replyCount`
- `replyToken`
- `authorIsChannelOwner`
- `isVerified`
- `isArtist`
- `isCreator`

***

### Example output

```json
{
  "video_id": "1gxf6flnvNA",
  "video_url": "https://www.youtube.com/watch?v=1gxf6flnvNA",
  "sort_by": "newest",
  "commentId": "UgzcQiVfAcJ5WGugXg14AaABAg",
  "authorText": "@odipglance5707",
  "authorChannelId": "UCr8Ld4tMJgQS4K5Oq1oDMtQ",
  "authorThumbnail": "https://yt3.ggpht.com/...",
  "textDisplay": "Who ever get this idea first is a genius!",
  "publishedTimeText": "2 years ago",
  "publishDate": "2024-04-13",
  "publishedAt": "2024-04-13T00:00:00Z",
  "likesCount": "0",
  "replyCount": "0",
  "replyToken": null,
  "authorIsChannelOwner": false,
  "isVerified": false,
  "isArtist": false,
  "isCreator": false
}
```

***

### Best use cases

#### Audience sentiment analysis

Understand how viewers react to a video, topic, product, or creator.

#### Competitor research

Analyze the comments on competing YouTube channels and videos.

#### Influencer and creator research

See how audiences respond to creator content and engagement strategies.

#### Market research

Collect direct audience opinions at scale.

#### Lead and insight generation

Find repeated questions, pain points, feedback patterns, and audience language.

#### AI and NLP workflows

Use comment data for classification, clustering, sentiment scoring, moderation analysis, or summarization.

***

### Reliability and budget protection

This actor is designed to be resilient in real-world scraping conditions.

It includes:

- automatic retries
- exponential backoff
- API key failover
- duplicate protection
- pagination loop protection
- run budget checks before scraping and before pushing data

This helps reduce wasted runs and prevents unnecessary downloads when the available budget is too low.

***

### Notes

- The actor returns **unique comments per video**.
- Final results depend on:
  - the requested `resultsLimit`
  - API stability
  - available pagination
  - the run’s charge limit
- Very active videos may require more requests and more time.

***

### Built for scalable comment extraction

Whether you are doing brand monitoring, creator research, sentiment analysis, or audience intelligence, this actor gives you a fast and practical way to collect YouTube comments in bulk.

# Actor input Schema

## `videos` (type: `array`):

Array of YouTube video URLs or raw video IDs.

## `resultsLimit` (type: `integer`):

Maximum number of unique comments to download per video.

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

Choose comment sorting mode.

## Actor input object example

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=1gxf6flnvNA",
    "1gxf6flnvNA"
  ],
  "resultsLimit": 1000,
  "sortBy": "newest"
}
```

# 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 = {
    "videos": [
        "https://www.youtube.com/watch?v=1gxf6flnvNA",
        "1gxf6flnvNA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scraping_solutions/youtube-comments-scraper-pro").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 = { "videos": [
        "https://www.youtube.com/watch?v=1gxf6flnvNA",
        "1gxf6flnvNA",
    ] }

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments Scraper Pro",
        "description": "Scrape YouTube comments from multiple videos with retries, API key failover, pagination, and clean structured output. Ideal for research, sentiment analysis, and audience insights.",
        "version": "0.0",
        "x-build-id": "mfY17naT2EEiTm0rN"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scraping_solutions~youtube-comments-scraper-pro/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scraping_solutions-youtube-comments-scraper-pro",
                "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/scraping_solutions~youtube-comments-scraper-pro/runs": {
            "post": {
                "operationId": "runs-sync-scraping_solutions-youtube-comments-scraper-pro",
                "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/scraping_solutions~youtube-comments-scraper-pro/run-sync": {
            "post": {
                "operationId": "run-sync-scraping_solutions-youtube-comments-scraper-pro",
                "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": [
                    "videos",
                    "resultsLimit",
                    "sortBy"
                ],
                "properties": {
                    "videos": {
                        "title": "YouTube videos",
                        "type": "array",
                        "description": "Array of YouTube video URLs or raw video IDs.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "resultsLimit": {
                        "title": "Comments per video",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of unique comments to download per video.",
                        "default": 1000
                    },
                    "sortBy": {
                        "title": "Sort comments by",
                        "enum": [
                            "newest",
                            "top"
                        ],
                        "type": "string",
                        "description": "Choose comment sorting mode.",
                        "default": "newest"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
