You need to answer a concrete question this week: how many videos does a channel have, or which channels dominate a topic? By the end of this article you’ll be able to programmatically compute “videos per channel” using the Youtube Data API on Zyla API Hub, with copy-pasteable requests that return real data you can aggregate by channel.
What this API gives you (and how to turn it into “videos per channel”)
The Youtube Data API on Zyla exposes endpoints to:
- Fetch videos related to a seed video (each item includes the channel ID and title).
- Fetch a video’s details (including its channel ID, title, description, and other metadata).
- Fetch the latest comments for a video (helpful for quality signals or moderation flows).
“Videos per channel” can be computed by grouping returned videos by snippet.channelId and counting. Two common flows that ship fast without extra discovery endpoints:
- Seed-based topic coverage: start from a known video, call Similar Videos, then count how many related videos come from each channel.
- Known list tally: if you already have a list of video IDs (e.g., from your DB, CSV, or campaign), call Video Details for each, read
snippet.channelId, and aggregate counts per channel.
This article shows both flows with precise endpoints and fields so you can build the aggregate confidently.
Getting started on Zyla API Hub
Open the API page for Youtube Data API on Zyla. Click Subscribe or Start 7-day trial, and you’ll get a single API key that works with this API and others across the hub. Zyla is a marketplace of more than 10,000 public APIs with one account, one key, and a subscription + quota model (not pay-per-call). There’s no Free Plan; for this API you can start with a 7-day trial directly on the listing page.
- API listing: Start 7-day trial on Youtube Data API
- Browse the marketplace: https://zylalabs.com
Authentication: send your key in the header as Authorization: Bearer YOUR_API_KEY. All examples below use that header.
Endpoint you’ll use to count videos per channel
1) Similar Videos
Receive a list of related videos for a given video ID. Each item includes snippet.channelId and id.videoId, which are exactly what you need to compute per-channel counts within the related set.
- Method: GET
- URL: https://zylalabs.com/api/14/youtube-data-api/56/similar-videos
- Required params:
relatedToVideoId(string): e.g., 7ghhRHRP6t4part(string): id,snippettype(string): video
- Optional params:
maxResults(string): up to 50
Copy-paste cURL (official sample):
curl -s -X GET "https://zylalabs.com/api/14/youtube-data-api/56/similar-videos?relatedToVideoId=7ghhRHRP6t4&part=id%2Csnippet&type=video&maxResults=50" \
-H "Authorization: Bearer YOUR_API_KEY"
Official JSON example (truncated in the listing; keep the shown fields):
{"kind":"youtube#searchListResponse","nextPageToken":"CDIQAA","pageInfo":{"totalResults":108,"resultsPerPage":50},"items":[{"kind":"youtube#searchResult","id":{"kind":"youtube#video","videoId":"mj0XInqZMHY"},"snippet":{"publishedAt":"2019-06-27T14:44:32Z","channelId":"UC0C-w0YjGpqDXGB8IHb662A","title":"Ed Sheeran - Beautiful People (feat. Khalid) [Official Music Video]","description":"The official music video for Ed Sheeran - Beautiful People (feat. @khalid)\nSubtract, the new album, out 05.05.2023. Pre-order: https://es.lnk.to/subtract\n \nTaken from No.6 Collaborations Project released in 2019, which featured the hit singles 'I Don't Care', 'Cross Me', 'Beautiful People', 'Blow', 'Best Part of Me', 'Antisocial', 'South of the Border' &'Take Me Back To London'. \n \nSubscribe to the Ed Sheeran channel for all the best and latest official music videos, behind the scenes and live performances. \nhttp://bit.ly/SubscribeToEdSheeran \n \nSee more official videos from Ed Sheeran here: \nhttps://www.youtube.com/watch?v=ryJgDL9jzKk&list=PLjp0AEEJ0-fGKG_3skl0e1FQlJfnx-TJz \n\nListen to more from the No. 6 Collaborations Project here : \nhttps://www.youtube.com/playlist?list=PLjp0AEEJ0-fHZDWhxhKo0wG08bMUcRy3l\n \nFollow Ed Sheeran on: \nInstagram: http://instagram.com/teddysphotos\nTikTok: https://www.tiktok.com/@edsheeran\nFacebook: http://www.facebook.com/EdSheeranMusic\nTwitter: http://twitter.com/edsheeran\nDiscord: http://discord.gg/edsheeran\nOfficial Website: http://edsheeran.com \n\nAbout Ed Sheeran: \nEd Sheeran may be the quintessential pop star of the 2010s: an internationally acclaimed, multi-award winning singer/songwriter who seems to acknowledge no boundaries between styles or eras with elements of folk, hip-hop, pop, dance, soul, and rock woven throughout his music. \n\nHis incredible catalogue includes the studio albums ‘+’ (plus), ‘x’ (multiply) and ‘÷’ (divide) which spawned hit singles such as ‘The A team’ , ’Lego House’, ‘Sing', ‘Thinking Out Loud’, ‘Photograph’, ‘Shape Of You’, ‘Castle on The Hill’ and ‘Perfect’. \n \nIn 2019, Ed Sheeran released the genre-spanning ‘No.6 Collaborations Project’ which featured a wide-range of artists including ‘Justin Bieber’, ‘Camilla’ Cabello’, ‘Travis Scott’, ‘Eminem’, ‘Cardi B, ‘Paulo Londra’, ‘Bruno Mars’ and ‘Stormzy’ amongst many others, producing hits such as ‘I Don’t Care’, ‘Beautiful People’, ‘South of The Border’ and ‘Take Me Back To London’. \n \n#EdSheeran #Khalid #BeautifulPeople","thumbnails":{"…
What you use from this payload:
items[].id.videoId: the unique video ID.items[].snippet.channelId: the channel that published the video.pageInfo.resultsPerPageandnextPageToken: useful for understanding result size and presence of more results. If you need more pages, check the API page for pagination usage.snippet.publishedAt: timestamps are ISO 8601 with Z (UTC), which is straightforward for sorting and windowing.
2) Video Details
Returns details for a given video ID. Use this to resolve a video’s channel and metadata when you already have a list of video IDs to tally.
- Method: GET
- URL: https://zylalabs.com/api/14/youtube-data-api/62/video-details
- Required params:
id(string): a video ID (e.g., 7ghhRHRP6t4)
cURL:
From the example response, you’ll use items[].snippet.channelId alongside the video id.
3) Video Comments
Fetch recent comments for a given video. While not required to compute per-channel counts, this endpoint can help you prioritize channels by engagement or moderate content related to high-volume channels you surface.
- Method: GET
- URL: https://zylalabs.com/api/14/youtube-data-api/61/video-comments
- Required params:
part(string): snippetvideoId(string): e.g., 7ghhRHRP6t4maxResults(string): e.g., 100
cURL:
Compute “videos per channel” with a single request
When you don’t have a channel discovery endpoint, the fastest path is to start from a known video that represents your topic and count how many related videos come from each channel. This is often sufficient for:
- Finding which channels dominate a topic cluster.
- Building suggested “top channels” for a recommendations sidebar.
- Pre-filtering channels to contact for a partnership or to include in a curated feed.
Python example: count channels from Similar Videos
This script calls Similar Videos, groups by snippet.channelId, and returns a sorted list of channels by count. It uses the exact endpoint and params from the hub listing.
import os
import requests
from collections import Counter
API_KEY = os.environ.get("ZYLALABS_API_KEY", "YOUR_API_KEY")
url = "https://zylalabs.com/api/14/youtube-data-api/56/similar-videos"
params = {
"relatedToVideoId": "7ghhRHRP6t4",
"part": "id,snippet",
"type": "video",
"maxResults": "50"
}
headers = {"Authorization": f"Bearer {API_KEY}"}
resp = requests.get(url, headers=headers, params=params, timeout=30)
resp.raise_for_status()
data = resp.json()
# Aggregate videos per channelId
channel_counts = Counter()
videos_by_channel = {}
for item in data.get("items", []):
snippet = item.get("snippet", {})
channel_id = snippet.get("channelId")
video_id = item.get("id", {}).get("videoId")
title = snippet.get("title")
if channel_id and video_id:
channel_counts[channel_id] += 1
videos_by_channel.setdefault(channel_id, []).append({
"videoId": video_id,
"title": title
})
# Print top channels by count
for channel_id, count in channel_counts.most_common():
print(f"{channel_id}: {count} videos")
# Optionally list the video IDs to build links or a playlist
for v in videos_by_channel[channel_id]:
print(f" - {v['videoId']} :: {v.get('title','')}")
# Note: data may include 'nextPageToken' if more results are available.
# Consult the API page for fetching additional pages when needed.
Implementation notes that save time:
- Counts reflect the slice you fetch. If you want broader coverage, choose seed videos that represent your topic well and repeat the aggregation across multiple seeds.
publishedAtis ISO 8601 in UTC. You can filter to a time window before counting to focus on recent activity.- If a
nextPageTokenis present, there are more results available. Check the API page for the exact pagination usage to continue fetching. - Cache the JSON for each request keyed by params. For fast iteration, persist the raw response and re-run aggregation locally without re-fetching.
Alternative: tally a known set of video IDs (using Video Details)
If you already have a list of video IDs (e.g., uploads you track, campaign links, or a CSV), call Video Details for each to resolve its snippet.channelId and then count by channel. This produces an exact per-channel breakdown over your input set.
High-level steps:
- Iterate video IDs in your list.
- For each, GET
https://zylalabs.com/api/14/youtube-data-api/62/video-details?id=VIDEO_ID. - Read
items[0].snippet.channelIdand increment a counter.
Tip: Store a small local map of {videoId: channelId} to avoid re-calling the API for the same item during development.
Use engagement signals when ranking channels
Once you have counts per channel, you might want to rank beyond pure volume. A lightweight approach is to pull recent comments for a representative video from top channels and use likeCount, publishedAt, or text length to generate simple heuristics (e.g., “channels with recent high-like comments get a slight boost”). The Video Comments endpoint returns:
textOriginalandauthorDisplayName: for simple NLP and attributions.likeCount,publishedAt: for quick scoring and recency windows.
Calling from AI agents via MCP
If you orchestrate from an IDE agent (Claude Code, Cursor, Windsurf or any MCP-compatible client), use Zyla’s MCP endpoint. Provide your API key and let the agent invoke the hub endpoints directly from your editor. See the MCP entry point here: MCP. The same Authorization header applies behind the scenes, and each tool call maps to the corresponding Zyla API endpoint. If you need an account key, create one on Zyla API Hub and then point your agent to the MCP endpoint with your key.
Operational tips
- Auth: Always include
Authorization: Bearer YOUR_API_KEY. - Quotas and billing: Zyla uses subscription + quota (not pay-per-call). For this API, you can start a 7-day trial from the listing. Check the API page for current access options and pricing.
- Timestamps: Fields like
publishedAtare ISO 8601 UTC (Z). Normalize to UTC in your datastore. - Pagination: If the response includes
nextPageToken, more results exist. Refer to the API page to continue pagination as needed; persist your last token when building batch jobs. - Deduplication: Use
id.videoIdas the canonical key for deduping when aggregating across multiple seed videos. - Partial responses: Only rely on fields shown in the examples or specified in the API docs. Handle absent fields defensively in your code.
End-to-end example workflow
Goal: produce a leaderboard of channels for a given topic without a dedicated channel-listing endpoint.
- Pick 3–5 representative seed videos for the topic (e.g., one per subtopic).
- For each seed, call Similar Videos with
part=id,snippetandtype=video. KeepmaxResultsat 50 for breadth. Cache raw JSON files. - Combine all items, group by
snippet.channelId, and count. - Optionally, for the top N channels, sample 1–2 videos and call Video Comments to collect quick engagement hints.
- Render: channel ID and video count; optionally list a few representative videos per channel.
Why this works for “videos per channel” quickly
You’re working with directly returned channel IDs from each video’s snippet. Counting them is straightforward and avoids multi-step discovery. If your product truly needs the total public uploads per channel (i.e., full catalog size), use broader seed coverage and repeat the Similar Videos fetch across several known anchors; then persist and dedupe over time. For many use cases (curation, recommendations, outreach), relative volume within a topical cluster is what you want, and this approach delivers it with one request and a small aggregation.
Reference: endpoint details in one place
Similar Videos
- GET https://zylalabs.com/api/14/youtube-data-api/56/similar-videos
- Params:
- relatedToVideoId (required): 7ghhRHRP6t4
- part (required): id,snippet
- type (required): video
- maxResults (optional): 50
Video Details
- GET https://zylalabs.com/api/14/youtube-data-api/62/video-details
- Params:
- id (required): 7ghhRHRP6t4
Video Comments
- GET https://zylalabs.com/api/14/youtube-data-api/61/video-comments
- Params:
- part (required): snippet
- videoId (required): 7ghhRHRP6t4
- maxResults (required): 100
FAQ
How do I authenticate?
Send your key in the header: Authorization: Bearer YOUR_API_KEY.
Can I fetch more than 50 related videos?
The response shows nextPageToken when more results exist. Check the API page for how to continue pagination beyond the first page.
Which fields identify the channel and video?
Use items[].id.videoId for video identity and items[].snippet.channelId for the channel.
Is there a free plan?
No Free Plan. You can start a 7-day trial from the API listing. Check the API page for current access options and pricing.
Can I call this from an AI agent?
Yes. Use Zyla’s MCP endpoint with your API key to let MCP-compatible clients call the same endpoints.
Ready to ship your “videos per channel” aggregation? Start your 7-day trial and get your API key on the listing: Youtube Data API on Zyla. One key works across the hub, so you can expand your integration as you go.
Official API response
{"kind":"youtube#searchListResponse","nextPageToken":"CDIQAA","pageInfo":{"totalResults":108,"resultsPerPage":50},"items":[{"kind":"youtube#searchResult","id":{"kind":"youtube#video","videoId":"mj0XInqZMHY"},"snippet":{"publishedAt":"2019-06-27T14:44:32Z","channelId":"UC0C-w0YjGpqDXGB8IHb662A","title":"Ed Sheeran - Beautiful People (feat. Khalid) [Official Music Video]","description":"The official music video for Ed Sheeran - Beautiful People (feat. @khalid)\nSubtract, the new album, out 05.05.2023. Pre-order: https://es.lnk.to/subtract\n \nTaken from No.6 Collaborations Project released in 2019, which featured the hit singles 'I Don't Care', 'Cross Me', 'Beautiful People', 'Blow', 'Best Part of Me', 'Antisocial', 'South of the Border' &'Take Me Back To London'. \n \nSubscribe to the Ed Sheeran channel for all the best and latest official music videos, behind the scenes and live performances. \nhttp://bit.ly/SubscribeToEdSheeran \n \nSee more official videos from Ed Sheeran here: \nhttps://www.youtube.com/watch?v=ryJgDL9jzKk&list=PLjp0AEEJ0-fGKG_3skl0e1FQlJfnx-TJz \n\nListen to more from the No. 6 Collaborations Project here : \nhttps://www.youtube.com/playlist?list=PLjp0AEEJ0-fHZDWhxhKo0wG08bMUcRy3l\n \nFollow Ed Sheeran on: \nInstagram: http://instagram.com/teddysphotos\nTikTok: https://www.tiktok.com/@edsheeran\nFacebook: http://www.facebook.com/EdSheeranMusic\nTwitter: http://twitter.com/edsheeran\nDiscord: http://discord.gg/edsheeran\nOfficial Website: http://edsheeran.com \n\nAbout Ed Sheeran: \nEd Sheeran may be the quintessential pop star of the 2010s: an internationally acclaimed, multi-award winning singer/songwriter who seems to acknowledge no boundaries between styles or eras with elements of folk, hip-hop, pop, dance, soul, and rock woven throughout his music. \n\nHis incredible catalogue includes the studio albums ‘+’ (plus), ‘x’ (multiply) and ‘÷’ (divide) which spawned hit singles such as ‘The A team’ , ’Lego House’, ‘Sing', ‘Thinking Out Loud’, ‘Photograph’, ‘Shape Of You’, ‘Castle on The Hill’ and ‘Perfect’. \n \nIn 2019, Ed Sheeran released the genre-spanning ‘No.6 Collaborations Project’ which featured a wide-range of artists including ‘Justin Bieber’, ‘Camilla’ Cabello’, ‘Travis Scott’, ‘Eminem’, ‘Cardi B, ‘Paulo Londra’, ‘Bruno Mars’ and ‘Stormzy’ amongst many others, producing hits such as ‘I Don’t Care’, ‘Beautiful People’, ‘South of The Border’ and ‘Take Me Back To London’. \n \n#EdSheeran #Khalid #BeautifulPeople","thumbnails":{"…