YouTube

How to Get a YouTube Channel’s Name and Stats via API

Get a YouTube channel’s name, description, subscribers, video count and avatar as JSON by @handle or ID, compared honestly with the Data API channels.list.

By FetchTranscript teamPublished 5 min read

To get a YouTube channel's name and details with an API, request the channel by its @handle or UC… ID and read the JSON: with FetchTranscript, GET /v1/channels/{channel} returns name, description, subscriber_count, video_count, the avatar and the URL for 1 credit. With the official YouTube Data API, the method is channels.list with part=snippet,statistics, at 1 quota unit for up to 50 channels. This guide shows both with working code, says honestly which one fits which job, and covers the fields that are missing or rounded on each side.

The fields you can get

Here is what each API returns for a channel, side by side:

DataFetchTranscript /v1/channels/{channel}YouTube Data API channels.list
Permanent IDchannel_idid
Namenamesnippet.title
Descriptiondescriptionsnippet.description
Subscriberssubscriber_count (rounded, null if hidden)statistics.subscriberCount (rounded), hiddenSubscriberCount
Number of videosvideo_count (Shorts included, null if not shown)statistics.videoCount
Avatarthumbnail_urlsnippet.thumbnails
Channel URLchannel_urlnot returned (build it from the ID)
Handlenot returnedsnippet.customUrl
Total viewsnot returnedstatistics.viewCount
Creation date, countrynot returnedsnippet.publishedAt, snippet.country

Two things stand out. First, both sides round the subscriber count: YouTube itself only shows it to three significant figures (20.2M), and the Data API has returned the same rounded number since 2019. Nobody outside the channel gets the exact figure. Second, if your job needs the channel's total views, creation date or country, the Data API is the better fit: those fields are not in our channel response.

Get a channel's details with curl

Shell
curl -H "X-API-Key: yt_your_api_key" \
  "https://api.fetchtranscript.com/v1/channels/@veritasium"
JSON
{
  "channel_id": "UCHnyfMqiRRG1u-2MsSQLbXA",
  "name": "Veritasium",
  "description": "An element of truth - videos about science, education, and anything else we find interesting.",
  "subscriber_count": 21500000,
  "video_count": 420,
  "thumbnail_url": "https://yt3.googleusercontent.com/...",
  "channel_url": "https://www.youtube.com/channel/UCHnyfMqiRRG1u-2MsSQLbXA"
}

The values are illustrative. The path takes a handle (@veritasium, with or without the @, any case) or a UC… ID. When you start from a URL or a name rather than a handle, see how to get a YouTube channel ID first. A channel that does not exist answers 404 channel_not_found, an identifier that is neither a handle nor an ID answers 400 invalid_channel_id, and errors cost nothing. Channel details are cached for 24 hours, which matches how often the public numbers move in a meaningful way.

Python: details of a list of channels to CSV

A creator shortlist, a competitor set, a list of channels to sponsor: the job is usually "these 200 channels, their name and size, in a spreadsheet".

Python
import csv
import requests

API = "https://api.fetchtranscript.com/v1"
HEADERS = {"X-API-Key": "yt_your_api_key"}


def channel_details(channel: str) -> dict | None:
    r = requests.get(f"{API}/channels/{channel}", headers=HEADERS, timeout=30)
    if r.status_code in (400, 404):
        return None  # not a channel: not billed
    r.raise_for_status()
    return r.json()


channels = ["@veritasium", "@mkbhd", "@kurzgesagt", "@no-such-channel-xyz"]

