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.
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.
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?
| Situation | Use |
|---|---|
| You need exact video counts or total views, or you already have a Google Cloud project | The official API |
| You have links of every shape, no Google project, or you want the channel's latest uploads in the same workflow | An 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.
APIs used in this guide
-
1 credit
YouTube Channel API
Subscribers, video count, description, keywords and avatar for a channel, from a handle, id or URL.
GET /v1/youtube/channel -
1 credit
YouTube Channel Videos API
The latest uploads of a channel, newest first, with views, duration and publish time.
GET /v1/youtube/channel/videos
More guides
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to give Claude or Cursor access to YouTube (MCP server)