# 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:** 160 total users, 0 monthly users, 100.0% runs succeeded, 8 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

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

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("💾 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": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ]
}' |
apify call topaz_sharingan/youtube-comment-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Youtube Comment Scraper",
        "description": "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",
        "version": "0.0",
        "x-build-id": "iWS3Kk33hPhkT0Mft"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/topaz_sharingan~youtube-comment-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-topaz_sharingan-youtube-comment-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/topaz_sharingan~youtube-comment-scraper/runs": {
            "post": {
                "operationId": "runs-sync-topaz_sharingan-youtube-comment-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/topaz_sharingan~youtube-comment-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-topaz_sharingan-youtube-comment-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": "URLs of YouTube videos to scrape comments from.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxComments": {
                        "title": "Maximum Comments",
                        "type": "integer",
                        "description": "Maximum number of comments to scrape per video. The scraper will stop when this limit is reached. Default is 200.",
                        "default": 200
                    },
                    "requestIntervalMs": {
                        "title": "Request Interval (ms)",
                        "type": "integer",
                        "description": "Time in milliseconds to wait between processing requests. Helps to avoid overloading the server. Default is 1000ms (1 second).",
                        "default": 1000
                    },
                    "maxConcurrency": {
                        "title": "Max Concurrency",
                        "type": "integer",
                        "description": "Maximum number of concurrent pages to crawl. Default is 10.",
                        "default": 10
                    },
                    "maxRequestRetries": {
                        "title": "Max Request Retries",
                        "type": "integer",
                        "description": "Maximum number of times a request will be retried if it fails. Default is 3.",
                        "default": 3
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
