# YouTube Scraper: Videos, Channels, Search, Comments (API) (`rawtojson/youtube-data-api-scraper`) Actor

Clean YouTube video, channel, keyword search and comment data from the official YouTube Data API v3 using your own free key. No proxies, no blocks, your quota, our low per-result price.

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

## Pricing

from $2.00 / 1,000 videos

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 Data API Scraper: videos, channels, search and comments

**YouTube scraper built on the official YouTube Data API v3.** Search videos by keyword, read whole channels, get video statistics and comments as clean JSON. You paste your own free Google API key, so there are no proxies, no blocks and no scraping fragility, and the API cost is yours (Google's free tier is 10,000 units per day). You only pay this Actor a low price per result.

### Who is it for

- Marketers and agencies tracking competitor channels and keyword niches.
- Creators and analysts looking for outlier videos (views, likes, engagement rate).
- Researchers and AI/RAG pipelines that need structured YouTube data.
- Anyone who got blocked or overcharged by browser-based YouTube scrapers.

### How it compares with the market leader

| | This Actor | streamers/youtube-scraper (18,254 users/month, 4.1 stars) |
|---|---|---|
| Source | Official YouTube Data API v3 with **your key** | HTML scraping through Apify proxies |
| Video price (per 1,000) | **$2.00** | $4.00 on the free plan (public Store listing, checked Nov 2026) |
| Comment price (per 1,000) | **$1.00** | $2.00 (separate comments Actor) |
| Search + channels + comments | One Actor | Split across Actors |
| Engagement rate, Short flag, clean nulls | Yes | Varies |
| Breaks when YouTube changes its page | No, versioned API | Possible |

Your own API usage is free up to Google's daily quota. Google's quota works in **two buckets** (official docs: [quota cost](https://developers.google.com/youtube/v3/determine_quota_cost) and [getting started](https://developers.google.com/youtube/v3/getting-started)):

- **Search bucket:** each `search.list` call costs 1 unit and also counts against its own default limit of **100 calls per day** ("own quota bucket"). One call returns up to 50 results, so one keyword with 50 results = 1 call.
- **General bucket:** `videos.list`, `channels.list`, `playlistItems.list` and `commentThreads.list` cost 1 unit per call (50 videos per call for details and uploads, up to 100 comments per call); the default is **10,000 units per day**.

Google states the default quota "is subject to change", and your project may have a different one (check Google Cloud Console). A channel with its latest 50 videos is about 3 calls. This Actor's counter follows this model; it has not yet been verified end to end against the real API with these figures (see the project verdict).

### Input

| Field | Description |
|---|---|
| `apiKey` | Your YouTube Data API v3 key (secret field, never stored in files). |
| `searchQueries` | Keywords to search (needs key). |
| `channelUrls` | Channel URLs, `@handles` or `UC...` IDs (needs key). Returns channel stats and latest uploads. |
| `videoUrls` | Video URLs or IDs (watch, youtu.be, shorts). |
| `maxResultsPerQuery`, `maxVideosPerChannel`, `maxItems` | Limits (and spending caps). |
| `includeComments`, `maxCommentsPerVideo`, `commentsOrder` | Optional comments. |
| `order`, `publishedAfter`, `publishedBefore`, `videoDuration`, `regionCode`, `relevanceLanguage` | Search filters. |
| `maxSearchCalls` | Cap on `search.list` calls per run (default 100, Google's default daily limit for that bucket). |
| `maxQuotaUnits` | Safety cap on API units per run (default 3,000); every call counts 1 unit. |

#### How to get a free API key (2 minutes)

1. Open Google Cloud Console, create a project.
2. Enable **YouTube Data API v3**.
3. Create credentials, **API key**. Paste it in the `apiKey` field.

#### Basic mode without a key

If `apiKey` is empty, only `videoUrls` work, reading the public watch page of each video (title, views, likes, duration, channel, tags). Best effort and unreliable on the Apify cloud: YouTube often serves datacenter IPs a page without data, in which case the run stops after 3 failures and you are only charged for the videos actually returned. There are no comment counts. For reliable results use a key.

### Example

Input:

```json
{ "apiKey": "YOUR_KEY", "searchQueries": ["apify tutorial"], "maxResultsPerQuery": 5, "order": "viewCount" }
```

Output item (video):

```json
{
  "type": "video",
  "videoId": "dQw4w9WgXcQ",
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "channelTitle": "Rick Astley",
  "publishedAt": "2009-10-25T06:57:33Z",
  "durationSeconds": 213,
  "duration": "3:33",
  "isShort": false,
  "viewCount": 1840194641,
  "likeCount": 19515996,
  "commentCount": 2400000,
  "engagementRatePct": 1.2,
  "tags": ["rick astley", "never gonna give you up"],
  "searchQuery": "apify tutorial",
  "source": "youtube-data-api-v3",
  "checkedAt": "2026-11-23T15:33:33.829Z"
}
```

Channel items carry `subscriberCount` (null if the owner hides it), `videoCount`, `viewCount`, `country`, `handle`, `createdAt`. Comment items carry `author`, `text`, `likeCount`, `replyCount`, `publishedAt`.

### Pricing

Pay per event. Per video: **$0.002**. Per channel: **$0.002**. Per comment: **$0.001**. Only valid results are charged; videos that are private or removed are skipped and free. You also keep control with `maxItems` and `maxQuotaUnits`.

### Schedule and send to Google Sheets or a webhook

1. Create a Task with your input and a Schedule (for example daily at 08:00).
2. Add an integration: **Google Sheets** (append dataset items) or **Webhook** on "run succeeded".
3. Use `publishedAfter` with yesterday's date to get only new videos.

### FAQ

**Why do I need my own key?** So the API cost and quota are yours. By Google's default limits (subject to change) you get 100 `search.list` calls per day (each returns up to 50 results) plus 10,000 units per day for the other calls.

**What if I run out of quota?** The run stops with a clear message (in English and Spanish) saying whether the search bucket or the general units bucket ran out, and keeps everything already saved. The quota resets at midnight Pacific Time.

**Can it get transcripts, or the full comment tree with replies?** Not in this version (the official API does not provide transcripts for third-party videos). Top-level comments only.

**Why is a field null?** The API omits likes or comments when the owner hides them. We return null rather than 0.

### Legal

Uses the official YouTube Data API v3 under Google's terms; you are responsible for complying with the YouTube API Services Terms of Service with your key. Basic mode reads public watch pages and may conflict with YouTube's terms: use it at your own risk and prefer the API. **GDPR:** comments contain author names and text posted publicly; process them only for a lawful purpose and delete on request.

### En español

Actor de YouTube con la API oficial (YouTube Data API v3) y **tu propia clave gratuita**: búsqueda por palabras clave, canales con sus últimos vídeos, estadísticas de vídeos y comentarios opcionales, en JSON limpio. El coste de la API es tuyo (cuota gratuita por defecto: 10.000 unidades al día, más un cubo aparte de 100 llamadas de búsqueda al día; Google indica que puede cambiar); a nosotros solo nos pagas 2 $ por cada 1.000 vídeos, la mitad que el líder. Sin clave solo funciona el modo básico con URLs de vídeos.

# Actor input Schema

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

Your own key from Google Cloud Console (free quota: 10,000 units per day; the API cost is yours, not ours). Needed for search, channels and comments. Leave empty for basic mode with video URLs only.

## `searchQueries` (type: `array`):

One search per keyword (needs API key). Each page of up to 50 results is one search.list call: 1 unit, and it also counts against Google's separate default limit of 100 search calls per day (https://developers.google.com/youtube/v3/determine_quota_cost).

## `channelUrls` (type: `array`):

Channel URLs, @handles or channel IDs (needs API key). Returns channel stats plus its latest uploads (cheap: 1 unit per call of up to 50 videos; a @handle or ID needs no search call).

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

Video URLs or 11-character IDs (watch, youtu.be, shorts, embed).

## `maxResultsPerQuery` (type: `integer`):

Maximum videos returned for each search keyword. Up to 50 per search.list call (1 unit and 1 of your 100 daily search calls); more results need more pages and more calls.

## `maxVideosPerChannel` (type: `integer`):

Maximum latest uploads returned for each channel. Use 0 to get only the channel statistics.

## `includeChannelInfo` (type: `boolean`):

Return one channel item (subscribers, views, country, handle) for every channel you list.

## `maxItems` (type: `integer`):

Hard cap on the number of videos returned (and charged) in this run.

## `includeComments` (type: `boolean`):

Also return top-level comments for each video (needs API key, 1 unit per call of up to 100 comments, charged as separate comment events).

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

Maximum comments returned for each video.

## `commentsOrder` (type: `string`):

Most relevant first or newest first.

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

How YouTube sorts search results.

## `publishedAfter` (type: `string`):

Only videos published after this date (YYYY-MM-DD).

## `publishedBefore` (type: `string`):

Only videos published before this date (YYYY-MM-DD).

## `videoDuration` (type: `string`):

short: under 4 min, medium: 4 to 20 min, long: over 20 min.

## `regionCode` (type: `string`):

Optional ISO 3166-1 alpha-2 country code, for example US or ES.

## `relevanceLanguage` (type: `string`):

Optional ISO 639-1 language code, for example en or es.

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

Safety cap on the API units this run may spend (every API call costs 1 unit; Google's default daily quota is 10,000 units and is subject to change, https://developers.google.com/youtube/v3/getting-started). The run stops cleanly when reached.

## `maxSearchCalls` (type: `integer`):

Cap on search.list calls this run may make. Google gives search.list its own default limit of 100 calls per day, separate from the general units (https://developers.google.com/youtube/v3/getting-started), so the default is 100. Raise it only if your project has a higher search quota.

## Actor input object example

```json
{
  "videoUrls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxResultsPerQuery": 10,
  "maxVideosPerChannel": 10,
  "includeChannelInfo": true,
  "maxItems": 100,
  "includeComments": false,
  "maxCommentsPerVideo": 20,
  "commentsOrder": "relevance",
  "order": "relevance",
  "videoDuration": "any",
  "maxQuotaUnits": 3000,
  "maxSearchCalls": 100
}
```

# Actor output Schema

## `videos` (type: `string`):

Video items with statistics.

## `channels` (type: `string`):

Channel items with statistics.

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

Top-level comments.

# 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"
    ]
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rawtojson/youtube-data-api-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/shMHdHqD5gkFxDeOf/builds/nva7jmhnji5TbsrKl/openapi.json
