# Youtube Comments Extractor (`kawsar/youtube-comments-extractor`) Actor

YouTube comment scraper that pulls comment text, authors, likes, and full reply threads from any video, so you can dig into audience sentiment or mine content ideas without a YouTube API key.

- **URL**: https://apify.com/kawsar/youtube-comments-extractor.md
- **Developed by:** [Kawsar](https://apify.com/kawsar) (community)
- **Categories:** Social media, Videos, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Extractor

Extract every comment from a YouTube video, including full reply threads, without touching the YouTube Data API or dealing with its quota limits. Give the actor a video URL and it returns comment text, author details, like counts, reply counts, and publish dates as clean, structured data ready for a spreadsheet, a dashboard, or your own pipeline.

### Why use this actor

The YouTube Data API caps free usage at a small daily quota, requires an API key and OAuth setup, and still won't hand you a video's comments in one clean call. This actor skips all of that. Paste a video URL, choose how many comments you want, and it walks YouTube's own comment feed the same way a browser would, following pagination automatically until it hits your limit or runs out of comments.

No YouTube API key, no OAuth consent screen, no quota to track. Just a video URL and an output you can open in Sheets five minutes from now.

#### Who this is for

- **SEO and content teams** mining comment threads for the questions, phrases, and pain points an audience is already typing out, then turning that into content briefs and FAQ sections
- **Marketers and brand teams** tracking what people are saying about a product, campaign, or competitor on any public video, including videos they don't own
- **Data analysts and researchers** feeding comment text into a sentiment or topic model to measure how an audience actually reacted, not just how many likes a video got
- **Creators and channel managers** reviewing comments and reply threads across a catalog of videos in one batch instead of scrolling through YouTube by hand
- **Moderation and compliance teams** that need a timestamped, exportable record of comment activity on a video

### How it works

1. You provide one or more YouTube video URLs.
2. The actor loads each video's comment section and reads YouTube's own comment feed, sorted by top or newest, exactly as configured.
3. For every top-level comment it collects, it follows the reply thread underneath that comment (when reply collection is on) before moving to the next one, so replies stay grouped with their parent instead of arriving as a separate, disconnected batch at the end.
4. It keeps paging, comment by comment and reply thread by reply thread, until it reaches your comment limit or the video runs out of comments, whichever comes first.

Videos with comments turned off, or comments restricted to signed-in viewers, return zero rows for that URL instead of failing the whole run, so a bad link in a batch never blocks the rest of your list.

### Input

| Field | Type | Description |
|---|---|---|
| `startUrls` | array of strings | One or more YouTube video URLs. Accepts full watch links, `youtu.be` short links, and Shorts links |
| `sortBy` | string | `top` or `newest`. Controls the order comments are fetched in. Default `top` |
| `includeReplies` | boolean | When on, fetches the full reply thread under each comment before moving to the next one. When off, only top-level comments are collected. Default `true` |
| `maxComments` | integer | Maximum number of comments to collect per video, top-level comments and replies combined. Default 100, up to 5000 |
| `requestTimeoutSecs` | integer | Per-request timeout in seconds. Default 60 |

Example input:

```json
{
  "startUrls": ["https://www.youtube.com/watch?v=xuCn8ux2gbs"],
  "sortBy": "top",
  "includeReplies": true,
  "maxComments": 200
}
```

### Output

Each dataset row is one comment or one reply. A top-level comment looks like this:

```json
{
  "videoId": "xuCn8ux2gbs",
  "videoUrl": "https://www.youtube.com/watch?v=xuCn8ux2gbs",
  "videoTitle": "history of the entire world, i guess",
  "commentId": "UgzbUWbHj_VFK6pb2_14AaABAg",
  "commentText": "Truly one of the greatest videos of all time",
  "authorName": "@jatootjaboot1578",
  "authorChannelUrl": "https://www.youtube.com/@jatootjaboot1578",
  "authorAvatarUrl": "https://yt3.ggpht.com/...",
  "authorIsVerified": false,
  "authorIsCreator": false,
  "likeCount": 5100,
  "replyCount": 46,
  "publishedTime": "2 months ago",
  "isReply": false,
  "position": 1,
  "scrapedAt": "2026-08-16T10:18:57.008045+00:00",
  "error": null
}
```

A reply carries the same fields plus `parentCommentId`, pointing back at the comment it replies to:

```json
{
  "commentId": "UgzbUWbHj_VFK6pb2_14AaABAg.AXwxAF9KBLcAXwxYmrDS4T",
  "commentText": "My autism is so obsessed with this video and the various sound bites that I have to return multiple times a year.",
  "isReply": true,
  "parentCommentId": "UgzbUWbHj_VFK6pb2_14AaABAg"
}
```

#### Field reference

| Field | Description |
|---|---|
| `videoId`, `videoUrl`, `videoTitle` | Identifies which video the row belongs to |
| `commentId` | YouTube's unique ID for this comment or reply |
| `commentText` | The comment's full text |
| `authorName`, `authorChannelUrl`, `authorAvatarUrl` | Who posted it and where to find their channel |
| `authorIsVerified`, `authorIsCreator` | Whether the author has a verified badge, or is the video's own creator replying in their own comments |
| `likeCount` | Number of likes on the comment |
| `replyCount` | YouTube's own reply count, shown on the top-level comment |
| `publishedTime` | YouTube's relative timestamp, e.g. "2 months ago" |
| `isReply` | `true` for a reply, `false` for a top-level comment |
| `parentCommentId` | Only present on replies, pointing to the parent comment's `commentId`. Top-level comments don't carry this field at all |
| `position` | The row's order within the run |
| `scrapedAt` | UTC timestamp of when the row was collected |
| `error` | `null` on a normal row. Populated only when a specific URL failed to process |

Export any run as JSON, CSV, or Excel, or push it straight to Google Sheets from the Apify dataset view.

### Tips

- Add several URLs to `startUrls` to pull comments from multiple videos in a single run.
- Set `sortBy` to `newest` when you're monitoring a video for fresh activity rather than pulling its full history.
- `maxComments` counts top-level comments and replies together. A video with long reply threads can use up the whole budget on just a handful of top-level comments and their replies, so raise the limit if you need broader top-level coverage across more comments.
- Turn `includeReplies` off if you only care about the top-level conversation and want to cover more distinct comments per run.

### FAQ

**Does this work on Shorts?**
Yes. Any public video with comments enabled works, Shorts included.

**Can I scrape multiple videos in one run?**
Yes. Add as many URLs as you need to `startUrls` and they're processed one after another in the same run.

**Do I need a YouTube account or API key?**
No. Just a public video URL.

**What happens if a video has comments disabled?**
The actor logs it and moves on to the next URL in your list instead of failing the whole run.

**Why does a top-level comment sometimes have fewer replies than `replyCount` shows?**
The actor stops adding rows once your run hits `maxComments`. If a comment thread's replies would push the run past that limit, only the replies that fit are included.

# Actor input Schema

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

One or more YouTube video URLs to extract comments from.

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

Order in which comments are fetched from YouTube.

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

Fetch full reply threads for each comment, in addition to top-level comments. When on, replies count toward Max comments per video.

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

Maximum number of comments to collect per video. Counts top-level comments and replies together.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.youtube.com/watch?v=xuCn8ux2gbs"
  ],
  "sortBy": "top",
  "includeReplies": false,
  "maxComments": 20,
  "requestTimeoutSecs": 60
}
```

# Actor output Schema

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

All extracted YouTube comments, one row per comment.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

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

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        "https://www.youtube.com/watch?v=xuCn8ux2gbs"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kawsar/youtube-comments-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": ["https://www.youtube.com/watch?v=xuCn8ux2gbs"] }

# Run the Actor and wait for it to finish
run = client.actor("kawsar/youtube-comments-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://www.youtube.com/watch?v=xuCn8ux2gbs"
  ]
}' |
apify call kawsar/youtube-comments-extractor --silent --output-dataset

```

## MCP server setup

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

```

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/BWSS02tVfCUmBYdOF/builds/WuCCHiYL175fD5d0j/openapi.json