with open("channels.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.writer(f)
    writer.writerow(["input", "channel_id", "name", "subscribers", "videos", "url"])
    for channel in channels:
        d = channel_details(channel)
        if d is None:
            writer.writerow([channel, "", "not found", "", "", ""])
            continue
        writer.writerow([channel, d["channel_id"], d["name"], d["subscriber_count"], d["video_count"], d["channel_url"]])

With the official SDK (pip install fetchtranscript) the request is one line, client.channels.get_info("@veritasium"), and a missing channel raises ChannelNotFoundError:

Python
from fetchtranscript import FetchTranscriptClient

client = FetchTranscriptClient(api_key="yt_your_api_key")
channel = client.channels.get_info("@veritasium")
print(channel["name"], channel["subscriber_count"], channel["video_count"])

JavaScript with the SDK

JavaScript
// Node 18+ as an ES module, after npm install fetchtranscript
import { FetchTranscriptClient } from 'fetchtranscript';

const client = new FetchTranscriptClient({ apiKey: 'yt_your_api_key' });

const channel = await client.channels.getInfo('@veritasium');
console.log(`${channel.name}: ${channel.subscriber_count ?? 'hidden'} subscribers, ${channel.video_count ?? '?'} videos`);
console.log(channel.channel_url);

The SDK's types (ChannelMetadataResponse) mark subscriber_count, video_count and thumbnail_url as possibly null, so your code handles hidden counts from the start.

The same with the YouTube Data API

Shell
curl "https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forHandle=@veritasium&key=YOUR_GOOGLE_API_KEY"

The answer is an items array; the name is items[0].snippet.title and the numbers are in items[0].statistics, as strings. channels.list costs 1 unit whatever the parts, and with id= it takes up to 50 comma-separated channel IDs in one request. With the default 10,000 units a day, that is a lot of channels.

So, honestly: if all you need is channel statistics for channels whose IDs you know, the Data API is cheaper and returns more fields. It asks for a Google Cloud project and an API key, quotas to watch, and the YouTube API Services terms, which limit how long you may store some data. FetchTranscript is the better fit when channel details are one step in a larger job (resolving pasted handles, then listing the channel's videos with durations and views, then fetching transcripts or comments) and you would rather have one key, one bill per call and no quota. The YouTube search API without quota guide explains the Data API quota in detail.

The channel name from a video

When you have a video and want its channel, you do not need the channel endpoint at all: GET /v1/videos/{video_id} returns channel_name and channel_id with the video's views, likes, upload date and tags.

Shell
curl -H "X-API-Key: yt_your_api_key" \
  "https://api.fetchtranscript.com/v1/videos/dQw4w9WgXcQ"

Our guide to YouTube video metadata lists every field. Search results carry channel_name and channel_id for every video too, so a search is a cheap way to discover the channels active on a topic.

Track a channel's growth over time

The public numbers only become interesting over time. A small daily job that stores one row per channel per day gives you a growth chart for any channel, including competitors:

Python
import datetime
import json

today = datetime.date.today().isoformat()
with open("channel_history.jsonl", "a", encoding="utf-8") as f:
    for channel in ["@veritasium", "@mkbhd"]:
        d = channel_details(channel)
        if d:
            f.write(json.dumps({"date": today, "channel_id": d["channel_id"],
                                "subscribers": d["subscriber_count"], "videos": d["video_count"]}) + "\n")

Keep in mind that subscriber counts are rounded to three significant figures, so a channel of 21.5 million moves in steps of 100,000: for big channels the video count and the views of recent uploads tell you more. The latest uploads, with their views and durations, come from the video list, GET /v1/channels/{channel}/videos; the full walkthrough, with pagination and Shorts, is in how to get all videos from a YouTube channel.

What it costs

Each successful channel lookup is 1 credit. Every account gets 100 free calls a month, then pay-as-you-go is $1 per 1,000 calls, and failed calls (unknown channel, invalid identifier) are never billed. The YouTube Channel API page lets you look up a channel and its latest five videos without an account, and the API reference documents every field. AI assistants can do the same through the MCP tool get_channel_info.

Frequently asked questions

How do I get a YouTube channel's name with an API?

Call GET /v1/channels/{channel} with the channel's @handle or UC… ID and read name from the JSON. With the YouTube Data API it is snippet.title from channels.list with part=snippet.

Can I get the exact subscriber count?

No. YouTube rounds public subscriber counts to three significant figures, and every API, the official one included, returns the rounded number. When a channel hides its count, our subscriber_count is null and the Data API sets hiddenSubscriberCount.

Does the API return a channel's total views?

Not ours: our channel response has subscribers and the number of videos, not lifetime views. The YouTube Data API returns statistics.viewCount; for the views of individual videos, use the channel's video list.

Can I get the details of many channels at once?

Each FetchTranscript call returns one channel, at 1 credit, with a rate limit of 500 requests per minute. The Data API's channels.list accepts up to 50 channel IDs in one request for 1 unit.

Is video_count the number of long videos or everything?

It is the number the channel page shows, which counts all public uploads, Shorts included. It can be null when YouTube does not show it.

Do I need a Google API key?

Not for FetchTranscript: you only need its API key, from a free account. The YouTube Data API needs a Google Cloud project and its own key.

Try it on your own videos

100 free calls every month, no credit card. Then $1 per 1,000 calls, only for the calls that succeed.

← All articles