# YouTube Channel Stats & Recent Videos Scraper (`mdcurt/youtube-channel-stats`) Actor

Channel snapshot for any YouTube handle, URL or channel id: subscribers, video count, latest uploads with views and duration, plus computed averages and upload cadence — one request per channel, no login, no API key.

- **URL**: https://apify.com/mdcurt/youtube-channel-stats.md
- **Developed by:** [Matthew Curtis](https://apify.com/mdcurt) (community)
- **Categories:** Social media, AI
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Channel Stats & Recent Videos Scraper

Channel snapshot for any YouTube handle, channel URL or channel id — **without the YouTube Data API, its quota or an API key**:
subscribers, video count, the latest uploads with views, dates and durations, and computed metrics (average and median views,
uploads per week, latest upload, views per subscriber). One request per channel, first record in about a second, pay per result.

Built for agents and batch lookups alike: pass `["@MrBeast"]` and get one record back in ~2 seconds, or pass 1,000 channels and
get 1,000 snapshot records for about a dollar. Each channel costs **one request** — the header stats and the newest 30 uploads come
from the same page, so there is no per-video crawl to pay for unless you ask for one.

### What it does

For every entry in `channels` the Actor opens the channel's **Videos** tab (or Shorts / Live streams, your choice) and returns one
`channel` record:

- identity: `id` (UC… channel id), `url`, `handle`, `title`, `description` (≤ 300 chars), `avatar`, `banner`, `keywords`, `isVerified`, `isFamilySafe`, `availableCountries`, `rssUrl`, `socialLinks` (the public links the channel lists), `tabs`
- header stats: `subscriberCount` (+ `subscriberCountText`), `videoCount` (+ `videoCountText`)
- `recentVideos[]` — the first page of the chosen tab, up to 30 uploads: `id`, `url`, `title`, `videoType`, `viewCount`, `viewCountText`, `publishedText`, `publishedAt`, `durationSeconds`, `durationText`, `thumbnail`, `isLive`
- `metrics` computed from that sample: `sampleSize`, `sampleTab`, `avgViews`, `medianViews`, `maxViews`, `latestUploadAt`, `oldestSampledUploadAt`, `uploadsPerWeek`, `avgDurationSeconds`, `viewsPerSubscriber` (average views ÷ subscribers), `medianViewsPerSubscriber` (median views ÷ subscribers: the typical upload, which one promoted video cannot move)

Turn on `includeVideos` to additionally get one `video` record per sampled upload (flat rows for spreadsheets, BI tools and
[dataset-diff-monitor](https://apify.com/mdcurt/dataset-diff-monitor) alerts on new uploads).

Typical uses: influencer vetting and sponsorship research (is the channel active, what does a video really get versus its
subscriber count), competitor and niche tracking, creator CRM enrichment, "find me the latest video of X" agent tools, and
scheduled monitoring of subscriber and upload cadence over time.

### Input

| Field | Type | Default | Meaning |
|---|---|---|---|
| `channels` | string\[] | `["@MrBeast"]` | Handles (`@NASA` or `NASA`), channel URLs (`youtube.com/@…`, `/channel/UC…`, `/c/…`, `/user/…`) or `UC…` ids. One request each. |
| `tab` | `videos` | `shorts` | `streams` | `videos` | Which tab supplies `recentVideos` and the metrics. A Shorts-only channel (no Videos tab) falls back to its Shorts tab automatically. |
| `includeVideos` | boolean | `false` | Also push one `video` record per sampled upload. |
| `maxItems` | integer 1–5000 | `50` | Cap on records (channels + videos). |
| `knownIds` | string\[] | `[]` | Video ids you already have; skipped when `includeVideos` is on, so a scheduled run only pays for new uploads. |
| `proxyConfiguration` | object | Apify Proxy, datacenter | Datacenter proxies pass (222/222 requests at concurrency 6 in testing). Use RESIDENTIAL only if `SUMMARY.blocked` > 0. |

Example — one channel for an agent:

```json
{ "channels": ["@veritasium"], "maxItems": 1 }
```

Example — a sponsorship shortlist with flat video rows:

```json
{ "channels": ["@MKBHD", "@LinusTechTips", "UCX6OQ3DkcsbYNE6H8uQQuVA"], "includeVideos": true, "maxItems": 100 }
```

### Output

Sample `channel` record (trimmed):

```json
{
  "kind": "channel",
  "id": "UCLA_DiR1FfKNvjuUpBHmylQ",
  "url": "https://www.youtube.com/@NASA",
  "handle": "@NASA",
  "title": "NASA",
  "description": "NASA's mission is to explore the unknown in air and space, innovate for the benefit of humanity, and inspire the world through discovery. …",
  "subscriberCount": 15100000,
  "subscriberCountText": "15.1M subscribers",
  "videoCount": 6100,
  "videoCountText": "6.1K videos",
  "isVerified": true,
  "isFamilySafe": true,
  "keywords": ["NASA", "space", "science", "astronomy"],
  "avatar": "https://yt3.googleusercontent.com/…",
  "banner": "https://yt3.googleusercontent.com/…",
  "rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UCLA_DiR1FfKNvjuUpBHmylQ",
  "availableCountries": 249,
  "socialLinks": ["https://www.nasa.gov", "https://x.com/nasa", "https://www.instagram.com/nasa"],
  "tabs": ["Home", "Videos", "Shorts", "Live", "Playlists", "Posts"],
  "recentVideos": [
    { "id": "Af6i6ChAVTw", "url": "https://www.youtube.com/watch?v=Af6i6ChAVTw", "title": "…", "videoType": "video",
      "viewCount": 97000, "viewCountText": "97 thousand views", "publishedText": "2 weeks ago", "publishedAt": "2026-10-19T18:25:17.503Z",
      "durationSeconds": 1434, "durationText": "23:54", "thumbnail": "https://i.ytimg.com/vi/Af6i6ChAVTw/hq720.jpg…", "isLive": false }
  ],
  "metrics": { "sampleSize": 30, "sampleTab": "videos", "avgViews": 267800, "medianViews": 97000, "maxViews": 2100000,
    "latestUploadAt": "2026-10-20T18:25:17.503Z", "oldestSampledUploadAt": "2026-05-04T18:25:17.503Z", "uploadsPerWeek": 1.24,
    "avgDurationSeconds": 1180, "viewsPerSubscriber": 0.0177, "medianViewsPerSubscriber": 0.0064 },
  "source": { "query": "@NASA", "tab": "videos", "pageUrl": "https://www.youtube.com/@NASA/videos?hl=en&gl=US" },
  "scrapedAt": "2026-11-02T18:25:18.000Z"
}
```

A `video` record (with `includeVideos`) carries the same video fields plus `channelId`, `channelHandle`, `channelTitle`.

The run's `SUMMARY` record (key-value store) reports `channelRecords`, `videoRecords`, `notFoundInputs`, `invalidInputs`,
`fallbackPages`, `emptyChannels`, `blocked`, `rateLimited`, p95 latency, time to first record and compute seconds.

### Pricing

Pay per event: **$0.005 per run start** and **$0.001 per record** (Store discounts for paid plans: −10 % / −15 % / −20 %).

- One channel lookup: $0.006. 100 channels: $0.105. 1,000 channels: $1.005.
- A channel snapshot bundles the header stats, the newest 30 uploads and the computed metrics into **one** record — the same data as
  a 30-row "channel videos" export elsewhere, for the price of one row.
- Datacenter proxy traffic only; runs finish in seconds, so platform compute is negligible.

### Monitoring a channel (incremental mode)

1. Run with `includeVideos: true` on a schedule.
2. Pass the `id` values of your last run's `video` records as `knownIds` — known uploads are skipped and not charged.
3. Point [mdcurt/dataset-diff-monitor](https://apify.com/mdcurt/dataset-diff-monitor) at the dataset to get a webhook/e-mail when
   a new upload appears or `subscriberCount` / `metrics.avgViews` moves.

### Speed (live tests, 2026-11-02, datacenter egress)

| Run | Result |
|---|---|
| 1 channel, `maxItems` 1 | 1 record, first record **1.3 s**, 1.3 s compute |
| 7 inputs (handle, URL, UC id, `/c/`, `/user/`, a bogus handle, a non-URL) | 4 records, 2 not found, 1 invalid — 2.7 s |
| 3 channels, Shorts tab, `includeVideos` | 3 channel + 37 video records from **3 requests**, 1,263 records/min |
| 3 channels incl. a Shorts-only one, `knownIds` | 30 records, fallback page used once, 1 known id skipped |
| **220 channels** | **220 records, 222/222 requests OK, 0 blocked**, 61 s, 216 channels/min, concurrency ramped 2 → 6 |

### Limitations

- Counts on channel pages are **rounded the way YouTube shows them** ("80.5M subscribers", "9.9K views", "1K videos"); the record
  keeps the original text next to the parsed number. Exact lifetime view totals and the "joined" date are not on these pages.
- The sample is the first page of the tab: up to 30 long-form videos, ~48 Shorts, or the latest streams. Shorts carry no upload
  dates, so `uploadsPerWeek` and `latestUploadAt` are null when the sample is Shorts.
- `publishedAt` is derived from YouTube's relative text ("2 weeks ago") at scrape time — same precision as the text.
- Channels with no uploads tab (playlist-only channels) return the header record with an empty sample.
- Only public, robots-allowed channel pages are read. No login, no cookies, no YouTube Data API, no innertube calls; e-mail
  addresses in descriptions are redacted. Video pages themselves are not opened — use the `url` fields to go deeper.

### For AI agents

Pass `channels` with one handle, channel URL or `UC…` id and `maxItems: 1`. One record comes back in about 2 seconds with `subscriberCount`, `videoCount`, the newest uploads in `recentVideos` and `metrics` (`medianViews`, `avgViews`, `medianViewsPerSubscriber`, `uploadsPerWeek`, `latestUploadAt`). One lookup costs $0.005 + $0.001 = $0.006. A handle that does not exist returns no record, is listed in `SUMMARY.notFoundInputs` and costs only the run start. Prefer `medianViews` over `avgViews` when judging a channel: on brand channels a few promoted videos pull the average far above what a typical upload gets.

### Tutorials

- **Benchmark brand YouTube channels by median views per upload** in `examples/brand-channel-benchmark/` of the Actor source: a real 65-record sample (75 guessed handles of restaurant chains, airlines and beauty brands, 2026-11-14, 78 requests, 0 failed, $0.07), per-category tables sorted by `medianViewsPerSubscriber`, the ten guessed handles that are almost certainly not the brand, and the weekly dataset-diff-monitor recipe. The ready-made input is the example task `youtube-brand-benchmark`.

### Changelog

- **1.0.1** (2026-11-14) — `metrics.medianViewsPerSubscriber` added. Fix: `metrics.medianViews` of an even-sized sample is now the mean of the two middle values (it was the upper one, which overstated the median). A channel whose `/@handle/videos` URL redirects to a legacy `/user/…` address and lands on the Home tab (Sephora, Pizza Hut) used to come back with an empty upload sample; the Actor now asks once more through the canonical `/channel/UC…` URL (`SUMMARY.canonicalRetries`), and the Shorts-only fallback uses the same canonical URL. For AI agents and Tutorials sections.
- **1.0.0** (2026-11-02) — first release: channel snapshot with recent-upload sample and computed metrics; Videos / Shorts / Live
  tabs; optional per-video records; incremental `knownIds`; Shorts-only fallback.

# Actor input Schema

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

Which channels to look up. Each entry is a handle (@MrBeast or MrBeast), a channel URL (https://www.youtube.com/@NASA, /channel/UC…, /c/…, /user/…) or a UC… channel id. One request per channel; the first record arrives in about 2 seconds.

## `tab` (type: `string`):

Which channel tab supplies the recent uploads and the computed metrics: videos (long-form, default), shorts, or streams (live replays). The first page of the tab is read: up to 30 latest uploads. A Shorts-only channel falls back to its Shorts tab automatically.

## `includeVideos` (type: `boolean`):

Off (default): one channel record per input with the sampled uploads embedded in recentVideos. On: additionally one video record per sampled upload (id, title, views, published, duration, channelId) — handy for spreadsheets and dataset-diff monitoring. Each record counts toward maxItems.

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

Maximum number of records to return in total (1–5000): channel records, plus video records when includeVideos is on.

## `knownIds` (type: `array`):

Video ids you already have (the `id` of earlier video records). With includeVideos on they are skipped, so a scheduled run only pays for new uploads. Pair with mdcurt/dataset-diff-monitor to get alerted on new videos or subscriber jumps.

## `proxyConfiguration` (type: `object`):

Apify Proxy settings. Datacenter proxies work for channel pages (tested at 200 requests, concurrency 4–6, zero blocks); switch to a RESIDENTIAL group only if the SUMMARY record reports blocked pages.

## Actor input object example

```json
{
  "channels": [
    "@MrBeast",
    "@NASA"
  ],
  "tab": "videos",
  "includeVideos": false,
  "maxItems": 50,
  "knownIds": [],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `records` (type: `string`):

One channel record per input (kind 'channel': id, url, handle, title, subscriberCount, videoCount, recentVideos\[], metrics{avgViews, medianViews, uploadsPerWeek, latestUploadAt}) and, with includeVideos, one record per sampled upload (kind 'video').

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

SUMMARY record: channels and videos pushed, inputs not found or invalid, fallback pages, blocked pages, p95 latency, time to first record and compute seconds.

# 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": [
        "@MrBeast",
        "@NASA"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("mdcurt/youtube-channel-stats").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": [
        "@MrBeast",
        "@NASA",
    ],
    "proxyConfiguration": { "useApifyProxy": True },
}

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

```

## MCP server setup

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

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/9oKqqu45PsIPQEyTm/builds/dKfTPftVxTf32gh2P/openapi.json
