# YouTube Comments Scraper 🚀 | Pay Per Result (`genial_candlestand/youtube-comments-scraper-ppr`) Actor

🔍 Unleash the Power of YouTube Comments: Extract insightful comments from one or multiple YouTube videos effortlessly! 🚀 Export the data in your preferred format: HTML, JSON, CSV, Excel, or XML. Perfect for sentiment analysis, content improvement, and audience research. 📊✨

- **URL**: https://apify.com/genial_candlestand/youtube-comments-scraper-ppr.md
- **Developed by:** [Flowo](https://apify.com/genial_candlestand) (community)
- **Categories:** Automation, Social media, Videos
- **Stats:** 185 total users, 9 monthly users, 100.0% runs succeeded, 19 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.40 / 1,000 comments

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Comments Scraper

📥 **Unlock YouTube Insights with Ease!**

YouTube Comments Scraper is a powerful tool designed to extract comments from one or multiple YouTube videos. Whether you need data for sentiment analysis, user feedback, or audience engagement, this scraper makes it easy to gather the insights you need.

### Why choose this scraper?

- 🚀 **Fast and Efficient**: Handles large datasets with speed and accuracy.
- 🛠 **User-Friendly**: Easy to set up and use, even for beginners.
- 🌐 **Global Compatibility**: Works with videos in any language and region.
- 🔒 **Secure**: Built-in proxy support for reliable and anonymous scraping.

### Features

- 🛠 **Customizable Input**: Configure language and the number of comments to scrape.
- 🚀 **Fast and Reliable**: High performance with minimal delays.
- 🌐 **Global Support**: Works with videos in any language.
- 📝 **Extract detailed comment data**: Includes text, author, timestamps, likes, and replies.
- 📊 **Sort by relevance**: Choose to sort comments by recent or popular.
- 🔒 **Proxy support**: Built-in integration with Apify Proxy for reliable and anonymous scraping.
- 📂 **Flexible output formats**: Export data as JSON, CSV, Excel, HTML, or XML.

### How to use YouTube Comments Scraper

1. Create an [Apify](https://console.apify.com/sign-up) account.
2. Open the [YouTube Comments Scraper](https://apify.com/your-actor-url).
3. Provide one or more YouTube video URLs in the input.
4. Adjust optional settings like maximum comments to extract or language preference.
5. Click the "Start" button and wait for the scraper to extract the data.
6. Download your results in your preferred format.

### What data can you scrape?

The scraper extracts the following data:

- **Comment ID**: Unique identifier for the comment.
- **Comment text**: The text content of the comment.
- **Author**: Name of the comment author.
- **Time**: Timestamp of when the comment was posted.
- **Votes**: Number of likes the comment received.
- **Replies**: Number of replies to the comment.
- **Channel ID**: ID of the comment author’s channel.
- **Profile photo URL**: Link to the author's profile picture.
- **Publication date**: Exact date and time the comment was published.

### Output example

The extracted data is saved in a dataset and can be exported in multiple formats. Example JSON output:

```json
[
    {
        "cid": "Ugz-DudNyjplEb262b94AaABAg",
        "text": "Exactly! This is very useful information.",
        "time": "4 months ago",
        "author": "@Apify",
        "channel": "UCTgwcoeGGKmZ3zzCXN2qo_A",
        "votes": 5,
        "replies": 2,
        "photo": "https://yt3.ggpht.com/mcMDz5bXyewUKn5L1RQu8_dYHq3PTdc=s88",
        "video_url": "https://www.youtube.com/watch?v=5kcaHAuGxmY",
        "video_id": "5kcaHAuGxmY",
        "publication_timestamp": 1726521194.461579,
        "publication_date_time": "2024-09-17 00:13:14.463579"
    }
]

```

**How proxy usage affects cost:**

- Residential proxies are included in the Starter plan and are essential for reliable scraping. They help bypass rate limits and prevent IP bans.
- Heavy scraping (e.g., scraping hundreds of thousands of comments) may require additional proxy resources, which could increase costs.

For detailed pricing and proxy usage information, refer to the [Apify pricing page](https://apify.com/pricing).

### Use cases

The data extracted by YouTube Comments Scraper can be applied to various scenarios:

- 📈 **Marketing analysis**: Understand user sentiments and reactions to campaigns or products.
- 🔍 **Product feedback tracking**: Monitor comments for direct feedback on product features or improvements.
- 🎥 **Content improvement**: Leverage viewer feedback to create more engaging and relevant videos.
- 📰 **Trend analysis**: Identify trending topics or commonly discussed themes in your niche.
- 🛠 **Data-driven decisions**: Use detailed comment data to guide strategic decisions for businesses or content creators.

### FAQ

#### What happens if YouTube blocks my request?

If YouTube blocks your request, enabling residential proxies can help bypass rate limits and restrictions, ensuring uninterrupted data extraction. These proxies are included in Apify's Starter plan. These proxies are included in Apify's Starter plan and help bypass rate limits and restrictions.

#### Can I schedule the scraper to run automatically?

Yes, you can schedule the scraper using Apify's built-in scheduling feature. This allows you to run the scraper at specific intervals, such as daily or weekly, ensuring that you always have the latest comment data.

#### Can I integrate YouTube Comments Scraper with other apps?

Yes, the scraper can be integrated with various cloud services and apps such as:

- Google Sheets
- Zapier
- Slack
- LangChain
- Trello
- Asana

Additionally, you can set up webhooks to trigger actions when the scraper finishes, such as sending notifications or processing data.

#### Can I use YouTube Comments Scraper with the API?

Absolutely! Apify API allows you to manage, schedule, and run Actors programmatically. You can fetch results, access datasets, and monitor performance using Node.js or Python libraries. Check the [Apify API reference docs](https://docs.apify.com/api/v2) for details.

#### How to use data after scraping YouTube comments?

Extracted comments can be used for:

- 🧐 **Sentiment analysis**: Understand user opinions and feedback.
- 🔍 **Trend tracking**: Identify trending topics or keywords.
- 📈 **Engagement analysis**: Measure audience interaction with content.
- 🛠 **Product improvements**: Leverage feedback to enhance products or services.
- 👥 **Audience research**: Study interests and demographics of viewers.

### Feedback and support

We’re always working to improve our tools. If you have feedback or encounter any issues, please let us know by creating an issue in the "Issues" tab on the Apify Console.

# Actor input Schema

## `urls` (type: `array`):

Youtube Video URLs

## `sort_by` (type: `string`):

Sort order for comments. Can be 'recent' or 'popular'.

## `max_comments` (type: `integer`):

Maximum number of comments to fetch. Left 0 for unlimited.

## `language` (type: `string`):

Language code for the response (e.g., 'en' for English).

## `sleep` (type: `integer`):

Time in milliseconds to wait between requests.

## `proxySettings` (type: `object`):

Select proxies to be used by your crawler.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=dzjS9iYHbuU"
  ],
  "sort_by": "recent",
  "max_comments": 0,
  "language": "en",
  "sleep": 100,
  "proxySettings": {
    "useApifyProxy": false,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "urls": [
        "https://www.youtube.com/watch?v=dzjS9iYHbuU"
    ],
    "sort_by": "recent",
    "max_comments": 0,
    "language": "en",
    "sleep": 100,
    "proxySettings": {
        "useApifyProxy": false,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("genial_candlestand/youtube-comments-scraper-ppr").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 = {
    "urls": ["https://www.youtube.com/watch?v=dzjS9iYHbuU"],
    "sort_by": "recent",
    "max_comments": 0,
    "language": "en",
    "sleep": 100,
    "proxySettings": {
        "useApifyProxy": False,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

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

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

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

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.youtube.com/watch?v=dzjS9iYHbuU"
  ],
  "sort_by": "recent",
  "max_comments": 0,
  "language": "en",
  "sleep": 100,
  "proxySettings": {
    "useApifyProxy": false,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call genial_candlestand/youtube-comments-scraper-ppr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,genial_candlestand/youtube-comments-scraper-ppr"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/DWMOoRvGToJfEcUR9/builds/Dcnf9jVyuiCfNZezq/openapi.json
