API Reference

Documentation

REST endpoints for YouTube channel, video, comment and community data. Built around publicly available YouTube information.

Quickstart

  1. 1
    Create an account and top up credits from the pricing page.
  2. 2
    Generate an API key on the API keys page. Copy it once. We only keep a SHA-256 hash.
  3. 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

EndpointCostCache
/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

StatusCodeMeaning
400missing_urlThe url query parameter is missing.
400invalid_urlNot a recognized YouTube URL.
401unauthorizedNo Authorization header was sent.
401invalid_api_keyThe API key was malformed, revoked, or not found.
402insufficient_creditsBalance is lower than the endpoint cost. Not charged.
404not_foundUpstream could not find the resource. Credits refunded.
429rate_limitedExceeded 60 requests per minute.
502upstream_errorBackend service failed. Credits refunded.

Response format

Successful responses always have data and meta:

{
  "data": ...,
  "meta": {
    "cost": 1,
    "remaining": 999,
    "cached": false
  }
}
  • data. The result. A number, string, or object depending on the endpoint. Numeric values are returned as JSON numbers (not strings).
  • meta.cost. Credits charged for this request.
  • meta.remaining. Credit balance after the charge.
  • meta.cached. true if served from cache. Still charged.

YouTube endpoints

GET /api/v1/youtube/channel
2 credits cache 15m

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 }
}
GET /api/v1/youtube/channel/id
1 credit cache 1h

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 }
}
GET /api/v1/youtube/channel/subscribers
1 credit cache 1m

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 }
}
GET /api/v1/youtube/video/views
1 credit cache 1m

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 }
}
GET /api/v1/youtube/video/likes
1 credit cache 1m

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 }
}
GET /api/v1/youtube/video/comments
1 credit cache 5m

Video comment count

Returns the comment 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/comments?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVIDEO_ID"

Example response

{
  "data": 2438587,
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}
GET /api/v1/youtube/comment/likes
1 credit cache 5m

Comment like count

Returns the like count for a top level comment, using the &lc= URL fragment.

Parameters

url required
A valid YouTube URL.

Example request

curl -H "Authorization: Bearer $TUBESTAT_KEY" \
  "https://tubestat.co/api/v1/youtube/comment/likes?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVIDEO_ID%26lc%3DCOMMENT_ID"

Example response

{
  "data": 142,
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}
GET /api/v1/youtube/comment/reply-likes
1 credit cache 5m

Comment reply like count

Returns the like count for a reply to a comment.

Parameters

url required
A valid YouTube URL.

Example request

curl -H "Authorization: Bearer $TUBESTAT_KEY" \
  "https://tubestat.co/api/v1/youtube/comment/reply-likes?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVIDEO_ID%26lc%3DCOMMENT_ID.REPLY_ID"

Example response

{
  "data": 7,
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}
GET /api/v1/youtube/community/likes
1 credit cache 5m

Community post like count

Returns the like count for a community post.

Parameters

url required
A valid YouTube URL.

Example request

curl -H "Authorization: Bearer $TUBESTAT_KEY" \
  "https://tubestat.co/api/v1/youtube/community/likes?url=https%3A%2F%2Fwww.youtube.com%2Fpost%2FPOST_ID"

Example response

{
  "data": 8,
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}
GET /api/v1/youtube/community/comment-likes
1 credit cache 5m

Community comment like count

Returns the like count for a comment on a community post.

Parameters

url required
A valid YouTube URL.

Example request

curl -H "Authorization: Bearer $TUBESTAT_KEY" \
  "https://tubestat.co/api/v1/youtube/community/comment-likes?url=https%3A%2F%2Fwww.youtube.com%2Fpost%2FPOST_ID%3Flc%3DCOMMENT_ID"

Example response

{
  "data": 2,
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}
GET /api/v1/youtube/community/poll-votes
1 credit cache 5m

Community poll vote count

Returns total vote count and per-choice breakdown for a community poll.

Parameters

url required
A valid YouTube URL.

Example request

curl -H "Authorization: Bearer $TUBESTAT_KEY" \
  "https://tubestat.co/api/v1/youtube/community/poll-votes?url=https%3A%2F%2Fwww.youtube.com%2Fpost%2FPOLL_POST_ID"

Example response

{
  "data": {
    "totalCount": 1819,
    "choices": [
      { "index": 1, "text": "Option A", "count": 916 },
      { "index": 2, "text": "Option B", "count": 28 },
      { "index": 3, "text": "Option C", "count": 50 },
      { "index": 4, "text": "Option D", "count": 825 }
    ]
  },
  "meta": { "cost": 1, "remaining": 998, "cached": false }
}