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

🔍 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://beta-securitybyobscurity.apify.com/genial\_candlestand/youtube-comments-scraper-ppr.md
- **Developed by:** [Flowo](https://beta-securitybyobscurity.apify.com/genial_candlestand) (community)
- **Categories:** Automation, Social media, Videos
- **Stats:** 58 total users, 25 monthly users, 100.0% runs succeeded, 8 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.40 / 1,000 comments

This Actor is paid per result. You are not charged for the Apify platform usage, but only a fixed price for dataset items the Actor outputs.

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

# 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("💾 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 '{
  "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": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=genial_candlestand/youtube-comments-scraper-ppr",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments Scraper 🚀 | Pay Per Result",
        "description": "🔍 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. 📊✨",
        "version": "1.0",
        "x-build-id": "Dcnf9jVyuiCfNZezq"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/genial_candlestand~youtube-comments-scraper-ppr/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-genial_candlestand-youtube-comments-scraper-ppr",
                "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/genial_candlestand~youtube-comments-scraper-ppr/runs": {
            "post": {
                "operationId": "runs-sync-genial_candlestand-youtube-comments-scraper-ppr",
                "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/genial_candlestand~youtube-comments-scraper-ppr/run-sync": {
            "post": {
                "operationId": "run-sync-genial_candlestand-youtube-comments-scraper-ppr",
                "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": [
                    "urls",
                    "sort_by",
                    "max_comments"
                ],
                "properties": {
                    "urls": {
                        "title": "Video URLs",
                        "type": "array",
                        "description": "Youtube Video URLs",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sort_by": {
                        "title": "Sort order for comments. Can be 'recent' or 'popular'.",
                        "enum": [
                            "recent",
                            "popular"
                        ],
                        "type": "string",
                        "description": "Sort order for comments. Can be 'recent' or 'popular'.",
                        "default": "recent"
                    },
                    "max_comments": {
                        "title": "Maximum number of comments.",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Maximum number of comments to fetch. Left 0 for unlimited.",
                        "default": 0
                    },
                    "language": {
                        "title": "Language code for the response.",
                        "type": "string",
                        "description": "Language code for the response (e.g., 'en' for English).",
                        "default": "en"
                    },
                    "sleep": {
                        "title": "Time in milliseconds to wait between requests.",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Time in milliseconds to wait between requests.",
                        "default": 100
                    },
                    "proxySettings": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Select proxies to be used by your crawler."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
