Twitch API: Streams and Channels as JSON
To get Twitch data as JSON, call GET /v1/twitch/games: the recorded call returned the top categories with viewersCount and broadcastersCount for each, such as Counter-Strike at 210,348 viewers across 1,362 broadcasters, for 1 credit. GET /v1/twitch/streams lists live streams with viewersCount, language and game, and sixteen more endpoints cover channels, clips, videos, search and tags. All eighteen are restricted endpoints. This guide shows the requests, parameters, recorded responses, a Python category tracker and the cost.
What does the Twitch API on Perceptlayer cover?
The Twitch API on Perceptlayer has 18 endpoints that return public Twitch data as JSON: categories and their live viewership, live streams, channels, clips, videos, schedules, teams, tags and search. Every endpoint is a GET request and costs 1 credit per successful call. For market-level work, the useful ones are games, streams, game, search-games and tags.
| Group | Endpoints | Required | Optional |
|---|---|---|---|
| Categories | games, game, search-games, tags |
id on game; query on search-games and tags |
first, after; limit on tags |
| Live streams | streams, search-streams |
query on search-streams |
first, after, sort |
| Channels | channels, channel, schedule, team |
login, channel or name |
logins[], first, week_of |
| Clips and videos | clips, clip, game-clips, videos, video |
login, slug or id |
first, after, sort, period, page |
| Search | search, search-users, suggestions |
query |
first, after, include_offline and per-type cursors |
These are Perceptlayer endpoints, collected from publicly available sources and returned as found at the time of the call. This guide makes no claims about Twitch's own developer API, plans or terms; compare them yourself. The Twitch API page has a playground for every endpoint.
Which terms apply to the Twitch endpoints?
All 18 Twitch endpoints are restricted. They work after you accept the restricted-endpoint terms in your dashboard; until then, a call returns restricted_endpoint (403) and costs nothing. The terms don't permit collecting personal data without a lawful basis, or using data from these endpoints to contact people. That rules out profiling streamers, following one person's activity and building contact lists.
Keep the work aggregate. Count viewers and broadcasters per game, compare languages, chart a category's live volume through the day, or check an organisation's public channel. Several endpoints take a channel login; this guide uses them only for brand channels and drops the streamer fields from stream data. The excerpts below leave out every streamer's login, display name and profile image.
How do you get live viewership by category?
Send GET /v1/twitch/games with no parameters, or with first and after. Each item in data.games carries an id, name, displayName, viewersCount, broadcastersCount and boxArtURL, and data.page_info has has_next_page and end_cursor. This is the recorded request and a trimmed response:
curl "https://api.perceptlayer.com/v1/twitch/games" \
-H "X-API-Key: $API_KEY"
{
"success": true,
"data": {
"games": [
{
"id": "32399",
"name": "Counter-Strike",
"displayName": "Counter-Strike",
"viewersCount": 210348,
"broadcastersCount": 1362,
…
},
{
"id": "509658",
"name": "Just Chatting",
"displayName": "Just Chatting",
"viewersCount": 180123,
"broadcastersCount": 3480,
…
}
],
"page_info": {
"has_next_page": true,
"end_cursor": "eyJzIjoyMCwiZCI6ZmFsc2UsInQiOnRydWV9"
}
},
"message": "Games retrieved.",
"meta": {
"duration_ms": 487.53,
"scraped_at": "2026-11-12T13:13:15+00:00"
}
}
The two counts give you a figure the response doesn't: viewers per broadcaster. In the recording, Counter-Strike had 210,348 ÷ 1,362 ≈ 154 viewers per broadcaster, and Just Chatting had 180,123 ÷ 3,480 ≈ 52. One category draws a larger audience to fewer channels; the other spreads viewers across more. Store meta.scraped_at with every row, since live counts change minute to minute.
Which parameters do the category endpoints take?
The category endpoints take a handful of parameters. Types and lengths come from the API reference; defaults and page sizes aren't documented, so test first in the playground before you rely on a value.
| Endpoint | Parameter | Type | Required | Documented constraint |
|---|---|---|---|---|
games |
first |
integer | no | None documented |
games |
after |
string | no | Up to 500 characters |
game |
id |
string | yes | Up to 100 characters |
game |
first |
integer | no | None documented |
search-games |
query |
string | yes | Up to 200 characters |
tags |
query |
string | yes | Up to 200 characters |
tags |
limit |
integer | no | None documented |
The games response has page_info.end_cursor, and the endpoint takes an after string. The recordings don't show a cursor passed back, so confirm in the playground that after accepts end_cursor before you page through categories. A game's id from games has the same shape as the id parameter on game, but we have no recorded game response to show.
What does the streams endpoint return?
GET /v1/twitch/streams returns live streams in data.streams, with the same page_info block. Each stream has an id, title, viewersCount, startedAt, language, type, a game object with id and name, and a broadcaster object. For aggregate work you need viewersCount, language and game; drop broadcaster before you store anything. Trimmed, with titles and broadcasters removed:
curl "https://api.perceptlayer.com/v1/twitch/streams" \
-H "X-API-Key: $API_KEY"
{
"success": true,
"data": {
"streams": [
{
"id": "316713966962",
…
"viewersCount": 34985,
"startedAt": "2026-11-12T10:27:35Z",
"language": "JA",
"type": "live",
…
"game": {
"id": "225471887",
"name": "BLEACH Rebirth of Souls"
}
},
{
"id": "317213325397",
…
"viewersCount": 34446,
"startedAt": "2026-11-12T01:46:26Z",
"language": "RU",
"type": "live",
…
"game": {
"id": "32399",
"name": "Counter-Strike"
}
}
],
"page_info": {
"has_next_page": true,
…
}
},
…
}
The game.id on the second stream, 32399, is the same value as Counter-Strike's id in the games recording, so you can join streams to categories on it. sort takes VIEWER_COUNT or RECENT; the recorded call sent none. Grouping a page of streams by language and game.name and summing viewersCount shows how a category's audience splits by language.
How do you read a brand channel?
GET /v1/twitch/channels takes a list of channel logins in logins[] and returns one record per channel, with requested and found counts. The recorded call asked for two organisations' channels. Each record has id, login, displayName, description, createdAt, primaryColorHex, followers.totalCount and lastBroadcast.startedAt. Use it for public brand, publisher or event channels, not individuals.
curl "https://api.perceptlayer.com/v1/twitch/channels?logins[]=nasa&logins[]=riotgames" \
-H "X-API-Key: $API_KEY"
{
"success": true,
"data": {
"channels": [
{
"id": "151920918",
…
"createdAt": "2017-03-30T22:42:23.044894Z",
…
"followers": {
"totalCount": 1911013
},
"lastBroadcast": {
"startedAt": "2026-11-05T21:08:37.823716Z"
}
},
…
],
"requested": 2,
"found": 2
},
"message": "Channels retrieved.",
…
}
Compare found with requested to spot logins that returned nothing. logins[] repeats in the query string, one value per channel, and each value can be up to 100 characters.
How do you track category viewership in Python?
A category tracker calls games on a schedule and appends one row per category: the scrape time, the game id, name, viewersCount and broadcastersCount. Run hourly, it gives you a daily curve of each category's live audience and channel count. The script uses requests and csv and reads only fields in the recorded response.
import csv
import os
import time
import requests
API_KEY = os.environ["API_KEY"]
URL = "https://api.perceptlayer.com/v1/twitch/games"
def get_games(attempts=3):
for _ in range(attempts):
r = requests.get(URL, headers={"X-API-Key": API_KEY}, timeout=60)
if r.status_code in (429, 503):
time.sleep(int(r.headers.get("Retry-After", "5")))
continue
r.raise_for_status()
return r.json()
raise RuntimeError("gave up on games")
body = get_games()
scraped_at = (body.get("meta") or {}).get("scraped_at")
with open("twitch-categories.csv", "a", newline="") as f:
out = csv.writer(f)
for game in body["data"].get("games", []):
viewers = game.get("viewersCount") or 0
broadcasters = game.get("broadcastersCount") or 0
per_channel = round(viewers / broadcasters, 1) if broadcasters else None
out.writerow([
scraped_at, game.get("id"), game.get("name"),
viewers, broadcasters, per_channel,
])
Schedule it with cron or any job runner. To add a language split, call streams in the same run and sum viewersCount by language and game.id, writing only those totals.
What should the job do with errors?
Every error returns an HTTP status and a JSON body with code, message and request_id, and costs nothing. restricted_endpoint (403) means the terms aren't accepted yet. Retry rate_limited (429) and temporarily_unavailable (503) after the Retry-After seconds. Requests have no idempotency key, so a client timeout may hide a billed call; keep the timeout generous. The errors docs list every code.
What does Twitch data cost?
Every successful call to any of the 18 endpoints costs 1 credit, and a failed call costs nothing and returns X-Credits-Used: 0. A games or streams call returns a page of items for that 1 credit, so a snapshot schedule costs the same whatever the counts inside it. Count calls per run and runs per month.
| Plan | Arithmetic | Credits a month |
|---|---|---|
games hourly |
24 × 30 days × 1 credit | 720 |
games and streams hourly |
2 × 24 × 30 days × 1 credit | 1,440 |
games and streams every 15 minutes |
2 × 96 × 30 days × 1 credit | 5,760 |
20 brand channels daily via channels |
1 × 30 days × 1 credit | 30 |
All four fit the Starter pack's 10,000 credits. The channels row assumes the 20 logins fit in one call; the reference documents no maximum, so test it. The 100 free credits on signup cover 100 calls, about four days of hourly games snapshots. Purchased credits last 12 months. See pricing for what credits cost and the credits docs for how calls are debited.
To try it, accept the restricted-endpoint terms and run the games endpoint in its playground, then get a free API key for a scheduled job. Other platforms are on the social media APIs page, and more guides are in API guides.
APIs in this post
Frequently asked questions
Is this Twitch's official API?
No. These are Perceptlayer endpoints that return public Twitch data, collected from publicly available sources and returned as found at the time of the call. This guide makes no claims about Twitch's own developer API, its plans or its terms, so compare them yourself. All 18 endpoints are restricted and need the restricted-endpoint terms accepted first.
Do I need to accept terms to use the Twitch endpoints?
Yes. All 18 are restricted endpoints. Accept the restricted-endpoint terms in your dashboard; until then, calls return restricted_endpoint (403) and cost nothing. The terms don't permit collecting personal data without a lawful basis or using it to contact people, so keep to games, categories, languages and stream volume.
How do I get total viewers for a game?
Call GET /v1/twitch/games. Each category in the response carries viewersCount and broadcastersCount; in the recording, Counter-Strike showed 210,348 viewers across 1,362 broadcasters. For a language split, sum viewersCount by language and game.id across streams results. Each call costs 1 credit.
How do I page through Twitch results?
List responses carry page_info with has_next_page and end_cursor, and the list endpoints take an optional after string of up to 500 characters. The recordings don't show a cursor passed back, so confirm in the playground that after takes end_cursor before relying on it. Each page costs 1 credit.
How fast can I poll the Twitch endpoints?
Limits are per account, shared by all its keys, and counted per minute. A free account gets 1 request a second, 60 a minute. Paying accounts run at least 5 requests a second, 300 a minute, depending on the pack. Every response carries RateLimit-Remaining, and the rate limits docs list each pack's rate.