# YouTube Comments Scraper - Comments & Replies by Video URL (`lanternlab318/youtube-comments`) Actor

Public YouTube comments and replies from video links: comment ID, parent comment ID, text, author name, likes, reply count, publish time, pinned and creator-heart flags. Top or newest order, exact per-video cap. No login. Comments-off and failed videos are marked and free.

- **URL**: https://apify.com/lanternlab318/youtube-comments.md
- **Developed by:** [Lantern Lab](https://apify.com/lanternlab318) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.99 / 1,000 comments

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 - Comments & Replies by Video URL

A Lantern Lab Actor. Give it YouTube video links and get back the **public comments and their replies**: **comment ID**, **parent comment ID** for every reply, **text**, **author display name**, **likes**, **reply count**, **publish time** (YouTube's own text and a parsed timestamp), and whether a comment is **pinned**, **hearted by the creator** or **written by the video owner**. Choose **Top** or **Newest** order and an exact per-video cap. No login, no cookies, no account of your own: the Actor reads only what YouTube shows a signed-out visitor.

**Price: USD 0.99 per 1,000 comments, plus USD 0.005 per run.** A video with comments turned off, a deleted video, a bad link and a duplicate are free - you pay for comment rows only. See [Pricing](#pricing).

Need the videos themselves (views, likes, duration, channel)? Use [YouTube Scraper](https://apify.com/lanternlab318/youtube-scraper). Need the spoken words? Use [YouTube Transcript Scraper](https://apify.com/lanternlab318/youtube-transcripts).

### Input

```json
{
    "videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://youtu.be/0e3GPea1Tyg"],
    "maxComments": 200,
    "sortBy": "newest",
    "includeReplies": true,
    "maxRepliesPerComment": 10
}
```

| Field | What it does |
| --- | --- |
| `videoUrls` | Watch, `youtu.be`, Shorts, embed or live links, or bare 11-character video IDs. The same video twice is collected once. |
| `maxComments` | The most comment rows per video, **replies included**. Default 100. Never exceeded. |
| `sortBy` | `top` (YouTube's Top comments, the default) or `newest`. A pinned comment comes first in both, as on the page. |
| `includeReplies` | Collect replies, each written right after its comment. Default `true`. |
| `maxRepliesPerComment` | The most replies under any one comment. Default 10. |
| `maxUpstreamRequests` | Optional hard ceiling on requests to YouTube. Left empty, the Actor derives one from the input. |
| `proxyConfiguration` | The proxy for requests to YouTube. Apify's datacenter proxy (the default) works. |

### Output

One row per comment or reply (`recordType: "comment"`). A video that produced fewer comments than you asked for, for any reason other than simply having no more, also gets one free `status` row that says why. Totals are in the run's key-value store under `RUN_SUMMARY`.

A top-level comment:

```json
{
    "recordType": "comment",
    "platform": "youtube",
    "commentId": "UgzKYksqeQ5gA3t0g0F4AaABAg",
    "parentCommentId": null,
    "isReply": false,
    "text": "I Rick rolled my entire French class because we had to study a city in France ...",
    "authorDisplayName": "@grustache4569",
    "authorIsVideoOwner": false,
    "authorIsVerified": false,
    "likeCount": 106000,
    "likeCountText": "106K likes",
    "replyCount": 665,
    "replyCountText": "665 replies",
    "publishedTimeText": "6 years ago (edited)",
    "publishedAtEstimated": "2020-11-03T08:28:24.364Z",
    "publishedTimePrecision": "year",
    "isEdited": true,
    "isPinned": false,
    "isHeartedByCreator": false,
    "videoId": "dQw4w9WgXcQ",
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "videoTitle": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
    "sortBy": "top",
    "rank": 1,
    "sourceInput": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "collectedAt": "2026-11-03T08:28:24.364Z"
}
```

A reply to it - same shape, with `parentCommentId` pointing at the comment above:

```json
{
    "recordType": "comment",
    "commentId": "UgzKYksqeQ5gA3t0g0F4AaABAg.91a9XW7osVT952pvnnAzll",
    "parentCommentId": "UgzKYksqeQ5gA3t0g0F4AaABAg",
    "isReply": true,
    "text": "The biggest comrade ever",
    "authorDisplayName": "@egdog_tm",
    "likeCount": 6900,
    "likeCountText": "6.9K likes",
    "replyCount": null,
    "publishedTimeText": "6 years ago",
    "publishedAtEstimated": "2020-11-03T08:28:24.665Z",
    "publishedTimePrecision": "year",
    "isPinned": false,
    "videoId": "dQw4w9WgXcQ",
    "rank": 2,
    "collectedAt": "2026-11-03T08:28:24.665Z"
}
```

A video with comments turned off:

```json
{
    "recordType": "status",
    "platform": "youtube",
    "videoId": "XqZsoesa55w",
    "videoUrl": "https://www.youtube.com/watch?v=XqZsoesa55w",
    "videoTitle": "Baby Shark Dance | #babyshark Most Viewed Video | Animal Songs | PINKFONG Songs for Children",
    "channelName": "Baby Shark - Pinkfong Kids’ Songs & Stories",
    "commentCountText": null,
    "commentCount": null,
    "commentsTurnedOff": true,
    "commentsWritten": 0,
    "repliesWritten": 0,
    "sourceInput": "XqZsoesa55w",
    "collectedAt": "2026-11-03T08:28:25.102Z",
    "partial": false,
    "partialReason": "comments_turned_off",
    "statusText": "Comments are turned off for this video."
}
```

Notes on the fields:

- **Publish time.** YouTube shows a comment's age only as relative text (`3 hours ago`, `6 years ago`); it states no exact time. `publishedTimeText` is that text as shown. `publishedAtEstimated` counts it back from `collectedAt`, and `publishedTimePrecision` says how precise it is: `6 years ago` means somewhere in the sixth year back, so it is `year`. Sort by it, but do not read a `year` estimate to the day.
- `likeCount` and `replyCount` are the numbers YouTube shows, which it rounds above 999 (`106K`); the page text is kept next to them in `likeCountText` / `replyCountText`. `replyCount` is on top-level comments only; on a reply it is `null`.
- `parentCommentId` is `null` on a top-level comment and the comment's ID on each of its replies. YouTube keeps replies one level deep: a reply to a reply is a reply to the same comment, usually starting with `@name`.
- `rank` is the row's position among this video's rows, in the order collected.
- `isHeartedByCreator`, `isPinned`, `authorIsVideoOwner` and `authorIsVerified` are as YouTube marks them on the page.
- `videoTitle` comes from the video's watch page, read once per video.
- A field YouTube did not state is `null`, never guessed. Emoji in the text are kept as characters.

#### Status rows

A video gets a free `status` row when its comments are off, missing, cut at your limit or not fully read. `partial: true` means collection was **incomplete** - YouTube has more that this run did not get - and is never reported as "no comments".

| `partialReason` | `partial` | Meaning |
| --- | --- | --- |
| `max_comments_reached` | false | Stopped at `maxComments`; the video has more. |
| `comments_turned_off` | false | The owner turned comments off. |
| `no_comments` | false | Comments are on and nobody has commented. |
| `unavailable` | false | Deleted, private, or no video under that ID. |
| `invalid_input` | false | Not a YouTube video link or ID. |
| `upstream_error` | **true** | A request to YouTube failed twice (each request is retried once on a new IP), or the replies of some comments could not be read. The comments written before it are kept. |
| `upstream_request_cap` | **true** | The run reached `maxUpstreamRequests`. Every video not finished gets this row. |
| `charge_limit_reached` | **true** | Your maximum cost per run was reached. Every video not finished gets this row. |

`commentsWritten` and `repliesWritten` on the status row say how many rows that video produced before it stopped. A video that simply ran out of comments below `maxComments` gets no status row; `RUN_SUMMARY.videos[]` lists every video with its status anyway.

#### Duplicates

A comment is written once per run, keyed by comment ID. A repeated video link is dropped before collection; `RUN_SUMMARY` counts both.

### Pricing

Pay per event: **USD 0.99 per 1,000 comments, plus USD 0.005 per run.** Apify platform usage, including proxy traffic, is included; you pay only these two events.

| Event | Price | Charged for |
| --- | --- | --- |
| `comment` | USD 0.00099 (USD 0.99 per 1,000) | Each comment or reply row. `status` rows are free. |
| `run-start` | USD 0.005 | Once per run, together with the first comment. A run that returns no comment is not charged at all. |

Example: 5 videos x 200 comments = 1,000 rows costs USD 0.005 + 1,000 x 0.00099 = USD 0.995.

To cap a run's cost, set **Maximum cost per run** in the run options. When it is reached, the Actor stops before the next comment and marks every unfinished video `charge_limit_reached`.

### Speed

About 20 top-level comments or 10 replies per request to YouTube. A run with replies off reads 300 comments in about 15 requests.

### Limits

- What a signed-out visitor sees: no comments on private, members-only or age-restricted videos, no live chat, no comment translations.
- Order is YouTube's. `top` is YouTube's ranking and can change between runs; use `newest` for a stable time order. Very large comment sections are read page by page, so `maxComments` in the tens of thousands takes minutes per video.
- Author data is limited to the public display name and the owner/verified marks. The Actor does not output author channel IDs or avatars.
- Not included: channel-wide collection, video downloads, sentiment analysis.

### Notes

Respect YouTube's terms and local law, and collect only what you need. Display names are public, but they can identify a person.

# Actor input Schema

## `videoUrls` (type: `array`):

One video per line: a watch link (youtube.com/watch?v=...), youtu.be/..., a Shorts, embed or live link, or a bare 11-character video ID. The same video twice is collected once. A line that is not a YouTube video gets a free status row with partialReason "invalid_input".

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

The most comment rows to collect from each video, replies included. Never exceeded. When a video has more, its free status row says "max_comments_reached".

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

"top": YouTube's Top comments order (what the page opens with). "newest": newest first. In both, a pinned comment comes first, as on the page.

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

Collect the replies under each comment, written right after it with parentCommentId set. Replies count toward "Max comments per video".

## `maxRepliesPerComment` (type: `integer`):

The most replies to take under any one comment. The comment's own replyCount still states how many YouTube shows.

## `maxUpstreamRequests` (type: `integer`):

Hard ceiling on the HTTP requests this run sends to YouTube, retries included. At the ceiling collection stops and every unfinished video gets a status row with partialReason "upstream_request_cap". Leave empty and the Actor derives a ceiling from the input, so a run is never unbounded.

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

The proxy used for every request to YouTube. Apify's datacenter proxy (the default) works for comments.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxComments": 20,
  "sortBy": "top",
  "includeReplies": true,
  "maxRepliesPerComment": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `runSummary` (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 = {
    "videoUrls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "maxComments": 20
};

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

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

```

## MCP server setup

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

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/E6FAsis5BT41pmkNI/builds/HmJqadSaO6N3izp0l/openapi.json
