# YouTube Comments Scraper (Public, No Login, Up to 1000) (`steadfetch/youtube-comments-scraper`) Actor

Scrape public YouTube comments from any video without login. Returns one item per comment: author, text, votes, replies, timestamps, video metadata. Uses the watch page and Innertube API. Residential proxies recommended for bulk use.

- **URL**: https://apify.com/steadfetch/youtube-comments-scraper.md
- **Developed by:** [Steadfetch](https://apify.com/steadfetch) (community)
- **Categories:** AI
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 comment delivereds

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/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 (Public Videos)

Base [Apify](https://apify.com) Actor for [Steadfetch](https://apify.com/steadfetch). Scrapes the public comments of any public YouTube video - no login, no account cookies - and returns typed JSON: one dataset item per comment plus error items for videos without a usable comment section.

### What it does

- Accepts public video URLs (`watch?v=`, `youtu.be/`, `/shorts/`, `/embed/`, `/live/`) or bare 11-character video ids.
- Reads the public watch page and YouTube's own public comment endpoint (`youtubei/v1/next`, the same one the website uses), ~20 comments per page, following the page's own continuation tokens until `maxComments` is reached.
- Returns the fields that matter for analysis: comment text, comment id, author handle and channel id (public usernames only - no emails, phones or profiles), likes, reply count, video title, video id, video URL and the video's total comment count as YouTube shows it.
- Sorts `TOP_COMMENTS` (web default) or `NEWEST_FIRST`, and can exclude comments older than `oldestCommentDate`. Both are included at no extra charge.
- Handles videos without comments gracefully: instead of failing, the run ends `SUCCEEDED` with an error item carrying a code (`VIDEO_UNAVAILABLE`, `AGE_RESTRICTED`, `NO_COMMENTS`).
- Validates every item against the dataset schema before it reaches the dataset (`strictSchema`, default true).

The Actor works on plain Apify datacenter runs - no residential proxies required (the leader of this niche demands them in its FAQ). An optional `proxyConfiguration` input is honored if your environment needs one.

### How to use

1. Fill `startUrls` with public video URLs and set `maxComments`:

   ```bash
   apify call steadfetch/youtube-comments-scraper --input='{"startUrls":[{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}],"maxComments":100,"strictSchema":true}'
   ```

2. Read results from the run's default dataset (JSON, CSV or the API).

#### Minimum input

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

With the defaults this reads the 100 most-liked comments of the video, in the order YouTube shows.

#### Input fields

| Field | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `startUrls` | array | Yes | - | Public video URLs or video ids. |
| `maxComments` | integer | No | 100 | Maximum comments pushed to the dataset (hard limit 10000). |
| `sortCommentsBy` | string | No | `TOP_COMMENTS` | `TOP_COMMENTS` or `NEWEST_FIRST` (the page's own sort menu; free). |
| `oldestCommentDate` | string | No | - | ISO date; comments older than it are excluded. Dates are approximate (YouTube shows relative times like "7 years ago" to signed-out clients). |
| `strictSchema` | boolean | No | true | Fail the run on output-schema violations. Keep enabled. |
| `proxyConfiguration` | object | No | none | Optional proxy settings for public pages. |

### Example output

```json
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Example Video Title",
  "scrapedAt": "2026-11-25T12:00:00.000Z",
  "type": "Comment",
  "cid": "UgzKYksqeQ5gA3t0g0F4AaABAg",
  "comment": "Public comment text as shown on the video page.",
  "author": "@examplehandle",
  "authorHandle": "@examplehandle",
  "authorChannelId": "UC1234567890abcdefghijklmnop",
  "authorAvatar": "https://yt3.ggpht.com/example=s88-c-k-c0x00ffffff-no-rj",
  "authorIsChannelOwner": false,
  "hasCreatorHeart": null,
  "videoId": "dQw4w9WgXcQ",
  "pageUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "commentsCount": 2400000,
  "replyCount": 742,
  "voteCount": 109000,
  "likes": 109000,
  "publishedTime": "7 years ago (edited)",
  "publishedTimeEdited": true,
  "publishedDateApprox": "2019-06-01T12:00:00.000Z",
  "replyToCid": null
}
```

Error item example (run still succeeds):

```json
{
  "url": "https://www.youtube.com/watch?v=EXAMPLEID111",
  "title": null,
  "scrapedAt": "2026-11-25T12:00:00.000Z",
  "type": "Error",
  "code": "NO_COMMENTS",
  "message": "The video has no public comment section (comments are disabled or none exist).",
  "videoId": "EXAMPLEID111",
  "pageUrl": "https://www.youtube.com/watch?v=EXAMPLEID111"
}
```

#### Output fields

| Field | Type | Description |
| --- | --- | --- |
| `url` | string | Video page URL (common Steadfetch envelope, required). |
| `title` | string | null | Video title. |
| `scrapedAt` | date-time | ISO 8601 UTC timestamp of the scrape (required). |
| `type` | string | `Comment` or `Error`. |
| `cid` | string | null | YouTube comment id. |
| `comment` | string | null | Comment text. |
| `author` | string | null | Public display name/handle. |
| `authorHandle` | string | null | Public @handle. |
| `authorChannelId` | string | null | Public channel id. |
| `authorAvatar` | string | null | Public avatar thumbnail URL. |
| `authorIsChannelOwner` | boolean | null | Author owns the video's channel. |
| `hasCreatorHeart` | null | Always null: the signed-out web client does not expose the creator-heart state. |
| `videoId` | string | null | Video id. |
| `pageUrl` | string | null | Watch URL. |
| `commentsCount` | integer | null | Approximate total comment count of the video (YouTube's rounded figure). |
| `replyCount` | integer | null | Replies to the comment (YouTube's rounded figure). |
| `voteCount` / `likes` | integer | null | Likes (YouTube's rounded figure, e.g. 109K -> 109000). |
| `publishedTime` | string | null | Relative time as shown on the web. |
| `publishedTimeEdited` | boolean | null | Comment marked "(edited)". |
| `publishedDateApprox` | string | null | Approximate UTC date derived from the relative time. |
| `replyToCid` | null | Always null: top-level comments only (use `replyCount` for thread size). |
| `code` / `message` | string | null | Only on Error items. |

### Pricing

Pay-per-event with the two synthetic platform events: `apify-actor-start` at 0.00005 USD per run (Apify-recommended default, includes the first 5 seconds of compute) and `apify-default-dataset-item` at **0.4 USD per 1,000 results** (one public comment = one result) - below the cheapest competitor in this niche (datasaurus bills 0.5 USD per 1,000 comments) and well below the leader (streamers bills 2 USD per 1,000 on the FREE plan and demands paid residential proxies). Sorting and the date filter are included at no extra charge; there is no custom per-item event and no `Actor.charge()` call, so users are never billed twice.

Cost basis (measured, see the repository task for the run): ~50 public API pages per 1,000 comments at <=1 request/second, about 60 seconds of the 0.25 GB slice per 1,000 comments, no proxy by default - a small fraction of the price, with margin over proxy cost if a user attaches one.

**Works on the Apify free plan** - about 12,499 results for the $5 monthly credit (floor((5.00 - 0.00005) / 0.0004)).

Monitor Actors built from this template may add exactly one more event: the reserved `monitor-check`, charged once per watched item actually checked in a run, priced 0.01-1.00 USD per 1,000 checks. This Actor is an extractor and ships no monitor charge; the pattern and the price measurement are documented in the repository `CONTRIBUTING.md`, section "Monitor Actors: charge per check".

### FAQ

**Does the Actor need a login or account cookies?** No. It only reads public pages and YouTube's public comment endpoint without authentication. Comment authors' public usernames are returned; the Actor never returns emails, phone numbers or profile dumps.

**Why no browser (Playwright)?** The comment data is already on the public page and the public API; HTTP-only runs are roughly 10x cheaper and faster.

**Why is `hasCreatorHeart` null and why are dates relative?** YouTube's signed-out web client does not expose creator hearts and only shows relative times ("7 years ago"). The Actor reports what the public page actually carries instead of inventing values; `publishedDateApprox` is an estimate.

**Why does the run succeed with 0 comments and 1 Error item?** For videos that are unavailable, age-restricted or have comments disabled, a typed error item (`VIDEO_UNAVAILABLE`, `AGE_RESTRICTED`, `NO_COMMENTS`) is more useful than a failed run. Real network failures still fail the run.

**When am I charged?** Once per run start (`apify-actor-start`) and once per result saved (`apify-default-dataset-item`). Failed runs that deliver no results only incur the start event.

**Is the output schema stable?** Yes. New fields are added additively and `required` fields never change.

**Can I request a new source?** Yes, open an issue in the Steadfetch actors repository describing the public page you want tracked.

### Other Steadfetch Actors

- [Instagram Reel Transcript Scraper](https://apify.com/steadfetch/instagram-reel-transcript-scraper) - AI transcripts of public Instagram reels.
- [Google Reviews Extractor](https://apify.com/steadfetch/google-reviews-extractor) - reviews of places on Google Maps.
- [Spain Tourism Statistics Scraper](https://apify.com/steadfetch/exceltur-indicadores-extractor) - Exceltur tourism indicators.

### Support

Report bugs or request features through the Apify Store page (Issues tab) of the Actor you ran, or through the Steadfetch actors repository issues. Include the run ID and the input used.

### Maintenance

This Actor is **tested daily** through the monorepo CI (`npm test` and `npm run publish:check` on every push, plus the shared publish gate) and a daily QA run against the example input. Use this Actor only for content you are allowed to collect under YouTube's terms - the user is responsible for how the output is used; Steadfetch removes any Actor from the Store within 48 hours of a valid complaint.

# Actor input Schema

## `videoUrl` (type: `string`):

YouTube video URL (watch, shorts, embed, or live format) or a bare 11-character video id.

## `sortCommentsBy` (type: `string`):

Sort order for comments. Uses the page's own sort tokens.

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

Maximum number of comments to scrape.

## `strictSchema` (type: `boolean`):

Fail the run when an item does not match the output schema.

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

Optional proxy settings. Residential proxies recommended for bulk scraping.

## Actor input object example

```json
{
  "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "sortCommentsBy": "TOP_COMMENTS",
  "maxComments": 100,
  "strictSchema": true
}
```

# Actor output Schema

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

Dataset items validated against the item schema in dataset_schema.json (fields).

# 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 = {
    "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "maxComments": 100
};

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

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

```

## MCP server setup

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

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/FG290a1LCRmYexjNj/builds/iMWRZZywwoZ5n6DGV/openapi.json
