# YouTube Data API: Videos, Channels, Playlists, Search, Comments (`omar_jarvis/youtube-data`) Actor

Video stats, channels with every upload, playlists, filtered search and all comments with replies, through the official YouTube Data API v3 and your own free Google API key. Reports quota used per run. Errors are never charged.

- **URL**: https://apify.com/omar_jarvis/youtube-data.md
- **Developed by:** [Omar Nassar](https://apify.com/omar_jarvis) (community)
- **Categories:** Videos, Social media
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.30 / 1,000 results

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 Data API: Videos, Channels, Playlists, Search, Comments

Get YouTube data through the **official YouTube Data API v3** with your own free Google API key. The actor does not scrape youtube.com and does not use proxies. Google does not change the API shape without notice, so runs do not break when the YouTube website changes.

### What you get

| Mode | Input | Output |
|---|---|---|
| `videos` | Video URLs or IDs | One row per video: title, description, tags, views, likes, comment count, duration, definition, captions flag, live-stream times, privacy, license, topics, thumbnail. |
| `channels` | Channel URLs, @handles, /user/ URLs or UC... IDs | One row per channel (subscribers, views, video count, country, handle, banner, keywords), then one video row per upload, newest first, with full stats. |
| `playlists` | Playlist URLs or IDs | One row per playlist, then one video row per item in playlist order, with full stats. |
| `search` | Search queries | Ranked results with full video, channel or playlist stats. Filters: date range, region, language, video length, order, safe search, channel. |
| `comments` | Video URLs or IDs | Every top-level comment and every reply, on all pages. Order: newest or top. Optional word filter. |

Accepted input formats:

- Videos: `youtube.com/watch?v=ID`, `youtu.be/ID`, `/shorts/ID`, `/live/ID`, `/embed/ID`, `m.youtube.com`, or the 11-character ID.
- Channels: `/channel/UC...`, `/@handle`, `@handle`, `/user/name`, `/c/name`, or the `UC...` ID. A `/c/` URL has no API lookup; the actor tries it as a handle.
- Playlists: any URL with `list=`, or the playlist ID.

Duplicates are removed after normalization.

### Get a free Google API key in 2 minutes

1. Open https://console.cloud.google.com and sign in with a Google account.
2. Create a project (top bar, **Select a project** > **New project**). No billing account is necessary.
3. Go to **APIs & Services** > **Library**, search for **YouTube Data API v3**, and click **Enable**.
4. Go to **APIs & Services** > **Credentials** > **Create credentials** > **API key**. Copy the key.
5. Optional: click the key, set **API restrictions** to **YouTube Data API v3**. Do not set website or IP restrictions; Apify runs on changing IP addresses.
6. Paste the key into the **Your Google API key** field. Apify stores it encrypted.

### Quota

Google gives each project 10,000 quota units a day for free, plus 100 search calls a day in a separate bucket. Quota resets at midnight Pacific time.

| Call | Cost | Gives |
|---|---|---|
| Video, channel or playlist details | 1 unit | Up to 50 items |
| Playlist or uploads page | 1 unit | 50 videos |
| Comment page | 1 unit | 100 comments |
| Search page | 1 search call | 50 results |
| Caption track list | 50 units | 1 video |

Examples with the free quota: about 250,000 channel uploads with full stats, or about 900,000 comments, or 5,000 search results a day.

Every run writes the quota it used to the `SUMMARY` record in the key-value store and to the run's status message:

```json
{
  "mode": "comments",
  "inputs": 2,
  "results": 159,
  "errors": 1,
  "stoppedBy": null,
  "quota": { "units_used": 4, "search_calls": 0, "api_calls": 4, "default_daily_units": 10000, "default_daily_search_calls": 100 }
}
```

When the quota is used up, the actor stops, keeps all results found so far, and adds one error row that says so. The error row is not charged.

### Input example

```json
{
  "apiKey": "<your Google API key>",
  "mode": "comments",
  "inputs": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://youtu.be/9bZkp7q19f0"],
  "commentOrder": "relevance",
  "includeReplies": true,
  "maxCommentsPerVideo": 0
}
```

Search example:

```json
{
  "apiKey": "<your Google API key>",
  "mode": "search",
  "searchQueries": ["espresso machine review"],
  "searchType": "video",
  "searchOrder": "viewCount",
  "publishedAfter": "2026-01-01",
  "regionCode": "NL",
  "relevanceLanguage": "nl",
  "videoDuration": "medium",
  "maxResultsPerQuery": 100
}
```

| Field | Modes | Description |
|---|---|---|
| `apiKey` | all | Your Google API key. Required. |
| `mode` | all | `videos`, `channels`, `playlists`, `search` or `comments`. |
| `inputs` | all but search | URLs, IDs or handles. Up to 10,000. |
| `searchQueries` | search | One query per line. |
| `searchType` | search | `video` (default), `channel`, `playlist` or all three. |
| `searchOrder` | search | `relevance`, `date`, `viewCount`, `rating`, `title`, `videoCount`. |
| `publishedAfter`, `publishedBefore` | search | Dates, e.g. `2026-01-01`. |
| `regionCode` | search | Country code, e.g. `NL`. |
| `relevanceLanguage` | search | Language code, e.g. `nl`. |
| `videoDuration` | search | `any`, `short` (under 4 min), `medium` (4 to 20 min), `long` (over 20 min). Videos only. |
| `safeSearch` | search | `moderate`, `none`, `strict`. |
| `searchChannelId` | search | Search inside one channel. |
| `maxResultsPerQuery` | search | 1 to 500 (default 50). |
| `includeUploads` | channels | Return the uploads too (default true). |
| `maxVideosPerChannel` | channels | Default 100. 0 means all. |
| `maxItemsPerPlaylist` | playlists | Default 0 (all). |
| `includeCaptions` | videos | Try to list caption tracks. See Limits. |
| `commentOrder` | comments | `time` (newest, default) or `relevance` (top). |
| `includeReplies` | comments | Return all replies (default true). |
| `maxCommentsPerVideo` | comments | Counts comments and replies. Default 0 (all). |
| `commentSearchTerms` | comments | Only top-level comments that contain these words. |
| `concurrency` | all | Inputs in parallel (default 5). |

### Output

Each row has `type`: `video`, `channel`, `playlist`, `comment` or `error`. The dataset has three table views: Videos, Channels, Comments. Every row also has `input` (the input line it came from), `error` and `scrapedAt`.

Video row (from the local test run with a mocked API):

```json
{
  "input": "https://youtu.be/vid00000001",
  "type": "video",
  "videoId": "vid00000001",
  "url": "https://www.youtube.com/watch?v=vid00000001",
  "title": "Video vid00000001",
  "publishedAt": "2026-03-01T12:00:00Z",
  "channelId": "UCaaaaaaaaaaaaaaaaaaaaaa",
  "channelTitle": "Mock Channel",
  "tags": ["mock", "test"],
  "duration": "PT1H4M13S",
  "durationSeconds": 3853,
  "definition": "hd",
  "hasCaptions": true,
  "privacyStatus": "public",
  "viewCount": 123456,
  "likeCount": 4321,
  "commentCount": 159,
  "topicCategories": ["https://en.wikipedia.org/wiki/Technology"],
  "liveStreaming": null,
  "error": null
}
```

Comment row:

```json
{
  "input": "https://www.youtube.com/watch?v=vid00000001",
  "type": "comment",
  "commentId": "Ug0.r0",
  "videoId": "vid00000001",
  "url": "https://www.youtube.com/watch?v=vid00000001&lc=Ug0.r0",
  "isReply": true,
  "parentId": "Ug0",
  "text": "Comment 900",
  "authorName": "@user900",
  "authorChannelId": "UCxxxxxxxxxxxxxxxxxxx900",
  "likeCount": 4,
  "replyCount": null,
  "publishedAt": "2026-03-02T10:00:00Z"
}
```

Channel rows add `handle`, `country`, `subscriberCount`, `hiddenSubscriberCount`, `viewCount`, `videoCount`, `uploadsPlaylistId`, `bannerUrl` and `keywords`. Video rows from a channel or playlist add `playlistId`, `position` and `sourceChannelId`. Search rows add `searchQuery` and `searchRank`. Counts that the owner hides (likes, subscribers) are `null`, not 0.

Error rows: the input does not parse, a video is private or deleted, comments are off, a handle does not exist, or the quota ran out. **Error rows are not charged.**

### Pricing

**$0.0003 per result** (pay-per-event `result`). No start fee. Error rows are free. Google does not charge for the API within the free quota.

### Limits

- Caption tracks: Google documents `captions.list` as OAuth-only. With `includeCaptions`, the actor tries the call once. If Google refuses the API key, the actor stops trying and sets `captionsError`. The `hasCaptions` field on every video row works without OAuth. Caption text cannot be downloaded with an API key.
- Search returns at most about 500 results per query, and fewer for some orders and filters.
- The uploads list of a very large channel can stop before the oldest videos; this is a YouTube API limit.
- Subscriber counts are rounded by YouTube to 3 significant figures.
- Comments on videos for kids, and on videos with comments off, are not available.
- The actor stops starting new work when your **Max cost per run** is reached.

### Local test

`bash test/mock-test.sh` runs all five modes, a quota-exhausted run and a bad-key run against `test/mock-server.mjs`. The mock server returns responses in the documented API shapes; it is not real YouTube data. The script checks result, error and charge counts, quota units and search parameters, and exits 1 on a mismatch. `scripts/test-all.sh` needs a real key in `test/input.json` for this actor.

# Actor input Schema

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

A free Google Cloud API key with "YouTube Data API v3" enabled. Google gives each project 10,000 quota units a day for free. See the README for the 2-minute setup. Stored encrypted by Apify.

## `mode` (type: `string`):

What to fetch. videos: details and stats per video. channels: channel details plus its uploads. playlists: playlist details plus every video. search: keyword search with filters. comments: all comments and replies per video.

## `inputs` (type: `array`):

For videos and comments: video URLs (watch, youtu.be, shorts, live, embed) or 11-character video IDs. For channels: channel URLs, @handles, /user/ URLs or UC... channel IDs. For playlists: playlist URLs or IDs. Duplicates are removed. Not used in search mode.

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

Search mode only. One query per line.

## `searchType` (type: `string`):

Which result types to return.

## `searchOrder` (type: `string`):

Result order.

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

Only results published on or after this date, e.g. 2026-01-01.

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

Only results published before this date.

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

Two-letter country code (ISO 3166-1), e.g. NL, US, DE. Results that can be watched in that country.

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

Prefer results in this language (ISO 639-1), e.g. nl, en, de.

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

short: under 4 minutes. medium: 4 to 20 minutes. long: over 20 minutes. Any value other than "any" returns videos only.

## `safeSearch` (type: `string`):

Filter restricted content.

## `searchChannelId` (type: `string`):

Optional UC... channel ID. Searches inside that channel only.

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

Up to 500. Each 50 results use one search call; Google allows 100 search calls a day per project by default.

## `includeUploads` (type: `boolean`):

Channels mode: also return the channel's uploaded videos (newest first) with full stats.

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

0 means all uploads. Every 50 videos cost 2 quota units.

## `maxItemsPerPlaylist` (type: `integer`):

0 means all videos.

## `includeCaptions` (type: `boolean`):

Videos mode: try captions.list (50 quota units per video) for track languages. Google documents this call as OAuth-only; if Google refuses the API key, the actor stops trying and reports it in captionsError. Every video row already has hasCaptions.

## `commentOrder` (type: `string`):

Comments mode: newest first or YouTube's top comments.

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

Return every reply, not only top-level comments.

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

Counts comments and replies. 0 means all.

## `commentSearchTerms` (type: `string`):

Optional. Only top-level comments that contain these words.

## `concurrency` (type: `integer`):

How many inputs to process in parallel.

## Actor input object example

```json
{
  "mode": "videos",
  "inputs": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "searchType": "video",
  "searchOrder": "relevance",
  "videoDuration": "any",
  "safeSearch": "moderate",
  "maxResultsPerQuery": 50,
  "includeUploads": true,
  "maxVideosPerChannel": 100,
  "maxItemsPerPlaylist": 0,
  "includeCaptions": false,
  "commentOrder": "time",
  "includeReplies": true,
  "maxCommentsPerVideo": 0,
  "concurrency": 5
}
```

# Actor output Schema

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

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

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

```

## MCP server setup

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

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/1gncluqdxMxWqGGwN/builds/nQSVYm86LQk1MgAQ1/openapi.json
