# YouTube Comments Scraper (`streamers/youtube-comments-scraper`)

This alternative YouTube Data API has no limits or quotas. Extract YouTube comments data from one or multiple YouTube videos: full comment text, posting date, author username, video title, videoId. Download YouTube comments in JSON, CSV, and Excel.

- **URL**: https://beta-securitybyobscurity.apify.com/streamers/youtube-comments-scraper.md
- **Developed by:** [Streamers](https://beta-securitybyobscurity.apify.com/streamers) (Apify)
- **Categories:** Videos, Social media
- **Stats:** 8,473 total users, 1,009 monthly users, 99.4% runs succeeded, 191 bookmarks
- **User rating**: 4.98 out of 5 stars

## Pricing

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

# README

### What is YouTube Comment Scraper?

YouTube Comments Scraper is a data extraction tool created for scraping comments from YouTube that goes beyond the standard YouTube API. As soon as you provide a video URL, you will be able to extract:

- **All comments** from chosen YouTube videos
- **Comment text**, author name, **date posted**, vote count, reply count
- Whether it **has been liked** by the video’s creator
- **Total comment count**

### How to use data extracted from YouTube comments

- **Monitor competitors’ comments** to see mentions of your brand
- Find **current trends** and **opinions** shared by commenters
- **Analyze comments** to find potential for expansion
- Use extracted data for **sentiment analysis**
- **Identify harmful** or **illegal** comments
- Get **quick insight** into what your community is doing and he opinions they hold

### How do I use YouTube Comment Scraper?

YouTube Comments Scraper is designed to be user-friendly, even for those who have never extracted data from YouTube before. Here’s how you can use YouTube Comment Scraper to extract YouTube comment data:

1. [Create](https://console.apify.com/actors/p7UMdpQnjKmmpR21D?addFromActorId=p7UMdpQnjKmmpR21D) an Apify account
2. Open [YouTube Comments Scraper](https://apify.com/streamers/youtube-comments-scraper)
3. Add one or more YouTube video URLs to scrape comments
4. Click the “Start” button and wait for the data to be extracted
5. Download your data in JSON, XML, CSV, Excel, or HTML

For more information, watch our [short video tutorial](https://www.youtube.com/watch?v=LOmod3V9pZw).

https://www.youtube.com/watch?v=LOmod3V9pZw

### ⬇️ Input example

The input for YouTube Comments Scraper should be a **YouTube video URL.** You can add as many URLs as you want, or even import a CSV file or Google Sheet with a prepared list of URLs.

<a href="https://console.apify.com/actors/p7UMdpQnjKmmpR21D/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-comments-scraper-input.png?raw=true" alt="YouTube Comments Scraper input" style="width:70%;">
</a>

Once you’ve entered the URL, you can choose how many results you would like to extract and then click “Start.” Click on the [input tab](https://apify.com/streamers/youtube-comments-scraper/input-schema) for a full explanation of an input example in JSON.

```json
{
    "maxComments": 300,
    "startUrls": [
        {
            "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
            "method": "GET"
        }
    ]
}
```

### ⬆️ Output sample

The scraped YouTube comments will be shown as a dataset which you can find in the **Storage** tab. Note that the output is organized as a table for viewing convenience, but it doesn’t show **all the fields**:

<a href="https://console.apify.com/actors/p7UMdpQnjKmmpR21D/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-comments-scraper-output.png?raw=true" alt="YouTube Comments Scraper output" style="width:70%;">
</a>

You can preview all the fields and choose in which format to download the YouTube comments you’ve extracted: JSON, Excel, HTML table, CSV, or XML. Here below is the same dataset in JSON:

```json
{
    "comment": "This is up there with their best songs.",
    "cid": "UgxRn0_LUxzRP2MybPR4AaABAg",
    "author": "@Nonie_Jay",
    "videoId": "bJTjJtRPqYE",
    "pageUrl": "<https://www.youtube.com/watch?v=bJTjJtRPqYE>",
    "commentsCount": 171,
    "replyCount": 0,
    "voteCount": 2,
    "authorIsChannelOwner": false,
    "hasCreatorHeart": false,
    "type": "comment",
    "replyToCid": null,
    "title": "Halestorm - Unapologetic [Official Audio]"
  },
 

```

### Want to try other YouTube APIs and scrapers?

If you want to extract specific YouTube data, you can use one of the specialized scrapers below, each built particularly for the relevant YouTube data scraping case, whether it's shorts, comments, or channels:

- ▶️ [YouTube Scraper](https://apify.com/streamers/youtube-scraper)
- 🏎 [Fast YouTube Channel Scraper](https://apify.com/streamers/youtube-channel-scraper)
- ▶️ [YouTube Shorts Scraper](https://apify.com/streamers/youtube-shorts-scraper)
- 📽️ [YouTube Video Scraper by Hashtag](https://apify.com/streamers/youtube-video-scraper-by-hashtag)

If you need to download scraped YouTube videos, you can use [YouTube Video Downloader](https://apify.com/pocesar/download-youtube-video).

You can also combine YouTube data with that from other social networks using any of the following scrapers:

- [TikTok scrapers](https://apify.com/clockworks)
- [Instagram scrapers](https://apify.com/store/categories?search=instagram\&managedBy=APIFY)
- [Facebook scrapers](https://apify.com/store/categories?search=facebook\&managedBy=APIFY)
- Or try our other [social media scrapers](https://apify.com/store?category=SOCIAL_MEDIA).

Furthermore, you can use the power of AI agents to do multiple tasks at one. For example, our [Comments Analyzer Agent](https://apify.com/apify/comments-analyzer-agent) can perform sentiment analysis of YouTube videos, or you could try our [Influencer Discovery Agent](https://apify.com/apify/influencer-discovery-agent) for lead generation on TikTok videos.

### Integrating YouTube Shorts Scraper with other apps

YouTube Scraper can be connected with almost any cloud service or web app thanks to [integrations](https://apify.com/integrations) on the Apify platform. These include [Make](https://docs.apify.com/platform/integrations/make), [Zapier](https://docs.apify.com/platform/integrations/zapier), [Slack](https://docs.apify.com/platform/integrations/slack), [Airbyte](https://docs.apify.com/platform/integrations/airbyte), [GitHub](https://docs.apify.com/platform/integrations/github), [Google Drive](https://docs.apify.com/platform/integrations/drive), and [plenty more](https://docs.apify.com/platform/integrations).

Alternatively, you can use [webhooks](https://docs.apify.com/platform/integrations/webhooks) to carry out an action whenever an event occurs, e.g. get a notification whenever YouTube Scraper successfully finishes a run, or initiate a new process, like ordering your data.

### FAQ

#### Is YouTube comments scraping legal?

Our [YouTube scrapers](https://apify.com/store?search=youtube) are ethical and **do not extract any private user data, such as email addresses, gender, or location**. They only extract what the user has chosen to share publicly. However, you should be aware that your **results could contain personal data.** You should not scrape personal data unless you have a legitimate reason to do so.

If you're unsure whether your reason is legitimate, consult your lawyers. You can also read our blog post on the [legality of web scraping](https://blog.apify.com/is-web-scraping-legal/) and [ethical scraping](https://blog.apify.com/what-is-ethical-web-scraping-and-how-do-you-do-it/).

#### Do I need proxies to scrape YouTube comments?

If you run the scraper on the Apify platform, for successful YouTube scraping you will need [residential proxies](https://apify.com/proxy?pricing=residential-ip#pricing) which are included in Apify's **monthly Starter plan**.

For more details about how our pricing works, platform credits, proxies, and usage, see the [platform pricing page](https://apify.com/pricing/actors).

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

Yes. You can do so using Apify API which will enable you to manage, schedule, and run any Apify Actors, including this one. The API also lets you access any datasets, monitor Actor performance, fetch results, create and update versions, and more. To access the API using Node.js, use the `apify-client` [NPM package](https://apify.com/streamers/youtube-comments-scraper/api/javascript). To access the API using Python for scraping YouTube comments, use the `apify-client` [PyPi package](https://apify.com/streamers/youtube-comments-scraper/api/python).

Check out the [Apify API reference](https://docs.apify.com/api/v2) docs for full details or click on the [API tab](https://apify.com/streamers/youtube-comments-scraper/api/python) for code examples.

#### Can I use YouTube Scraper through an MCP Server?

With Apify API, you can use almost any Actor in conjunction with an MCP server. You can connect to the MCP server using clients like ClaudeDesktop and LibreChat, or even build your own. Read all about how you can [set up Apify Actors with MCP](https://blog.apify.com/how-to-use-mcp/).

For YouTube Scraper, go to the [MCP tab](https://apify.com/streamers/youtube-comments-scraper/api/mcp) and then go through the following steps:

1. Start a Server-Sent Events (SSE) session to receive a `sessionId`
2. Send API messages using that `sessionId` to trigger the scraper
3. The message starts the Amazon ASINs Scraper with the provided input
4. The response should be: `Accepted`

#### Your feedback

We’re always working on improving the performance of our Actors. So if you’ve got any technical feedback for YouTube Comment Scraper or simply found a bug, please create an issue on the Actor’s [Issues tab](https://apify.com/streamers/youtube-comments-scraper/issues/open).

# Actor input Schema

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

Enter a link to a specific Youtube video <a href='https://www.youtube.com/watch?v=xObhZ0Ga7EQ' target='_blank' rel='noopener'>YouTube video</a>. You can also import a CSV file or Google Sheet with a list of URLs.<br>

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

Limit the number of comments you want to scrape per video.

## `commentsSortBy` (type: `string`):

Select Youtube sorting parameter for comments

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=xObhZ0Ga7EQ"
    }
  ],
  "maxComments": 10,
  "commentsSortBy": "1"
}
```

# 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": [
        {
            "url": "https://www.youtube.com/watch?v=xObhZ0Ga7EQ"
        }
    ],
    "maxComments": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("streamers/youtube-comments-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": [{ "url": "https://www.youtube.com/watch?v=xObhZ0Ga7EQ" }],
    "maxComments": 10,
}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments Scraper",
        "description": "This alternative YouTube Data API has no limits or quotas. Extract YouTube comments data from one or multiple YouTube videos: full comment text, posting date, author username, video title, videoId. Download YouTube comments in JSON, CSV, and Excel.",
        "version": "0.0",
        "x-build-id": "hT6tsHe7jQAFye3Vu"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/streamers~youtube-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-streamers-youtube-comments-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/streamers~youtube-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-streamers-youtube-comments-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/streamers~youtube-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-streamers-youtube-comments-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": "Direct video URLs",
                        "type": "array",
                        "description": "Enter a link to a specific Youtube video <a href='https://www.youtube.com/watch?v=xObhZ0Ga7EQ' target='_blank' rel='noopener'>YouTube video</a>. You can also import a CSV file or Google Sheet with a list of URLs.<br>",
                        "default": [],
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxComments": {
                        "title": "Maximum comments",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Limit the number of comments you want to scrape per video.",
                        "default": 1
                    },
                    "commentsSortBy": {
                        "title": "Sorting order",
                        "enum": [
                            "0",
                            "1"
                        ],
                        "type": "string",
                        "description": "Select Youtube sorting parameter for comments",
                        "default": "1"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
