# Youtube Comment Scraper (`topaz_sharingan/youtube-comment-scraper`) Actor

Introducing the YouTube Comment Scraper — a dynamic tool designed to unlock the wealth of insights hidden within YouTube video comments. Whether you're a content creator, researcher, or simply curious, this actor empowers you to effortlessly extract and analyze valuable information, including commen

- **URL**: https://apify.com/topaz_sharingan/youtube-comment-scraper.md
- **Developed by:** [Moses Ceaser](https://apify.com/topaz_sharingan) (community)
- **Categories:** Social media, SEO tools, Integrations
- **Stats:** 161 total users, 0 monthly users, 98.7% runs succeeded, 8 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 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.

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

Introduction

YouTube Comment Scraper is a powerful tool designed to extract valuable data from YouTube video comments. With this scraper, you can effortlessly gather information such as comment content, author details, reply count, like count, and voting status. Additionally, you can choose to include replies to each comment.

Key Features

Extract YouTube video comments with ease.
Retrieve essential comment details, including author information, reply count, and likes.
Option to include all replies to each comment.
Configurable to limit the maximum number of comments to scrape.
Typical Use Cases

Audience Engagement Analysis: Analyze the engagement and sentiment of comments on a specific YouTube video.
Content Improvement: Gain insights from user feedback to enhance video content.
Competitor Analysis: Monitor and analyze comments on competitors' videos.
Inputs

Data Input

The scraper takes the following inputs:

Start URLs: The URLs of the YouTube videos for which you want to scrape comments.
Maximum Comment Count: The maximum number of comments to scrape for each video.
Input Example

{
"startUrls": \["https://www.youtube.com/watch?v=ySA7mSgF54I"],
"maxCommentCount": 30,
"get_all_comments": false
}

Outputs

The scraper produces the following output for each comment:

Comment Author: The username of the comment author.
Author's Thumbnail: The URL of the author's profile thumbnail.
Comment Content: The content of the comment.
Reply Count: The number of replies to the comment.
Comment ID: The unique ID of the comment.
Comment Like Count: The number of likes on the comment.
Time Posted: The time when the comment was posted.
Output Example

{
"content": "The best country artist in a very long time to me",
"author": "@Allman2013",
"commentId": "UgwYXDX8ILkTIytauQR4AaABAg",
"publishedTime": "4 months ago",
"thumbnail": "https://yt3.ggpht.com/ytc/AIdro_ldjGNNBkVwkJPi3uO9izWA4BI69xAM2IlNxZV3vZIJL0qd=s88-c-k-c0x00ffffff-no-rj",
"channelId": "UCN7Ypfqdsh4ieWUvCXcneWw",
"isVerified": false,
"likeCount": "14 likes",
"replyCount": "0 replies"
}

Usage

How to Run the Scraper

Go to Apify and log in or create an account if you don't have one.
Create a new task and select the "YouTube Comment Scraper" scraper.
Configure the scraper's input settings by providing the YouTube video URLs and specifying the maximum number of comments to scrape.
(Optional) Set the "Include All Replies" input according to your preference.
Start the task and wait for it to complete.
Once the task is finished, you can access the scraped data in the task's dataset.
How to Interpret the Scraper's Results

The scraper will provide you with a JSON dataset containing the scraped YouTube video comments data. Each comment will have its own set of properties, as described in the "Outputs" section.

Examples

Example 1: Scraping a Specific Number of Comments.

In this example, we will scrape comments from a YouTube video, including all replies to each comment.

{
"startUrls": \["https://www.youtube.com/watch?v=example_video_id"],
"maxCommentCount": 30,
"get_all_comments": false
}

Example 2: Scraping all Comments

In this example, we will scrape comments from a YouTube video, excluding replies.

{
"startUrls": \["https://www.youtube.com/watch?v=example_video_id"],
"maxCommentCount": 30,
"get_all_comments": true
}

Troubleshooting

Common Problems and Solutions

Problem: The scraper is not returning any data.

Solution:

Ensure that the provided video URLs are correct, and the videos have comments available.

Problem: Rate limiting issues.

Solution:

If you encounter rate limiting issues, try adjusting the scraping speed or contact Apify support for assistance.

Additional Information

Links to Related Resources

Apify
Apify Documentation
Acknowledgements

This scraper is powered by Apify, a leading web scraping and automation platform. Special thanks to the Apify team for their contributions.

# Actor input Schema

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

URLs of YouTube videos to scrape comments from.

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

Maximum number of comments to scrape per video. The scraper will stop when this limit is reached. Default is 200.

## `requestIntervalMs` (type: `integer`):

Time in milliseconds to wait between processing requests. Helps to avoid overloading the server. Default is 1000ms (1 second).

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

Maximum number of concurrent pages to crawl. Default is 10.

## `maxRequestRetries` (type: `integer`):

Maximum number of times a request will be retried if it fails. Default is 3.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxComments": 200,
  "requestIntervalMs": 1000,
  "maxConcurrency": 10,
  "maxRequestRetries": 3
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("topaz_sharingan/youtube-comment-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": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"] }

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

```

## MCP server setup

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

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/ibPBz17Mvw5p0c5Im/builds/iWS3Kk33hPhkT0Mft/openapi.json
