# YouTube Comments (`s-r/youtube-comments`) Actor

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

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 — Hosted Apify Actor

Hosted youtube comments scraper that returns structured JSON without the captcha-solving, proxy-rotation, and site-update maintenance you'd otherwise own. Run it from the Apify Store with one click, or call it from your own service via the Apify API. Pay only for what you scrape — no monthly subscription.

### What you get

- **Structured JSON output** — every youtube comments scraper run returns clean, parseable records ready for analytics or downstream pipelines.
- **Hosted on Apify** — no servers, no proxies, no anti-bot maintenance. Click Run.
- **Pay only for what you scrape** — pricing scales with usage; no monthly subscription minimum.

### Why use this youtube comments scraper

Most youtube comments scraper solutions fall into one of two camps: free open-source libraries that break every few months when the upstream site changes, or expensive SaaS tools that charge $99-$399/month for the data layer plus a dashboard UI you may not need.

This Apify Actor sits in the middle: same structured data the SaaS tools ship, but priced per run instead of per month, with a hosted infrastructure that handles proxies, retries, and captcha solving so you don't have to.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `video` | string | **required** | YouTube video URL (watch?v=…, youtu.be/…, /shorts/…) or 11-character video ID. |
| `max_comments` | integer | `100` | Top-level comments to collect (1–2000). Replies are not expanded in this POC. |

### Output

Every run pushes results to the Apify dataset as JSON records. Each record contains the structured fields surfaced by the youtube comments scraper — fields, IDs, timestamps, and any nested objects. You can:

- **Download** the dataset as JSON, JSONL, CSV, or Excel from the Apify console
- **Stream** results via the Apify API for use in your own application
- **Pipe** results to webhooks, S3, BigQuery, or any of Apify's 30+ integrations
- **Diff** today's run against yesterday's to detect changes (new entries, removed entries, modified fields)

### Use cases for the youtube comments scraper

#### Competitive monitoring

Use the youtube comments scraper to pull your competitors' data daily. Diff against yesterday's run to detect price changes, new listings, or removed inventory.

#### Lead generation

Pipe youtube comments scraper output into your CRM as enrichment — every record arrives with the structured fields your sales reps need.

#### Market sizing

Scrape an entire vertical's catalog with the youtube comments scraper, then aggregate to size the addressable market by category, geo, or price band.

#### Internal dashboards

Schedule the youtube comments scraper as a daily Apify task. Push results to BigQuery and visualize in your existing BI tool.

### FAQ

#### Is this youtube comments scraper free?

The Actor itself is hosted on Apify with pay-per-event pricing — you only pay for what you actually scrape. There's no monthly subscription and no minimum spend. The first few runs typically cost less than a coffee. For long-running daily jobs, your monthly bill scales with the volume of data you pull.

#### How does this youtube comments scraper compare to existing tools?

Most off-the-shelf youtube comments scraper alternatives are either fragile open-source scripts that break every few months, or expensive SaaS subscriptions starting at $99-$399/month. This Actor sits in between: hosted infrastructure that handles proxy rotation and retries, but priced per run.

#### What input does the youtube comments scraper accept?

The full input schema is rendered as a form on the Apify Store page — you can run a job by filling out a few fields with no code. The schema also accepts raw JSON if you're calling the Actor via the Apify API from your own service. See the **Input** section above for the field list.

#### How accurate is the youtube comments scraper data?

The Actor scrapes data directly from the source, so accuracy matches what a human user would see on the page. There's no third-party cache or middleware — every run returns the live state. If the upstream site throttles requests, the Actor handles retries and proxy rotation transparently and surfaces a structured error in the dataset's `errors` field rather than failing silently.

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

Yes — Apify has built-in scheduling. You can set the Actor to run hourly, daily, or weekly, and pipe results to webhooks, S3, or your data warehouse via the Apify integrations. Most teams schedule the youtube comments scraper as a daily task and incrementally diff against the previous run to detect changes.

### Pricing

This youtube comments scraper uses Apify's pay-per-event pricing — every successful record costs a small fixed amount, so your bill scales linearly with usage. There's no monthly subscription and no minimum spend. See the Apify Store page for the current per-event price; expect typical workloads to cost a few dollars per run.

# Actor input Schema

## `video` (type: `string`):

YouTube video URL (watch?v=…, youtu.be/…, /shorts/…) or 11-character video ID.
## `max_comments` (type: `integer`):

Top-level comments to collect (1–2000). Replies are not expanded in this POC.

## Actor input object example

```json
{
  "video": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "max_comments": 100
}
````

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

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

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Comments",
        "description": "",
        "version": "0.1",
        "x-build-id": "DfajPD5FqwKd4WoEa"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/s-r~youtube-comments/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-s-r-youtube-comments",
                "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/s-r~youtube-comments/runs": {
            "post": {
                "operationId": "runs-sync-s-r-youtube-comments",
                "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/s-r~youtube-comments/run-sync": {
            "post": {
                "operationId": "run-sync-s-r-youtube-comments",
                "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": [
                    "video"
                ],
                "properties": {
                    "video": {
                        "title": "Video",
                        "type": "string",
                        "description": "YouTube video URL (watch?v=…, youtu.be/…, /shorts/…) or 11-character video ID."
                    },
                    "max_comments": {
                        "title": "Max comments",
                        "minimum": 1,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Top-level comments to collect (1–2000). Replies are not expanded in this POC.",
                        "default": 100
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
