Twitch
游戏直播 API
- 认证方式
- OAuth
- HTTPS
- Yes
- CORS
- Unknown
- 分类
- 社交
- 文档 / URL
- https://dev.twitch.tv/docs
简介
Twitch Helix API 提供 Twitch 直播平台的直播流、频道、游戏、剪辑、用户和事件。认证是 OAuth(应用级数据用客户端凭证,用户数据用用户令牌)——没有匿名访问(实测:无令牌 → 401)。
快速开始
获取应用访问令牌(客户端凭证):
curl -X POST "https://id.twitch.tv/oauth2/token" \
-d "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials"
使用令牌(替换 CLIENT_ID 和 TOKEN):
# 直播流:
curl "https://api.twitch.tv/helix/streams?first=5" \
-H "Client-Id: YOUR_CLIENT_ID" \
-H "Authorization: Bearer YOUR_TOKEN"
热门游戏 / 用户信息:
curl "https://api.twitch.tv/helix/games/top?first=5" \
-H "Client-Id: YOUR_CLIENT_ID" -H "Authorization: Bearer YOUR_TOKEN"
curl "https://api.twitch.tv/helix/users?login=shroud" \
-H "Client-Id: YOUR_CLIENT_ID" -H "Authorization: Bearer YOUR_TOKEN"
认证方式
- 在 dev.twitch.tv/console/apps 注册应用 → Client ID + Client Secret。
- 应用访问令牌(client_credentials):覆盖应用级读取(直播流、游戏、用户)。
- 用户访问令牌(授权码):用户级数据(关注、订阅)。
- 每个请求都需要
Client-Id和Authorization: Bearer两个头。
速率限制与注意事项
- 限流:按令牌计算,应用令牌约 800 次请求/分钟——以文档为准。
- 所有 Helix 端点都需要两个头;无匿名访问(实测无令牌 401)。
- 通过响应
pagination对象里的cursor分页。 - API 返回带
data、pagination和total字段的 JSON。
常见问题
Twitch API 免费吗? 是的——在限流内 API 免费。
需要 OAuth 吗? 是的——应用访问令牌(客户端凭证)是读取的最低要求。
如何获取 client id? dev.twitch.tv/console/apps → Register Your Application。
社交 分类更多
| API | Auth | HTTPS | CORS | |
|---|---|---|---|---|
| 4chan Simple image-based bulletin board dedicated to a variety of topics | No auth | Yes | Yes | ↗ |
| Ayrshare Social media APIs to post, get analytics, and manage multiple users social media accounts | API Key | Yes | Yes | ↗ |
| aztro Daily horoscope info for yesterday, today, and tomorrow | No auth | Yes | Unknown | ↗ |
| Blogger The Blogger APIs allows client applications to view and update Blogger content | OAuth | Yes | Unknown | ↗ |
| Bluesky Decentralized social networking via the AT protocol | No auth | Yes | Yes | ↗ |