# Channel Stats, Live Streams & Comments for YouTube (`panda_studio/channel-stats-for-youtube`) Actor

Channel stats, recent uploads, live & upcoming streams, trending charts by country, and comments via the official YouTube Data API v3 with your own free key. No scraping, no proxies, no blocking.

- **URL**: https://apify.com/panda\_studio/channel-stats-for-youtube.md
- **Developed by:** [panda studio](https://apify.com/panda_studio) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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

## Channel Stats, Live Streams & Comments for YouTube (Official API)

Get **channel statistics, recent uploads, live and upcoming streams, country trending charts, video details and comments** from the **official YouTube Data API v3** – using **your own free Google API key**.

No scraping, no proxies, no CAPTCHAs, no random breakage when the YouTube page layout changes. You get exactly what the official API returns, in clean flat JSON / CSV / Excel.

> Not affiliated with or endorsed by YouTube or Google. This Actor is an API client: you bring your own YouTube Data API key and you agree to the [YouTube API Services Terms of Service](https://developers.google.com/youtube/terms/api-services-terms-of-service).

### Why use this instead of a scraper?

| | This Actor (official API) | Typical page scrapers |
|---|---|---|
| Source | YouTube Data API v3 | HTML / internal endpoints |
| Stability | Stable, versioned API | Breaks when YouTube changes |
| Proxies needed | No | Usually residential proxies |
| Exact counts | Yes (views, likes, comments, subscribers\*) | Often rounded ("1.2M") |
| Live stream schedule | `scheduledStartTime`, `actualStartTime`, `concurrentViewers` | Rarely |
| Cost | $0.50 per 1,000 rows + your free Google quota | $1–5 per 1,000 rows |

\* Subscriber counts are rounded by YouTube itself for channels over 1,000 subscribers; hidden counts return `null`.

### What you can do

- **Channel monitoring** – subscribers, total views, video count, country, created date for any list of channels (`@handle`, URL or `UC…` ID).
- **Recent uploads with stats** – the latest N videos per channel with views, likes, comments, duration, tags, language.
- **Live & upcoming stream schedule** – turn on *Only live & upcoming streams* to get what your favourite streamers / VTubers / competitors are live with now or have scheduled, with start times. Run it on a schedule and send it to Slack, Discord, Google Sheets or a webhook.
- **Trending charts by country** – the official "most popular" chart for `JP`, `US`, `KR`, `IN`, `GB` … optionally by category (Music = 10, Gaming = 20).
- **Video details** – full statistics for any list of video / Shorts / live URLs.
- **Comments** – top or newest comments (plus up to 5 replies per thread) for sentiment analysis, community management or research.
- **Keyword search** – optional; note that search costs 100 quota units per page.

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

1. Open [Google Cloud Console](https://console.cloud.google.com/) and create (or pick) a project.
2. *APIs & Services → Library* → search **YouTube Data API v3** → **Enable**.
3. *APIs & Services → Credentials* → **Create credentials → API key**.
4. Optional but recommended: *Restrict key → API restrictions → YouTube Data API v3*. Do **not** add HTTP-referrer or IP restrictions (Apify servers would be blocked).
5. Paste the key into the **YouTube Data API key** field. It is stored encrypted as a secret input and only sent to `googleapis.com`.

The free quota is **10,000 units per day** per Google project (resets at midnight Pacific Time).

### Quota cost per feature

| Feature | YouTube quota units |
|---|---|
| Channel stats | 1 per channel |
| Recent uploads | ~2 per 50 videos |
| Video details | 1 per 50 videos |
| Trending chart | 1 per 50 videos |
| Comments | 1 per 100 comments |
| Keyword search | **100 per 50 results** |

Example: 100 channels × 20 recent videos ≈ 300 units – about 3% of the free daily quota. The run summary (key-value store `RUN_SUMMARY`) shows the units used.

### Input example

```json
{
  "apiKey": "YOUR_KEY",
  "channels": ["@YouTube", "https://www.youtube.com/@GoogleDevelopers"],
  "recentVideosPerChannel": 10,
  "trendingRegions": ["JP", "US"],
  "commentsForVideos": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "maxCommentsPerVideo": 200
}
```

Stream schedule only:

```json
{ "apiKey": "YOUR_KEY", "channels": ["@channelA", "@channelB"], "onlyLiveAndUpcoming": true }
```

### Output

Every row has a `type`: `channel`, `video` or `comment`.

```json
{
  "type": "video",
  "videoId": "bbbbbbbbbbb",
  "url": "https://www.youtube.com/watch?v=bbbbbbbbbbb",
  "title": "Weekly live stream",
  "channelTitle": "Example Channel",
  "liveStatus": "upcoming",
  "scheduledStartTime": "2026-10-01T12:00:00Z",
  "durationSeconds": 0,
  "viewCount": 0,
  "likeCount": 12,
  "commentCount": 0,
  "tags": ["live"],
  "source": "channel:UC...",
  "fetchedAt": "2026-09-25T00:00:00.000Z"
}
```

`liveStatus` is one of `live`, `upcoming`, `was_live`, `was_scheduled`, `none`. Trending rows also have `trendingRank`.

### Pricing

Pay per event: **$0.0005 per result row** ($0.50 per 1,000) plus a tiny start fee. Runs without an API key finish with a setup message and are **not charged** for results. Use *Max results in total* to cap the cost of a run.

### Errors are explained, not hidden

- Missing key → a clear setup message (no charge).
- Invalid key / API not enabled / key restricted → the run fails with a message telling you exactly what to fix.
- Daily quota exhausted → the run stops early and **keeps the rows already collected**.
- Comments disabled / private or deleted videos → skipped with a warning in the log and `RUN_SUMMARY`.

### Data use

The data comes from the YouTube Data API and is subject to the YouTube API Services Terms and Developer Policies (for example, refreshing or deleting stored API data after 30 days). Comments contain public personal data (display names); process them in line with the GDPR / your local privacy law. This Actor does not keep any data outside your own Apify storage.

### Support

Found a bug or need a field? Open an issue on the Actor's *Issues* tab – we reply within a few days.

# Actor input Schema

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

Your own YouTube Data API v3 key (free, 10,000 quota units per day). Google Cloud Console > APIs & Services > Library > enable "YouTube Data API v3" > Credentials > Create credentials > API key. The key is stored encrypted and only sent to googleapis.com.

## `channels` (type: `array`):

Channel handles (@name), channel URLs or channel IDs (UC...). Returns channel statistics and the most recent uploads with live status.

## `recentVideosPerChannel` (type: `integer`):

How many of the latest uploads to return per channel (0 = channel stats only). Costs about 1 quota unit per 50 videos.

## `onlyLiveAndUpcoming` (type: `boolean`):

Stream schedule mode: return only videos that are live now or scheduled (upcoming) among the latest uploads (checks at least 30). Channel rows are skipped.

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

Video URLs or IDs (watch, youtu.be, shorts, live). Returns full statistics, duration, tags and live details.

## `commentsForVideos` (type: `array`):

Video URLs or IDs to download public comments from.

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

Top-level comments per video. 1 quota unit per 100 comments.

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

Order of comments.

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

Also return replies included in each thread (the API returns up to 5 replies per thread).

## `trendingRegions` (type: `array`):

ISO country codes for the official most-popular chart, e.g. JP, US, KR, GB, IN.

## `trendingCategoryId` (type: `string`):

Optional video category ID, e.g. 10 = Music, 20 = Gaming, 24 = Entertainment. Leave empty for all.

## `maxTrendingPerRegion` (type: `integer`):

Up to 200 per country.

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

Keyword search for videos. Note: each search page costs 100 quota units (about 100 searches per day with the free quota).

## `maxSearchResults` (type: `integer`):

Videos per query (50 per page).

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

Sort order for search.

## `searchRegionCode` (type: `string`):

Optional ISO country code, e.g. JP.

## `searchLanguage` (type: `string`):

Optional language code, e.g. ja, en.

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

Safety cap for the number of rows (and cost) of one run.

## Actor input object example

```json
{
  "channels": [
    "@YouTube"
  ],
  "recentVideosPerChannel": 10,
  "onlyLiveAndUpcoming": false,
  "maxCommentsPerVideo": 100,
  "commentOrder": "relevance",
  "includeReplies": false,
  "maxTrendingPerRegion": 50,
  "maxSearchResults": 25,
  "searchOrder": "relevance",
  "maxItems": 1000
}
```

# Actor output Schema

## `items` (type: `string`):

All items produced by this run, stored in the default dataset.

# 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 = {
    "channels": [
        "@YouTube"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("panda_studio/channel-stats-for-youtube").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 = { "channels": ["@YouTube"] }

# Run the Actor and wait for it to finish
run = client.actor("panda_studio/channel-stats-for-youtube").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 '{
  "channels": [
    "@YouTube"
  ]
}' |
apify call panda_studio/channel-stats-for-youtube --silent --output-dataset

```

## MCP server setup

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

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/jjxW4j9VXkKHAymLx/builds/JIxBtVvcR5l00BRzi/openapi.json
