Fetch Live Streams
Use the Helix client with client-credential tokens to fetch live stream data. The example demonstrates typed responses, simple logging, and troubleshooting hints when authentication fails.
Get started
- Install dependencies with
npm install. -
Export
TWITCH_CLIENT_IDandTWITCH_CLIENT_SECRET(or add them to.env). -
Run
npx tsx examples/FETCH_STREAMS.tsto request the first page of live streams from the Helix API. - Review the console output for the raw API payload or any authentication troubleshooting tips.
What you can do
- Swap the
firstquery parameter to page through more results. - Add filters like
game_idoruser_loginfor targeted lookups. - Reuse the authenticated
HelixClientinstance for subsequent API calls in your app. - Hook the data into analytics, overlays, or moderation workflows.
Extend it further
- Combine with the authorization code example to act on behalf of a broadcaster.
- Cache stream responses using your preferred store to avoid rate-limit pressure.
- Trigger EventSub subscriptions for channels returned by the query.