API Reference
Documentation
REST endpoints for YouTube channel, video, comment and community data. Built around publicly available YouTube information.
Quickstart
-
1
-
2
Generate an API key on the
API keys page.
Copy it once. We only keep a SHA-256 hash.
-
3
Make your first request:
curl -H "Authorization: Bearer ts_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"https://tubestat.co/api/v1/youtube/channel/id?url=https://www.youtube.com/@channelname"
Response:
{
"data": "UCxxxxxxxxxxxxxxxxxxxxxx",
"meta": {
"cost": 1,
"remaining": 999,
"cached": false
}
}
Authentication
Every request must include an Authorization header with a Bearer API key:
Authorization: Bearer ts_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
API keys start with ts_live_ and are 40 characters long. We only store a SHA-256 hash on our side. If you lose a key, generate a new one and revoke the old one from the API keys page.
Keep keys secret. Do not commit them to public repositories, and do not ship them in browser side JavaScript.
Credits and pricing
Requests are paid in credits. Most endpoints cost 1 credit. /api/v1/youtube/channel (full statistics) costs 2 credits. Credits do not expire.
Refunds. If a request fails because of an error on our side (5xx), or the upstream returns "not found", credits are not charged.
Cost by endpoint
| Endpoint | Cost | Cache |
/api/v1/youtube/channel |
2 |
15m |
/api/v1/youtube/channel/id |
1 |
1h |
/api/v1/youtube/channel/subscribers |
1 |
1m |
/api/v1/youtube/video/views |
1 |
1m |
/api/v1/youtube/video/likes |
1 |
1m |
/api/v1/youtube/video/comments |
1 |
5m |
/api/v1/youtube/comment/likes |
1 |
5m |
/api/v1/youtube/comment/reply-likes |
1 |
5m |
/api/v1/youtube/community/likes |
1 |
5m |
/api/v1/youtube/community/comment-likes |
1 |
5m |
/api/v1/youtube/community/poll-votes |
1 |
5m |
Cached responses still cost credits. You are paying for the data, not the bandwidth.
Rate limits
Each API key is limited to 60 requests per minute. Exceeding this returns HTTP 429 with a Retry-After header.
Need higher throughput? Email [email protected].
Errors
All errors return a consistent JSON body:
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits. Balance: 0, required: 1.",
"details": { "balance": 0, "required": 1 }
}
}
Status codes
| Status | Code | Meaning |
| 400 | missing_url | The url query parameter is missing. |
| 400 | invalid_url | Not a recognized YouTube URL. |
| 401 | unauthorized | No Authorization header was sent. |
| 401 | invalid_api_key | The API key was malformed, revoked, or not found. |
| 402 | insufficient_credits | Balance is lower than the endpoint cost. Not charged. |
| 404 | not_found | Upstream could not find the resource. Credits refunded. |
| 429 | rate_limited | Exceeded 60 requests per minute. |
| 502 | upstream_error | Backend service failed. Credits refunded. |
YouTube endpoints
Channel statistics
Returns subscriber count, video count and total view count for a channel.
Parameters
url required
- A valid YouTube URL.
Example request
curl -H "Authorization: Bearer $TUBESTAT_KEY" \
"https://tubestat.co/api/v1/youtube/channel?url=https%3A%2F%2Fwww.youtube.com%2F%40channelname"
Example response
{
"data": {
"subscriberCount": 366000,
"videoCount": 2146,
"viewCount": 154415218
},
"meta": { "cost": 2, "remaining": 998, "cached": false }
}
Channel ID lookup
Resolves any channel related YouTube URL to its canonical channel ID. Accepts /channel/, /c/, /@handle, /watch, /shorts, /live, /post and shortened youtu.be URLs.
Parameters
url required
- A valid YouTube URL.
Example request
curl -H "Authorization: Bearer $TUBESTAT_KEY" \
"https://tubestat.co/api/v1/youtube/channel/id?url=https%3A%2F%2Fwww.youtube.com%2F%40channelname"
Example response
{
"data": "UCxxxxxxxxxxxxxxxxxxxxxx",
"meta": { "cost": 1, "remaining": 998, "cached": false }
}
Subscriber count
Returns just the subscriber count. Cheaper and faster for high frequency polling.
Parameters
url required
- A valid YouTube URL.
Example request
curl -H "Authorization: Bearer $TUBESTAT_KEY" \
"https://tubestat.co/api/v1/youtube/channel/subscribers?url=https%3A%2F%2Fwww.youtube.com%2F%40channelname"
Example response
{
"data": 366000,
"meta": { "cost": 1, "remaining": 998, "cached": false }
}
Video view count
Returns the view count for a single video.
Parameters
url required
- A valid YouTube URL.
Example request
curl -H "Authorization: Bearer $TUBESTAT_KEY" \
"https://tubestat.co/api/v1/youtube/video/views?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVIDEO_ID"
Example response
{
"data": 1775775169,
"meta": { "cost": 1, "remaining": 998, "cached": false }
}
Video like count
Returns the like count for a single video.
Parameters
url required
- A valid YouTube URL.
Example request
curl -H "Authorization: Bearer $TUBESTAT_KEY" \
"https://tubestat.co/api/v1/youtube/video/likes?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVIDEO_ID"
Example response
{
"data": 19115698,
"meta": { "cost": 1, "remaining": 998, "cached": false }
}