# YouTube Comments and Replies via Data API, Your Own Key (`bardach_technologies/youtube-comments-data-api`) Actor

YouTube comments and replies through the YouTube Data API v3 with your own API key: text, date, likes, reply counts, per-video summary. Only-new mode, quota tracking, resume. No author names. Not for channels or pages. USD 0.40 per 1,000 comments.

- **URL**: https://apify.com/bardach_technologies/youtube-comments-data-api.md
- **Developed by:** [Bardach Technologies](https://apify.com/bardach_technologies) (community)
- **Categories:** Social media, Videos, Marketing
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 comment or reply writtens

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 and Replies via Data API, Your Own Key

Downloads the comments and replies of YouTube videos through the YouTube Data API v3, using an API key that you create in your own Google Cloud project. You get comment text, time, like count and reply count, plus one summary row per video. Author names, channel ids, profile links and pictures are never output.

**Use it when**

- you want the comments of a list of videos as clean rows, from the documented API instead of reading web pages;
- you repeat the same videos and want only the comments you have not received before (only-new mode);
- you want a hard cap on how much of your key's daily quota a run may use.

**Do not use it when**

- you need who wrote a comment: author names and channels are deliberately left out;
- you want channel, playlist or search results, video downloads, transcripts or statistics of whole channels: this Actor reads the comments of the videos you list;
- you have no Google Cloud project: without your own key you only get the free sample row described below.

Not affiliated with or endorsed by YouTube or Google.

### Minimal input

```json
{"videos": ["dQw4w9WgXcQ"], "apiKey": "YOUR-OWN-YOUTUBE-DATA-API-KEY", "maxCommentsPerVideo": 20, "includeReplies": false}
```

### Run without a key: one free sample row

If the API key field is empty (for example in Apify's automatic daily test of the default input), the run makes no request to Google, charges no event of this Actor and writes exactly one row from built-in, made-up demo data, marked `"sample": true` (video id `demoVideo01`). It shows the row shape only; it is not a YouTube comment. Apify's own run-start event applies as on every run. Add your key to read real comments.

### One output row (shape of a comment row; the text is an invented example)

```json
{"type": "comment", "videoId": "dQw4w9WgXcQ", "commentId": "UgxExample1", "parentId": null, "isReply": false, "text": "Nice one, write to [removed]", "maskedItems": 1, "publishedAt": "2026-11-01T10:00:00Z", "updatedAt": "2026-11-01T10:00:00Z", "likeCount": 3, "replyCount": 1, "fetchedAt": "2026-11-19T09:00:00Z", "refreshBy": "2026-12-19T09:00:00Z"}
```

### Pricing

USD 0.40 per 1,000 comments or replies written (USD 0.0004 each), plus USD 0.00005 per run start. Summary rows, status rows (comments turned off, video not found) and comments skipped by only-new mode are free. Example: 20 videos with 100 comments each is 2,000 rows, USD 0.80. Your key's own Google quota is used as well, 1 unit per call, see below. The Actor never writes more rows than your maximum charge allows.

### How it works

For each video the Actor reads the video's details (1 quota unit for up to 50 videos), then the comment threads page by page (100 threads per unit, up to 5 replies come inside each thread) and, if a thread has more replies, the rest of them (100 per unit). Only a server error (HTTP 500, 502, 503 or 504 with Google's JSON error body) or a lost connection is retried, up to 4 attempts with waiting in between; every attempt that Google answered counts as a unit.

### Quota tracking and budget

- Google gives each project 10,000 units a day by default; every call used here costs 1 unit.
- **Quota budget** (default 500, up to 10,000): the run never makes a call that would go over it. It stops cleanly, keeps what it wrote and says so in the run summary.
- If Google answers 429 (rate limit), refuses the request (401, 407, 451, a page that is not Google's JSON, or a redirect) the run stops reading at once and does not retry. It keeps what it wrote, saves the stop in its run store (a restart of the same run asks Google nothing more), and the status says so. Start a new run later.
- If Google reports that the daily quota is used up, the run stops at once without retrying, keeps what it wrote, and the status says so. If that happens before any comment was read, the run fails and nothing is charged.
- The run log and the summary (`OUTPUT` record) show the lowest quota use expected for your input and the units actually used; every video summary row has its own `quotaUnitsUsed`.

### Only new, resume

- **Only new since the last run** remembers the ids of delivered comments and the reply count of each thread in a named key-value store (ids and counts only, no text). With order "newest first" and a finished earlier scan, reading stops at the first page where every comment is already known, which saves quota. New replies to old comments are found when a thread's reply count has grown and its page is read. Comments hidden deep behind pages that were skipped by the early stop are not re-read.
- **Time limit** (`maxRunSeconds`, default 1500, from 60 to 3600): the total time of the run, including slow or stalled answers. When it is used up the run stops cleanly, keeps what it wrote and says so in the summary.
- In only-new mode the ids of a page are saved right before that page is written and charged, so a run that is killed or aborted never makes a later only-new run charge those comments again. If the process dies in the instant between the save and the write, that one page (up to 100 threads) is not delivered by later only-new runs; use another `stateStoreName` to read it again.
- A scan that was cut by the maximum, the budget or the quota is not trusted for the early stop: the next only-new run reads on until it reaches the end.
- Remembered ids older than 30 days are dropped, so after a pause longer than that the older comments are delivered again (refreshed).
- **Resume:** if a run is interrupted and restarted by the platform, it continues at the page it was reading, skips the rows already written, and does not write or charge a comment twice. If a restart happens in the instant between writing a page and recording its charge, that page can stay uncharged; it is never charged twice.

### What is left out, and why

Comments are personal data of the people who wrote them. By default and always: no author name, no author channel id or link, no avatar. Contact details in the text (e-mail addresses, phone numbers, street addresses), links to YouTube channels and @mentions are replaced by placeholders such as `[removed]` and `[mention]`; `maskedItems` counts them. Masking works on patterns: a name written in plain words inside a comment, or a contact detail in an unusual form, can remain, so treat the output as personal data. The comment id stays so that you can match rows between runs.

### YouTube API terms you take on

You use your own key, in your own Google project, and you agree to Google's API Services Terms and Developer Policies yourself. Points that matter for this data (read them for yourself):

- Stored API data must be refreshed or deleted within 30 calendar days. Every row has `refreshBy` (read time plus 30 days). Deleting your copies of the dataset is your responsibility.
- Data must be deleted when YouTube or a user requires it.
- The policies restrict combining API data from different content owners and building insight into YouTube's business from it. Summary rows are per video only; the Actor makes no cross-video or cross-channel totals.
- The Actor does not read YouTube pages and does not scrape; it only calls the API with your key. The key is sent to Google in a request header, kept as a secret input, and never written to the output, the summary, the state store or the logs.
- Do not restrict your key to IP addresses or referrers: the Actor runs from Apify's servers and Google may refuse the calls.

### Input

- **Videos**: up to 50 watch, youtu.be, shorts, live or embed links, or 11-character ids. Channel, playlist and search links are refused with a message.
- **Your YouTube Data API key** (secret; needed for real data, empty gives the one free sample row).
- **Include replies** (default on). **Maximum comments per video** (default 100, up to 10,000; counts comments plus replies). **Order**: newest first (default) or top comments first.
- **Only new since the last run** (default off) and **State store name** (default `youtube-comments-state`; use another name for another job).
- **Quota budget (units)** (default 500, up to 10,000).

### Status values of a video summary row

`ok`, `partial` (cut by the maximum, your maximum charge, the budget, the quota or the run time limit, which shows as `deadline`; `stopReason` says which), `commentsDisabled`, `notFound` (also private or removed videos), `error` (`note` has the reason). Only `comment` rows are charged.

### Alternatives, honestly

Store listings that read the comment pages already exist and are used much more (in a read of the Store data on 18.11.2026: one with about 4,400 users in 30 days at USD 1.50 per 1,000 comments, one with about 1,150 users at USD 0.50 per 1,000, one with a 72 % success rate). They need no key from you. This Actor is the better pick if you want the documented API route, a quota budget, only-new runs that spare quota, resume, and no author data; it is the worse pick if you do not want to create a Google key.

### Status of this build

Tested against a local imitation of the API written from Google's reference documentation, through the real Actor process: paging, replies, only-new, caps, quota stop, spending limit, run time limit, charging, restart and resume, error handling, key handling, masking and the row schema (138 tests, 7 of them through the real Actor process). It has not been run against the live YouTube Data API: real error texts, real response shapes and the behaviour of the quota are unproven until a first run with a real key.

# Actor input Schema

## `videos` (type: `array`):

One video per line: a watch, youtu.be, shorts, live or embed link, or the 11-character video id. Up to 50 videos. Channels, playlists and search pages are not supported.

## `apiKey` (type: `string`):

Your own API key (Google Cloud Console, YouTube Data API v3 enabled). Stored as a secret input, sent only to Google, never written to the output or the logs. Do not restrict the key by IP address or referrer: the Actor runs from Apify's servers. Left empty, the run makes no request and writes one free sample row from built-in demo data (sample: true).

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

On by default. Replies are read too and count towards the maximum below. Threads with more than 5 replies cost one extra quota unit per 100 replies.

## `maxCommentsPerVideo` (type: `integer`):

Comments plus replies written per video, up to 10,000. Default 100. About 1 quota unit per 100 top-level comments.

## `order` (type: `string`):

time: newest first (the default; needed for the early stop of only-new runs). relevance: YouTube's top comments first.

## `onlyNew` (type: `boolean`):

Off by default. On: comments already delivered by an earlier run with the same state store name are skipped and not charged, and reading stops at the first page of known comments, which saves quota. Remembered ids are dropped after 30 days, so comments older than that are delivered again.

## `maxQuotaUnits` (type: `integer`):

The run never uses more than this many units of your key's daily quota (Google's default is 10,000 per project and day, every call costs 1). When the budget or your quota is used up, the run stops cleanly and keeps what it delivered. Default 500, up to 10,000.

## `maxRunSeconds` (type: `integer`):

Total time of the run. When it is used up the run stops cleanly, keeps what it delivered and saves where it stopped (with only-new on, the next run continues from there). Default 1500, from 60 to 3600.

## `stateStoreName` (type: `string`):

Name of the key-value store that remembers delivered comment ids (ids and counts only, no text) for only-new runs. Use another name for another job. 3 to 63 characters: lowercase letters, digits, hyphens.

## Actor input object example

```json
{
  "videos": [
    "dQw4w9WgXcQ"
  ],
  "includeReplies": true,
  "maxCommentsPerVideo": 100,
  "order": "time",
  "onlyNew": false,
  "maxQuotaUnits": 500,
  "maxRunSeconds": 1500,
  "stateStoreName": "youtube-comments-state"
}
```

# Actor output Schema

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

One row per comment or reply (type comment) and one free summary row per video (type videoSummary).

## `summary` (type: `string`):

Comments delivered, status per video, quota units used against your budget and why the run stopped, if it stopped early.

# 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 = {
    "videos": [
        "dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bardach_technologies/youtube-comments-data-api").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 = { "videos": ["dQw4w9WgXcQ"] }

# Run the Actor and wait for it to finish
run = client.actor("bardach_technologies/youtube-comments-data-api").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 '{
  "videos": [
    "dQw4w9WgXcQ"
  ]
}' |
apify call bardach_technologies/youtube-comments-data-api --silent --output-dataset

```

## MCP server setup

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

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/buxLqqdypxyoyx1Kn/builds/mdYQZTUlb642prgbJ/openapi.json
