# YouTube Comments Scraper | (`alpha-scraper/youtube-comments-scraper`) Actor

\[ ✨YouTube Comments Scraper ]
Fast & Reliable Scraper
Extract CID, type, publish time, comments, author & page URL in seconds
Streamline workflow, save time & gather structured data
Perfect for research, analysis & business insights .

- **URL**: https://apify.com/alpha-scraper/youtube-comments-scraper.md
- **Developed by:** [Alpha Scraper](https://apify.com/alpha-scraper) (community)
- **Categories:** Social media, Videos, Other
- **Stats:** 10 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$9.99/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

## 🎥 YouTube Comments Scraper

**Quickly extract structured comment data from one or more YouTube videos — including comment text, author info, timestamps, votes, and raw fields.**

Built to run as an **Apify actor**. This README shows a summary, inputs, outputs, examples, troubleshooting tips and proxy recommendations. 🔧

---

### ✨ Summary

This actor scrapes comments from YouTube video URLs and returns structured JSON objects per video, including:

* 💬 **Comments** (text, id, author, replies, likes/votes, timestamps)
* 👤 **Author info** (author name, author id, author url, avatar if available)
* 🧾 **Video metadata** (video id, video url, title, best-effort commentsCount)
* 📦 **Raw payload** — the original raw comment object is preserved for every comment so you don’t lose any fields.

**Key points:**

* Input: one or more YouTube video URLs (`startUrls`).
* Optional: `maxComments` to limit how many comments per video are scraped.
* Optional: `getAllComments` to ignore `maxComments` and fetch all available comments.
* Optional: `sortBy` — `top` (highest votes first) or `newest` (most recent first).


---

### 🚀 Highlights

* ⚡ Fast, structured output — one JSON object per video run.
* 🧩 Preserves full `raw` comment object for custom fields.
* 🎯 Exact `maxComments` support (when `getAllComments` is `false`) and `getAllComments` toggle.
* 🌐 Proxy-aware (Apify Proxy recommended for stability) — use RESIDENTIAL for best results.
* 🔁 Supports sorting by `top` or `newest`.

---

### 🛠️ Example Input

```json
{
  "startUrls": [
    "https://www.youtube.com/watch?v=wT4HcYAeV5U",
    "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  ],
  "maxComments": 100,
  
  "sortBy": "top",
}
````

***

### 📤 Output

For every video the actor writes results both to the Apify dataset and to container files:

- `output_<videoId>.json` — full JSON object for the video (including `comments` array).
- `comments_<videoId>.jsonl` — newline-delimited JSON with one comment per line (good for streaming).
- Apify dataset entry for each video — downloadable from the Apify Console. ☁️

#### Example output (one video object)

```json
{
  "videoUrl": "https://www.youtube.com/watch?v=wT4HcYAeV5U",
  "videoId": "wT4HcYAeV5U",
  "title": "YouTube",
  "commentsCount": null,
  "comments": [
  
  {
    "cid": "Ugxl_IUyS2PaN9t-_wV4AaABAg",
    "type": "comment",
    "publishedTimeText": "7 hours ago",
    "publishedTimeTs": 1759729079.617027,
    "comment": "Madhubanti + Rashmika = 🔥",
    "author": "@maddockfilmsindia",
    "authorId": null,
    "authorUrl": null,
    "authorThumbnail": null,
    "replyCount": 7,
    "voteCount": 5,
    "isHearted": false,
    "isEdited": false,
    "raw": {
      "cid": "Ugxl_IUyS2PaN9t-_wV4AaABAg",
      "text": "Madhubanti + Rashmika = 🔥",
      "time": "7 hours ago",
      "author": "@maddockfilmsindia",
      "channel": "UCGgi8DSEirlGCQ3B3bO5BsQ",
      "votes": "5",
      "replies": "7",
      "photo": "https://yt3.ggpht.com/bhYAlBYCO9k-CfeGL42c3db-vBGi-3vLwQFgXWrQgHAstpaqE5LxHdIHDYdJ0RVje0-v5j7RLQ=s88-c-k-c0x00ffffff-no-rj",
      "heart": false,
      "reply": false,
      "time_parsed": 1759729079.616943
    },
    "videoId": "H6l0q4l2NLo",
    "pageUrl": "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  },
  {
    "cid": "UgxR7iZmrx-cvVYyIZJ4AaABAg",
    "type": "comment",
    "publishedTimeText": "10 hours ago",
    "publishedTimeTs": 1759718280.088529,
    "comment": "This song honestly has the soul of Aaj Ki Raat.\nFeels like Sachin–Jigar were asked to recreate that same vibe — and they pulled it off.\nJust try singing Aaj Ki Raat over this track and you’ll get exactly what I mean",
    "author": "@saho_x",
    "authorId": null,
    "authorUrl": null,
    "authorThumbnail": null,
    "replyCount": 1,
    "voteCount": 4,
    "isHearted": false,
    "isEdited": false,
    "raw": {
      "cid": "UgxR7iZmrx-cvVYyIZJ4AaABAg",
      "text": "This song honestly has the soul of Aaj Ki Raat.\nFeels like Sachin–Jigar were asked to recreate that same vibe — and they pulled it off.\nJust try singing Aaj Ki Raat over this track and you’ll get exactly what I mean",
      "time": "10 hours ago",
      "author": "@saho_x",
      "channel": "UCnVC00Vv0foM0EKkz6Y1iWQ",
      "votes": "4",
      "replies": "1",
      "photo": "https://yt3.ggpht.com/TUTguFWKoy3k8SUTycBbxzhJ3T7B6enA0MGQqsE77VSCl8YeL4p8dK9iZu1QZ5gqGj_IWqN3=s88-c-k-c0x00ffffff-no-rj",
      "heart": false,
      "reply": false,
      "time_parsed": 1759718280.088388
    },
    "videoId": "H6l0q4l2NLo",
    "pageUrl": "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  },
  {
    "cid": "UgyDoXT2Qt9yi8s_K0V4AaABAg",
    "type": "comment",
    "publishedTimeText": "16 hours ago",
    "publishedTimeTs": 1759696680.562509,
    "comment": "Thama Massive Hit Hai 💯🔥",
    "author": "@KAMALBOLTAHAI",
    "authorId": null,
    "authorUrl": null,
    "authorThumbnail": null,
    "replyCount": 0,
    "voteCount": 2,
    "isHearted": false,
    "isEdited": false,
    "raw": {
      "cid": "UgyDoXT2Qt9yi8s_K0V4AaABAg",
      "text": "Thama Massive Hit Hai 💯🔥",
      "time": "16 hours ago",
      "author": "@KAMALBOLTAHAI",
      "channel": "UC7QK8aH2kx8kV3ZDb78gudg",
      "votes": "2",
      "replies": "",
      "photo": "https://yt3.ggpht.com/-dSC3L4wVQlPFXaE1DQ0pa861J_1gJmKr0whQ_OBAVuC_du6rp3UNXtb9mIImMk2akwNfj1-=s88-c-k-c0x00ffffff-no-rj",
      "heart": false,
      "reply": false,
      "time_parsed": 1759696680.562357
    },
    "videoId": "H6l0q4l2NLo",
    "pageUrl": "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  },
  {
    "cid": "UgxjmCCpexYiRfqxtOZ4AaABAg",
    "type": "comment",
    "publishedTimeText": "52 minutes ago",
    "publishedTimeTs": 1759751159.068628,
    "comment": "🗿AAJ KI RAAT 2.0✅",
    "author": "@SANJAY_GALAXY_369",
    "authorId": null,
    "authorUrl": null,
    "authorThumbnail": null,
    "replyCount": 0,
    "voteCount": 1,
    "isHearted": false,
    "isEdited": false,
    "raw": {
      "cid": "UgxjmCCpexYiRfqxtOZ4AaABAg",
      "text": "🗿AAJ KI RAAT 2.0✅",
      "time": "52 minutes ago",
      "author": "@SANJAY_GALAXY_369",
      "channel": "UC1aOBn-22LWDKOXIEjWpaBQ",
      "votes": "1",
      "replies": "",
      "photo": "https://yt3.ggpht.com/PgPHT8B88ib2qteQGAaQe_zQWPs5D4hQHM6xlyBijbL0paF_AUO6VPdj0eH49QCT5o_5JiVa=s88-c-k-c0x00ffffff-no-rj",
      "heart": false,
      "reply": false,
      "time_parsed": 1759751159.068529
    },
    "videoId": "H6l0q4l2NLo",
    "pageUrl": "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  },
  {
    "cid": "UgxieB4nLFkp3lMGhY94AaABAg",
    "type": "comment",
    "publishedTimeText": "7 hours ago",
    "publishedTimeTs": 1759729079.616322,
    "comment": "Aaj Ki Raat 2.0 ❤",
    "author": "@maddockfilmsindia",
    "authorId": null,
    "authorUrl": null,
    "authorThumbnail": null,
    "replyCount": 0,
    "voteCount": 1,
    "isHearted": false,
    "isEdited": false,
    "raw": {
      "cid": "UgxieB4nLFkp3lMGhY94AaABAg",
      "text": "Aaj Ki Raat 2.0 ❤",
      "time": "7 hours ago",
      "author": "@maddockfilmsindia",
      "channel": "UCGgi8DSEirlGCQ3B3bO5BsQ",
      "votes": "1",
      "replies": "",
      "photo": "https://yt3.ggpht.com/bhYAlBYCO9k-CfeGL42c3db-vBGi-3vLwQFgXWrQgHAstpaqE5LxHdIHDYdJ0RVje0-v5j7RLQ=s88-c-k-c0x00ffffff-no-rj",
      "heart": false,
      "reply": false,
      "time_parsed": 1759729079.616239
    },
    "videoId": "H6l0q4l2NLo",
    "pageUrl": "https://www.youtube.com/watch?v=H6l0q4l2NLo"
  },
  ]
  "scrapedCount": 1
}
```

***

### 📑 Typical fields

| Field                   | Description                                      |
| ----------------------- | ------------------------------------------------ |
| `videoUrl`              | Input video URL                                  |
| `videoId`               | YouTube video ID                                 |
| `title`                 | Best-effort page title (if available)            |
| `commentsCount`         | Best-effort comment count (may be `null`)        |
| `comments`              | Array of comment objects                         |
| `comments[].cid`        | Comment unique id                                 |
| `comments[].comment`    | Comment text                                     |
| `comments[].author`     | Author display name                              |
| `comments[].authorId`   | Author channel id (if available)                 |
| `comments[].authorUrl`  | Author channel URL (if available)                |
| `comments[].authorThumbnail` | Author avatar URL (if available)           |
| `comments[].publishedTimeText` | Human readable time (e.g. "2 days ago") |
| `comments[].publishedTimeTs` | Parsed timestamp (when parseable)           |
| `comments[].replyCount` | Number of replies                                |
| `comments[].voteCount`  | Likes / votes count (if available)               |
| `comments[].isHearted`  | Whether channel owner hearted the comment        |
| `comments[].isEdited`   | Whether the commenter edited the comment         |
| `comments[].raw`        | Full raw object returned by underlying parser    |

***

### 🧩 Troubleshooting

| Issue                         | Possible Cause                             | Fix / Tip                                                      |
| ----------------------------  | ------------------------------------------ | --------------------------------------------------------------- |
| Empty dataset                 | Wrong video URL or comments disabled       | Verify URLs and check video has comments; try another video.    |
| Fewer comments than expected  | `maxComments` limit or generator yielded fewer | Set `getAllComments=true` or increase `maxComments`             |
| `commentsCount` is null       | Not present in page HTML                   | Use `comments[].raw` to inspect raw payload for count           |
| Partial metadata              | Fields hidden or loaded dynamically        | Check `raw` field; consider retries with proxy                 |
| Rate limiting / 429 errors    | Too many requests without proxy            | Use Apify Proxy RESIDENTIAL or reduce concurrency               |

***

## Here my another actors :

### Youtube Iteams:

- [🎶 Youtube Audio Downloader (Video/Shorts)](https://console.apify.com/actors/lTUPL4gmLTDNXBeWw/source)
- [Youtube Video Downloader Advanced](https://console.apify.com/actors/XOpQsUkgGZLGSCJd0/source)
- [Youtube Video Downloader ( Soundless )](https://console.apify.com/actors/gFsczW1QplIquv9eL/source)
- [Youtube Video Downloader](https://console.apify.com/actors/9kZQcUlHZRKp1ilZA/source)
- [Youtube Video Details Scraper](https://console.apify.com/actors/On4VfiWjGnT79clm1/source)
- [Youtube Transcript Ninja (Subtitles) ](https://console.apify.com/actors/eWrsJHhdeEbVHChpX/source)
- [Youtube Thumbnails Downloader & Scraper](https://console.apify.com/actors/YShot3wkL0HJdRkD0/source)
- [Youtube Tags or Hashtags Scraper](https://console.apify.com/actors/O1FU99ID2ccR5wcS8/source)
- [Youtube Tags Scraper](https://console.apify.com/actors/1wVokAhQLbbeeFVfR/source)
- [Youtube Shorts Scraper lite](https://console.apify.com/actors/bOyWDt1IbXZsadWRp/source)
- [Youtube Shorts Downloader Pro](https://console.apify.com/actors/bN1AjNRMops81rGkg/source)
- [Youtube Shorts Comments Scraper](https://console.apify.com/actors/ON1C4qgHaEQEhhEmI/source)
- [Youtube Community Posts Scraper](https://console.apify.com/actors/X38E51BParHFNaCw1/source)
- [Youtube Channel Id Scraper Pro](https://console.apify.com/actors/2uuIEovgGHcYjEKyN/source)
- [Youtube Video Transcript  Scraper ( Subtitles )](https://console.apify.com/actors/IEmSN6FkNn0tw10BA/source)
- [Youtube Video Comments Scraper](https://console.apify.com/actors/URh4zBT1aesfE8QKc/source)
- [Youtube Shorts Scraper  Pro](https://console.apify.com/actors/G4McyHJJzc2TbUSo6/source)
- [Youtube Shorts Scraper](https://console.apify.com/actors/XP0WgKweF1M83FnmR/source)
- [Youtube Channel Scraper](https://console.apify.com/actors/ufMZfwMgyHeaoDdAd/source)
- [YouTube Video Description Extractor](https://console.apify.com/actors/Xqae3CmxqT3HfHaJ5/source)
- [YouTube Hashtag Scraper](https://console.apify.com/actors/d4bYqQ0LWuczEgumx/source)
- [YouTube Description Scraper pro](https://console.apify.com/actors/OVymx0bku0C8gowB0/source)
- [YouTube Comments Scraper | Pay Per Result](https://console.apify.com/actors/ict6AecoJ85T4RthZ/source)
- [YouTube Channel ID Scraper](https://console.apify.com/actors/P9XlG8ylMGqfoelOg/source)

### Tiktok Iteams:

- [Tiktok Video Downloader](https://console.apify.com/actors/dlyQGIrqOracdqOeb/source)
- [Tiktok Video Details Scraper Pro](https://console.apify.com/actors/kZMMAHBehLOdG2FBb/source)
- [Tiktok Profile Scraper](https://console.apify.com/actors/C9mdCvPs7mDV8AYdd/source)
- [TikTok Video Scraper](https://console.apify.com/actors/7NjipRJbS73X9Io90/source)
- [TikTok Profile Videos Scraper](https://console.apify.com/actors/F6ar6Hu5STLp5mdAf/source)
- [TikTok Profile Scraper pro](https://console.apify.com/actors/3fmkMmoCBQ4SBIIAN/source)
- [TikTok Audio Downloader 🎵](https://console.apify.com/actors/jHipu7fQihSVhBE3x/source)

### Snapchat Iteams:

- [Snapchat Video Downloader (Spotlight )](https://console.apify.com/actors/yKz99HNmn4AgmhPOf/source)
- [Snapchat Video  Details Scraper (Spotlight)](https://console.apify.com/actors/fyV48EkRqcNoeq2kH/source)
- [Snapchat Followers Scraper](https://console.apify.com/actors/PxBiNYw0mgZOagGyD/source)
- [Snapchat Profile     Scraper](https://console.apify.com/actors/siCUsZdm6xmc3g7HF/source)
- [Snapchat Profile Scraper  Mini](https://console.apify.com/actors/qhkQO51Cv6iHJxdAs/source)

### Instagram Iteams:

- [Instagram video Downloader + Scraper](https://console.apify.com/actors/zIpixF6ZjlbelQDrY/source)
- [Instagram Video Downloader (Soundlss)](https://console.apify.com/actors/QQkJuhIQp4pexakls/source)
- [Instagram Thumbnail Scraper Video & Reels](https://console.apify.com/actors/z8JOosBY8hlqiUthl/source)
- [Instagram Reels  Downloader](https://console.apify.com/actors/VRbovYCWXTZXuVaN2/source)
- [Instagram Profile URL to Username Converter & Extractor](https://console.apify.com/actors/FOApkedA1VuG6ncno/source)
- [Instagram Profile Scraper](https://console.apify.com/actors/5dvorBkg7ccX95wAg/source)
- [Instagram Post Videos Downloader](https://console.apify.com/actors/h95ZexZ0ifOX4JEYQ/source)
- [Instagram Followers Scraper](https://console.apify.com/actors/c55pdH9mCE02sj7Dg/source)
- [Instagram Audio Downloader](https://console.apify.com/actors/MQRNuEHUqKreEi8gI/source)
- [Instagram Video Scraper + Downloader](https://console.apify.com/actors/63Z5eSy3IxgdIEYOX/source)
- [Instagram Video  scraper Advanced](https://console.apify.com/actors/79ng2nukXLzUn0aWg/source)
- [Instagram Video Details  scraper](https://console.apify.com/actors/VLyBXSwQpHTFwUcds/source)
- [Instagram Reels Details scraper](https://console.apify.com/actors/oGR3xfeXTuIirhdlZ/source)
- [Instagram Followers Scraper Pro](https://console.apify.com/actors/MqW3EtUZXm6OHdvcI/source)

### Facebook Iteams:

- [Facebook reels Downloader  (Separate audio or video)](https://console.apify.com/actors/nuvIRaMeRIzz3cfxK/source)
- [Facebook Video Downloader advanced](https://console.apify.com/actors/2SU8ZuABbAVFNKMZa/source)
- [Facebook Video Details Scraper Advanced](https://console.apify.com/actors/umYouAXm92472jIdY/source)
- [Facebook Video Details Scraper](https://console.apify.com/actors/cQi4k63arffL6Cn0m/source)
- [Facebook Transcript & Subtitle scraper](https://console.apify.com/actors/hMNe1QYDOtcTc95qI/source)
- [Facebook Thumbnail Downloader Video & Reels](https://console.apify.com/actors/9SmYiqGTUia29Yd1Y/source)
- [Facebook Reels Downloader Advanced](https://console.apify.com/actors/3Zdnp9TnvltdoC44T/source)
- [Facebook Reels Details Scraper  Best and  Affordable](https://console.apify.com/actors/nuzr418MKJltywrCh/source)
- [Facebook Reels Details Scraper](https://console.apify.com/actors/OGBA89e5Ki6Y5amko/source)
- [Facebook Page Details Scraper](https://console.apify.com/actors/PL9nP9BrKDSsKwSZF/source)
- [Facebook Audio Downloader](https://console.apify.com/actors/uVrcf4OJ9VW8iCybQ/source)

### Amazon Iteams:

- [Amazon Search Scraper](https://console.apify.com/actors/YcgJR1WP1cHJhHzvH/source)
- [Amazon Product Details Scraper ](https://console.apify.com/actors/1twpltijc10KFaVeb/source)

# Actor input Schema

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

List of one or more YouTube channel or video URLs to scrape.

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

Specify the maximum number of comments to scrape. Leave blank to scrape all comments.

## `getAllComments` (type: `boolean`):

If true, scrape all comments regardless of the maximum number limit.

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

Choose how to sort comments before scraping.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=k_dYs8ovmnk"
    },
    {
      "url": "https://www.youtube.com/watch?v=VegKhno-BK8"
    }
  ],
  "maxComments": 100,
  "getAllComments": false,
  "sortBy": "top Comments"
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("alpha-scraper/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=k_dYs8ovmnk" },
        { "url": "https://www.youtube.com/watch?v=VegKhno-BK8" },
    ],
    "maxComments": 100,
}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments Scraper |",
        "description": "[ ✨YouTube Comments Scraper ]\n Fast & Reliable Scraper\n Extract CID, type, publish time, comments, author & page URL in seconds\n Streamline workflow, save time & gather structured data\n Perfect for research, analysis & business insights .",
        "version": "0.0",
        "x-build-id": "a8GaePBNCzAxjhPyO"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/alpha-scraper~youtube-comments-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-alpha-scraper-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/alpha-scraper~youtube-comments-scraper/runs": {
            "post": {
                "operationId": "runs-sync-alpha-scraper-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/alpha-scraper~youtube-comments-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-alpha-scraper-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": "🟢 Start URLs",
                        "type": "array",
                        "description": "List of one or more YouTube channel or video URLs to scrape.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxComments": {
                        "title": "🟢 Maximum number of comments",
                        "type": "integer",
                        "description": "Specify the maximum number of comments to scrape. Leave blank to scrape all comments."
                    },
                    "getAllComments": {
                        "title": "🟢 Get all comments",
                        "type": "boolean",
                        "description": "If true, scrape all comments regardless of the maximum number limit.",
                        "default": false
                    },
                    "sortBy": {
                        "title": "🟢 Sort by Top or Newest comments",
                        "enum": [
                            "top Comments",
                            "newest comments"
                        ],
                        "type": "string",
                        "description": "Choose how to sort comments before scraping.",
                        "default": "top Comments"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
