# YouTube Comments Scraper + Sentiment Analysis (`confidential_gnat/youtube-comments-scraper-and-sentiment-analysis`) Actor

Scrape comments and replies from YouTube (youtube.com) videos: text, author, channel, likes, replies, pinned and creator-hearted flags, optional free sentiment analysis. Paste video, Shorts or youtu.be links, sort by top or newest, export JSON, CSV or Excel.

- **URL**: https://apify.com/confidential_gnat/youtube-comments-scraper-and-sentiment-analysis.md
- **Developed by:** [ActorFlow](https://apify.com/confidential_gnat) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

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

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

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

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

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

# README

## YouTube Comments Scraper

![YouTube Comments Scraper cover](https://i.postimg.cc/J49fD8My/Gemini-Generated-Image-gnr378gnr378gnr3.jpg)

**Scrape comments from YouTube (youtube.com)** videos: comment text, author, channel link, likes, reply count, pinned and creator-hearted flags, replies, optional **sentiment analysis** and the video title. Export to JSON, CSV or Excel, or call it as an **API**. Paste a **YouTube video URL**, sort by top or newest comments, and press Start.

**Target website:** [YouTube (youtube.com)](https://www.youtube.com)

### ✨ Features of this YouTube comments scraper

- **Comment extraction** — top-level comments from any public video, Short or youtu.be link, with author, channel, likes and reply count.
- **Replies** — switch on replies to collect the answers under each comment, linked to their parent by `parentCommentId`.
- **Pagination support** — keeps loading comment pages until it has the number of comments you asked for.
- **Sort by top or newest** — YouTube's default ranking or newest first.
- **Pinned and hearted flags** — see which comments the video owner pinned or hearted, and which were written by the owner.
- **Free sentiment analysis** — optional: label every comment positive, negative, neutral or mixed with a confidence score, at no extra charge.
- **Cache, new comments only** — use one cache name across scheduled runs and get only new comments.
- **Proxy support** — configurable Apify Proxy, off by default.
- **No browser required** — fast and cheap runs.

### 🚀 How to scrape YouTube comments in 5 steps

1. [Sign up](https://apify.com/sign-up) for a free Apify account — includes **$5 monthly credit**.
2. Open the actor page and click **Try for free**.
3. Paste one or more YouTube video URLs into **Video URLs**.
4. Click **Start** and wait for the run to complete.
5. Download results from the **Output** tab in JSON, CSV, or Excel format.

You can also run this actor via the [Apify API](https://docs.apify.com/api/v2) or integrate it directly into your workflows using [Zapier](https://zapier.com/apps/apify), [Make](https://www.make.com/), or [n8n](https://n8n.io/).

### 💰 Pricing for the YouTube comments scraper

This actor uses **pay-per-result** billing based on the compute units a run consumes.

- New Apify accounts include **$5 of free monthly credit**.
- It reads the data YouTube sends to its own pages instead of driving a browser, so it costs significantly less to run than browser-based scrapers.
- Proxies are off by default, which keeps runs cheapest.
- Comments skipped by the cache are not charged.
- **Sentiment analysis is free**: switching it on adds no extra charge to the run.

### 🖼️ YouTube comments scraper input screenshot

![YouTube Comments Scraper input form in Apify Console: video URLs, max comments per video, include replies, analyze sentiment, cache project name, sort comments by, and proxy configuration](https://i.postimg.cc/pdkcZMb8/image.png)

Numbered labels in the screenshot:

1. **Video URLs** — the YouTube videos to collect comments from.
2. **Max comments per video** — how many comments to save for each video.
3. **Include replies** — also collect the replies under each comment.
4. **Analyze sentiment** — label every comment positive, negative, neutral or mixed (free).
5. **Cache project name** — reuse the same name on scheduled runs to get only new comments.
6. **Sort comments by** — top comments or newest first.

The proxy configuration sits below these fields.

### 🔧 YouTube comments scraper input configuration

| Field | Type | Required | Default | Description |
| ----- | ---- | -------- | ------- | ----------- |
| Video URLs (`startUrls`) | array | ✅ | Rick Astley video (prefill) | YouTube videos to collect comments from: watch links, youtu.be short links, Shorts and embed links. |
| Max comments per video (`maxItems`) | integer | — | 5 | Maximum comments saved for each video, replies included when they are switched on. |
| Include replies (`includeReplies`) | boolean | — | false | Also collect the replies under each comment. Replies count towards the maximum and follow the comment they answer. |
| Analyze sentiment (`analyzeSentiment`) | boolean | — | false | Label every comment as positive, negative, neutral or mixed, with a confidence score. Free: no extra charge. |
| Cache project name (`cacheProjectName`) | string | — | — | Same name on each run = only new comments. Replies of a comment already in the cache are not opened again. |

**Sorting**

| Field | Type | Required | Default | Description |
| ----- | ---- | -------- | ------- | ----------- |
| Sort comments by (`sortBy`) | string | — | top | `top` (YouTube's default ranking) or `newest`. Use newest first together with the cache to collect only new comments on each run. |

**Proxy**

| Field | Type | Required | Default | Description |
| ----- | ---- | -------- | ------- | ----------- |
| Proxy configuration (`proxyConfiguration`) | object | — | no proxy | Works without a proxy for small runs. Switch on Apify Proxy for large runs or if YouTube starts blocking requests. |

**Supported URL types:**

- Watch link: `https://www.youtube.com/watch?v=dQw4w9WgXcQ`
- Short link: `https://youtu.be/dQw4w9WgXcQ`
- Shorts: `https://www.youtube.com/shorts/dQw4w9WgXcQ`
- Embed: `https://www.youtube.com/embed/dQw4w9WgXcQ`

### 📦 YouTube comments scraper output data

The output is a dataset of comment records with the fields `commentId`, `text`, `author`, `authorChannelId`, `authorChannelUrl`, `authorAvatar`, `likeCount`, `replyCount`, `publishedTimeText`, `isReply`, `parentCommentId`, `isPinned`, `isHeartedByCreator`, `isByVideoOwner`, `isVerifiedAuthor`, `videoId`, `videoUrl`, `videoTitle`, `scrapedAt` and, when sentiment analysis is on, `sentiment` and `sentimentConfidence`. The dataset has 3 views:

- **Overview** — author, comment text, likes, replies, age, whether it is a reply and the video title.
- **Sentiment** — author, comment text, sentiment label, confidence, likes and video (filled when sentiment analysis is on).
- **Pinned and hearted** — the flags the video owner sets: pinned, hearted, written by the owner, verified author, plus the author's channel link.

**Output at a glance:**

| Author | Comment | Likes | Replies | Published | Reply |
| ------ | ------- | ----- | ------- | --------- | ----- |
| @bdr8823 | My algebra teacher said that this was a link to th | 69000 | 622 | 7 years ago | no |
| @mattai075 | Nice 👌 | 1800 | 0 | 7 years ago | yes |

**Sample output (raw JSON):**

```json
[
  {
    "commentId": "UgwPwTibxdgqCHZxktd4AaABAg",
    "text": "My algebra teacher said that this was a link to the test answers",
    "author": "@bdr8823",
    "authorChannelId": "UCdi6tGxvFvTRGe-7dAn7m7w",
    "authorChannelUrl": "https://www.youtube.com/@bdr8823",
    "authorAvatar": "https://yt3.ggpht.com/ytc/AIdro_kcDoQJUNDkDzTrA5kaF5ADVujN-6UcDjMP2Kydtw=s88-c-k-c0x00ffffff-no-rj",
    "likeCount": 69000,
    "replyCount": 622,
    "publishedTimeText": "7 years ago",
    "isReply": false,
    "parentCommentId": null,
    "isPinned": false,
    "isHeartedByCreator": false,
    "isByVideoOwner": false,
    "isVerifiedAuthor": false,
    "videoId": "dQw4w9WgXcQ",
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "videoTitle": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
    "scrapedAt": "2026-10-22T10:10:39.096Z"
  },
  {
    "commentId": "UgwPwTibxdgqCHZxktd4AaABAg.8z9UZMV20LP8zHkGpHCUYu",
    "text": "Nice 👌",
    "author": "@mattai075",
    "authorChannelId": "UClfiseshZqVm85bQCVvPT0w",
    "authorChannelUrl": "https://www.youtube.com/@mattai075",
    "authorAvatar": "https://yt3.ggpht.com/6loFqKnWj-s6Ql5b1-HlqVJgWrBOUEJTWxLdmJLFe1LFFRXTq7vP-BKFoGLrmqEyLjxHe5Gd=s88-c-k-c0x00ffffff-no-rj",
    "likeCount": 1800,
    "replyCount": 0,
    "publishedTimeText": "7 years ago",
    "isReply": true,
    "parentCommentId": "UgwPwTibxdgqCHZxktd4AaABAg",
    "isPinned": false,
    "isHeartedByCreator": false,
    "isByVideoOwner": false,
    "isVerifiedAuthor": false,
    "videoId": "dQw4w9WgXcQ",
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "videoTitle": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
    "scrapedAt": "2026-10-22T10:10:39.096Z"
  }
]
```

### 🔁 Scrape only new YouTube comments with the cache

Set the same **Cache project name** on every scheduled run. Comments already saved under that name are skipped: they are not charged and do not count towards **Max comments per video**. Each name keeps its own separate cache. Combine it with **Sort comments by: Newest first**: the scraper stops as soon as it reaches a whole page of comments it already knows, so a scheduled run only reads the new ones. Replies of a comment already in the cache are not opened again. Add the actor to an Apify Schedule to monitor new comments on a video automatically.

### 🐍 How to scrape YouTube comments with Python, JavaScript or the API

Run the actor programmatically with the official Apify clients. Replace `<YOUR_API_TOKEN>` with the token from your [Apify Console](https://console.apify.com/account/integrations).

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")

run = client.actor("confidential_gnat/youtube-comments-scraper").call(run_input={
    "startUrls": [{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}],
    "maxItems": 100,
    "includeReplies": True,
    "analyzeSentiment": True,
    "sortBy": "top",
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**JavaScript** (`npm install apify-client`):

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });

const run = await client.actor('confidential_gnat/youtube-comments-scraper').call({
    startUrls: [{ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' }],
    maxItems: 100,
    includeReplies: true,
    analyzeSentiment: true,
    sortBy: 'top',
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**cURL** — start a run and wait for the dataset:

```bash
curl -X POST "https://api.apify.com/v2/acts/confidential_gnat~youtube-comments-scraper/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"startUrls":[{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}],"maxItems":100,"includeReplies":true,"analyzeSentiment":true,"sortBy":"top"}'
```

### 💡 What you can use YouTube comment data for

- Sentiment analysis of audience reactions to a video, ad or product launch
- Brand and reputation monitoring: new comments on your own or competitors' videos
- Finding questions, feature requests and complaints in the comments of tutorial and review videos
- Influencer and creator research: who engages, what gets liked and what the creator hearts or pins
- Training and evaluating text models on real conversation threads

Marketers, community managers, researchers and data teams typically use this data across media, e-commerce, education and entertainment.

### ⚠️ Limitations of the YouTube comments scraper

- **Comment depth** — sorted by top, YouTube serves roughly 1,200 top-level comments per video, even when the video has millions; sorted by newest first it goes much deeper (tens of thousands in testing). To get more, use newest first.
- **Rounded likes** — YouTube shows likes as "1.5K" above a thousand, so `likeCount` is rounded the same way.
- **Relative dates** — YouTube only shows the age of a comment ("2 days ago"), so `publishedTimeText` is not an exact date.
- **Comments turned off** — videos with comments disabled return nothing; the run logs a warning.
- **Video links only** — channel pages and playlists are not accepted; paste the video links you want.
- **Login-required content** — age-restricted or members-only videos and comments behind a login are not collected.

### ❓ YouTube comments scraper FAQ

#### Can I scrape YouTube comments legally?

The actor only collects comments that are already publicly visible on YouTube — no login, paywall or private content is accessed. Scraping publicly available data is generally considered lawful (see *hiQ Labs v. LinkedIn*), but you are responsible for complying with YouTube's Terms of Service and applicable laws such as GDPR or CCPA, since comments contain personal data like names and profile links.

#### What data does the YouTube comments scraper return?

Each record has the comment text, author name, channel link and avatar, likes, reply count, age, whether it is a reply and which comment it answers, the pinned, hearted, owner and verified flags, and the video id, link and title.

#### How many comments can I scrape from one YouTube video?

`maxItems` limits the comments saved for each video, not the whole run, and replies count towards it when they are switched on. The scraper keeps loading comment pages until it has that many or YouTube stops serving more. Sorted by top, YouTube serves roughly 1,200 top-level comments per video, even when the video has millions; sorted by newest first it goes much deeper, so use newest first for very large pulls.

#### Do I need a proxy to scrape YouTube comments?

No for small runs: the input defaults to no proxy, which is cheapest. For large runs or many videos at once, switch on Apify Proxy in the proxy field.

#### How do I scrape YouTube comments with Python?

Use the Python example above: call the actor with the Apify client and iterate over the dataset items.

#### Can I run this YouTube comments scraper on a schedule?

Yes. Use Apify Schedules to run it daily or hourly. Set a **Cache project name** and sort by **Newest first**, and each run returns only the comments posted since the last one; comments already seen are skipped and not charged.

#### How does the sentiment analysis work, and does it cost extra?

Switch on **Analyze sentiment** and every comment gets a `sentiment` label (positive, negative, neutral or mixed) and a `sentimentConfidence` from 0 to 1. It is free: there is no extra charge for it, only the normal result cost of the run. Comments with no text, or that could not be classified, get an empty sentiment instead of failing the run.

#### What output formats are supported?

JSON, CSV, Excel, XML and RSS, either from the **Output** tab or through the Apify API.

### 🔗 Relevant actors for YouTube data

| Scraper | Description |
| ------- | ----------- |
| [▶️ YouTube Video List Scraper](https://apify.com/confidential_gnat/youtube-video-list-scraper) | Scrape video listings from YouTube channels and playlists, with optional details. |
| [📺 YouTube Channel Info and Stats Scraper](https://apify.com/confidential_gnat/youtube-channel-info-and-stats) | Scrape channel info and statistics from YouTube channel About pages. |
| [⬇️ YouTube Video Downloader](https://apify.com/confidential_gnat/youtube-video-downloader) | Download YouTube videos, Shorts, playlists and channels as MP4, MP3 and more. |
| [⭐ Google Play Reviews Scraper](https://apify.com/confidential_gnat/google-play-reviews-scraper) | Scrape user reviews from Google Play Store apps, including review text. |
| [🍷 Vivino Wine Reviews Scraper](https://apify.com/confidential_gnat/vivino-reviews-scraper) | Scrape user reviews and tasting notes from Vivino, including the review text. |

### 🔗 Other actors you may find useful

| Scraper | Description |
| ------- | ----------- |
| [💼 Dice Jobs Scraper](https://apify.com/confidential_gnat/dice-jobs-scraper) | Scrape tech job listings from Dice: title, company, location and employment type. |
| [📈 Kalshi Markets Scraper](https://apify.com/confidential_gnat/kalshi-markets-scraper) | Scrape Kalshi prediction markets: yes/no prices, implied probability and volume. |
| [🏠 Otodom Property Scraper](https://apify.com/confidential_gnat/otodom-property-scraper) | Scrape property listings from Otodom.pl: price, area, rooms and address. |
| [✈️ Kiwi.com Flight Scraper](https://apify.com/confidential_gnat/kiwi-flight-scraper) | Scrape flight prices and schedules from Kiwi.com, including airline and times. |
| [🛒 Craigslist Listings Scraper](https://apify.com/confidential_gnat/craigslist-listings-scraper) | Scrape Craigslist listings in any city and category: title, price and more. |

### 💬 Support & contact

If you encounter any issues or have questions, please [open an issue](https://apify.com/confidential_gnat/youtube-comments-scraper/issues/open) or reach out via the [Apify Community Forum](https://community.apify.com/).

You can also find more of our actors on the [Actor Flow](https://apify.com/confidential_gnat) page.

# Actor input Schema

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

YouTube videos to collect comments from: watch links (https://www.youtube.com/watch?v=dQw4w9WgXcQ), short links (https://youtu.be/dQw4w9WgXcQ), Shorts and embed links.

## `maxItems` (type: `integer`):

Maximum comments saved for each video, replies included when they are switched on.

## `includeReplies` (type: `boolean`):

Also collect the replies under each comment. Replies count towards the maximum and follow the comment they answer.

## `analyzeSentiment` (type: `boolean`):

Label every comment as positive, negative, neutral or mixed, with a confidence score. Free: no extra charge.

## `cacheProjectName` (type: `string`):

Use the same name on each scheduled run to get only new comments. Comments already saved under this name are skipped and not charged. Replies of a comment already in the cache are not opened again.

## `sortBy` (type: `string`):

Top comments (YouTube's default ranking) or newest first. Use newest first together with the cache to collect only new comments on each run.

## `proxyConfiguration` (type: `object`):

Works without a proxy for small runs. Switch on Apify Proxy for large runs or if YouTube starts blocking requests.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "maxItems": 5,
  "includeReplies": false,
  "analyzeSentiment": false,
  "sortBy": "top",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `comments` (type: `string`):

No description

# 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=dQw4w9WgXcQ"
        }
    ],
    "maxItems": 5,
    "analyzeSentiment": false,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("confidential_gnat/youtube-comments-scraper-and-sentiment-analysis").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=dQw4w9WgXcQ" }],
    "maxItems": 5,
    "analyzeSentiment": False,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("confidential_gnat/youtube-comments-scraper-and-sentiment-analysis").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": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "maxItems": 5,
  "analyzeSentiment": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call confidential_gnat/youtube-comments-scraper-and-sentiment-analysis --silent --output-dataset

```

## MCP server setup

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

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/JDtOJnqdvY81cp4O6/builds/MxU9ypLMMbx3ckEMb/openapi.json
