For AI

Answers

How do I get a YouTube channel's subscriber count and stats through an API?

Short answer

Call YouTube channel profile with the @handle or the UC… channel ID: it returns subscribers and video count as YouTube shows them, and with view=full the channel's total views, the day it joined, its country and its About links, for $0.002 a channel. No Google Cloud project or API key is needed. If you already have one, the Data API's channels.list returns the same statistics for 1 quota unit per call, with subscriberCount rounded down to three significant figures.

A gaming-accessories brand keeps 60 YouTube channels on its sponsorship shortlist. Once a month the team updates subscribers, total views, join date and country for each, and checks how many views the latest uploads got, because an old channel's subscriber count often overstates who still watches. They have handles copied from channel links, not channel IDs.

Profile: one call per channel

YouTube channel profile takes username (the handle, with or without @) or id (the 24-character channel ID that starts with UC).

Field Meaning
followers Subscribers, as YouTube shows them on the channel
posts Videos, as YouTube shows them
name, bio, avatar_url, verified, url Channel details
ext.views Total views of the channel
ext.created_at The day the channel joined YouTube
ext.country, ext.links, ext.banner_url Country, the links in its About section, banner

The ext fields come with view=full. YouTube rounds both counts on the page (15.1M subscribers, 1.2K videos), so followers comes back as 15100000. Exact counts are not public.

Recent views: one page of uploads

YouTube channel videos lists a channel's uploads newest first, about 30 a page, with title, views, cover, length and roughly when each was published (YouTube says "3 weeks ago"). Add type=short for the channel's Shorts instead. The median views of the last 30 videos is a better reach figure than subscribers.

Finding channels you don't know yet

YouTube channel search takes keywords and returns 20 channels a page with channel ID, name, the start of the description, avatar and subscribers, for $0.004 a page. Results carry no handle or verification badge; for the badge and the total views, pass the channel ID to the profile endpoint.

A monthly sheet in Python

import csv, datetime, os, statistics, requests

API = "https://api.okdata.online"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

def get(path, **params):
    body = requests.get(API + path, headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']}")
    return body["data"]

today = datetime.date.today().isoformat()
with open("channels.csv", "a", newline="", encoding="utf-8") as f:
    w = csv.writer(f)
    for handle in ["mkbhd", "LinusTechTips", "veritasium"]:
        ch = get("/v1/youtube/channels/get", username=handle, view="full")["item"]
        vids = get("/v1/youtube/channels/videos/list", id=ch["id"])["items"]
        views = [v["metrics"]["views"] for v in vids if v["metrics"]["views"] is not None]
        w.writerow([today, handle, ch["id"], ch["followers"], ch["posts"], ch["ext"]["views"],
                    ch["ext"]["created_at"], ch["ext"]["country"],
                    int(statistics.median(views)) if views else ""])

What it costs

Job Calls Cost
One channel profile 1 $0.002
60 channels, profile and one page of videos 60 + 60 $0.24
100 channels found by keyword 5 $0.02
1,000 channel profiles 1000 $2.00

A handle or channel ID that does not exist comes back from the profile endpoint as not_found, charged like any lookup, and a call that fails at the data source is charged too. The video list cannot tell a missing channel from an empty one, which is why the script asks for the profile first and passes on its id.

Limits

  • Counts are rounded the way YouTube rounds them. A channel that hides its subscriber count has no public number, so check followers for null before you compare channels.
  • Publish times in the video list are approximate, because YouTube shows them as "3 weeks ago". For an exact date and the like count of one video, use YouTube video detail at $0.002.
  • The video list has one order, newest first. There is no most-viewed sort.
  • There is no history. Keep a dated row per month, as the script does, to chart growth.

The official YouTube Data API

With a Google Cloud project, channels.list with part=statistics returns subscriberCount, viewCount and videoCount, takes a comma-separated list of channel IDs or a forHandle in one request, and costs 1 quota unit per call. The default quota is 10,000 units a day, so for a fixed list of known channels it is the cheapest option and you should use it. Google's reference states that subscriberCount is rounded down to three significant figures and that videoCount counts public videos only. The quota is tighter for discovery: the default allocation includes 100 search.list calls a day. okdata fits when you do not want to run a project and keys, when you search for channels every day, or when an agent pulls the numbers alongside TikTok and X through the MCP server. For one video's views, see YouTube view counts.

Sources

Where people asked this (read 2026-11-15)

Updated

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp