GET /v1/youtube/stats
YouTube channel stats API: average views and top videos by handle
Returns figures over the videos we have stored for one channel: how many (tracked_videos), total, average, median and max views, average duration, total likes and comments, average engagement rate, and the top 5 videos by views. Send q as an @handle or UC… channel id. The numbers cover the stored videos, not the channel's full history, and a channel we never crawled is a 404.
- Price
- $0.0010 per call
- Batch
- Yes, through /v1/batch
- Failed calls
- Not charged
Example request
curl 'https://api.virev.ai/v1/youtube/stats?q=mkbhd' \
-H "Authorization: Bearer $VIREV_API_KEY"import os
import requests
response = requests.request(
"GET",
"https://api.virev.ai/v1/youtube/stats",
params={
"q": "mkbhd",
},
headers={"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"},
timeout=60,
)
response.raise_for_status()
print(response.json())Parameters
| Name | In | Type | Description |
|---|---|---|---|
q required | query | string | YouTube @handle (case-sensitive), UC… channel id, or a youtube.com/@handle / /channel/UC… URL. |
Example response
The example response of the API reference.
{
"data": {
"username": "mkbhd",
"followers": 21100000,
"tracked_videos": 30,
"total_views": 106800000,
"avg_views": 3560000,
"max_views": 7300000,
"median_views": 3700000,
"avg_length_seconds": null,
"top_videos": [
{
"youtube_video_id": "kBX5WH9b4M4",
"title": "Macbook Neo Impressions: Reincarnated!",
"views": 7300000,
"length_seconds": null,
"thumbnail_url": null
},
{
"youtube_video_id": "eFUB_jL_XcM",
"title": "So This is Peak Foldable",
"views": 6400000,
"length_seconds": null,
"thumbnail_url": null
}
]
},
"meta": {
"cost": "$0.0010",
"balance": "$0.7922",
"request_id": "req_03e2cbfb2c088a8eebed5f7187097c5e"
}
}How it works
Performance analytics over a channel's tracked videos: tracked count, total/avg/max/median views, average duration, total likes/comments, average engagement rate, and the top 5 videos by views. Numbers describe the tracked corpus (tracked_videos), not the channel's full history; legacy sparse fields remain null.
Errors
| Status | When |
|---|---|
400 | The request parameters are invalid. |
401 | Missing, malformed, or revoked API key. |
402 | Balance is too low for this request. |
404 | Channel not in the tracked corpus. |
429 | Over the per-minute limit. The limit belongs to your organization and all its API keys share it: 100 requests per minute unless an increase was granted. Wait for the Retry-After seconds, then retry. On a live read, code rate_limited means the platform itself rate-limited this read; retry after the Retry-After seconds. You are not charged. |
502 | The upstream fetch failed. You are not charged. |
503 | Billing could not be confirmed, so no upstream data was returned. |
504 | The upstream request timed out. You are not charged. |