How to get a YouTube channel's subscriber count in Python

Checked on 2026-11-18.

Reading a channel's subscriber count takes one request. Before the code, one fact that saves a search for a better source: for channels you do not own, the exact number does not exist anywhere public.

Why the number is always rounded

YouTube publishes subscriber counts with three significant figures: a channel with 21,437,812 subscribers shows as 21.4M everywhere. Google's reference for the official API says the same about its own field: the value "is rounded down to three significant figures". Only the channel's owner sees the exact count, in YouTube Studio. So every method below returns 21,400,000 for that channel, and a tool that claims a live exact count is estimating.

1. The official YouTube Data API

channels.list costs 1 quota unit and accepts a handle directly. It also returns the exact number of public videos and the channel's total views. You need a Google Cloud project and an API key.

Python
import os
import requests

res = requests.get(
    "https://www.googleapis.com/youtube/v3/channels",
    params={
        "part": "snippet,statistics",
        "forHandle": "@mkbhd",
        "key": os.environ["YOUTUBE_API_KEY"],
    },
    timeout=30,
)
items = res.json().get("items", [])
if not items:
    print("No such channel")
else:
    stats = items[0]["statistics"]
    subscribers = None if stats["hiddenSubscriberCount"] else int(stats["subscriberCount"])
    print(items[0]["snippet"]["title"], subscribers, int(stats["videoCount"]), int(stats["viewCount"]))

A channel can hide its subscriber count. hiddenSubscriberCount tells you, and the code above returns None then. The counts arrive as text, hence int().

2. An HTTP API, without a Google project

With Pipefetch one request takes a handle, a channel ID or any channel URL, including old /c/ and /user/ links, and returns the subscriber count with the description, keywords and avatar.

Python
import os
import requests

res = requests.get(
    "https://pipefetch.com/v1/youtube/channel",
    params={"channel": "@mkbhd"},
    headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
    timeout=90,
)
if res.status_code == 404:
    print("No such channel")  # not charged
else:
    res.raise_for_status()
    channel = res.json()["data"]
    print(channel["title"], channel["subscriberCount"], channel["videoCount"], channel["id"])

The numbers are already numbers. The subscriber count is the same rounded figure, and the video count here is YouTube's rounded display value too (1,800 for "1.8K videos"), so use the official API when you need the exact number of videos or the channel's total views. A request costs 1 credit. The reference lists every field.

Which one should you use?

SituationUse
You need exact video counts or total views, or you already have a Google Cloud projectThe official API
You have links of every shape, no Google project, or you want the channel's latest uploads in the same workflowAn HTTP API such as Pipefetch

Tracking growth over time

Because the public number moves in steps (21.4M, then 21.5M), daily checks of a large channel show no change for weeks. Store one reading a day and compare over months; for small channels the three figures change often enough to see weekly growth. To follow what a channel publishes, see the guide on listing a channel's videos.

Try it with 100 free credits. No card, no Google Cloud project, no OAuth. Get an API key or read the docs.