Followed Streams
Learn to get all the active streams from the followed channels.
We'll cover the following
Get followed streams
While the streams endpoint gets us a list of all the currently active live streams, what if we only want to see streams from the channels we follow? In that case, we can use the Twitch API's followed streams endpoint. We can send a GET request to this endpoint and receive a list of all the active streams of the channels we follow. It returns a list, sorted in descending order of viewers, split over multiple pages.
The URL for this endpoint is as follows:
https://api.twitch.tv/helix/streams/followed
All calls to this endpoint need to be authorized with a user access token that has the user:read:follows
scope. The response includes a list of all the streams from the channels the user authenticated with the access token follows.
Request parameters
This endpoint takes a single required query parameter and three optional parameters. The table below gives a summary of all these parameters:
Parameter | Type | Category | Description |
| String | Required | This is the user ID for which we want to retrieve the list of followed streams. It must be of the same user who is authenticated with the access token. |
| String | Optional | This is a cursor value for forward pagination. Each response from this endpoint that has multiple pages returns a cursor value. We can provide this cursor value in the |
| String | Optional | This is a cursor value for backward pagination. Each response from this endpoint that has multiple pages returns a cursor value. We can provide this cursor value in the |
| Integer | Optional | This is the number of streams to be returned per page, with a maximum of 100 results per page. Its default value is also |
Let's make a sample request to this endpoint and view the response.
Note: If your token has expired, return to this lesson and follow the steps to generate a new one.
import fetch from "node-fetch";const endpointUrl = new URL("https://api.twitch.tv/helix/streams/followed");const headerParameters = {Authorization: "Bearer {{USER_ACCESS_TOKEN}}","Client-Id": "{{CLIENT_ID}}",};const queryParameters = new URLSearchParams({user_id: "{{USER_ID}}",});const options = {method: "GET",headers: headerParameters,};async function fetchFollowedStreams() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);} catch (error) {printError(error);}}fetchFollowedStreams();
In the code above, we perform the following:
Lines 10–12: We define the query parameters for the request using the
user_id
parameter.Lines 14–17: We set the options for the API call, specifying the HTTP request type as GET and providing the request headers.
Lines 19–27: We define a function called
fetchFollowedStreams
to make a call to the followed streams endpoint.Lines 20–24: Within a
try
block, we provide the query parameters, make a call to the endpoint, and print the response from the API.Lines 24–26: We catch any errors or exceptions within a
catch
block and print them to the console.
Line 29: We invoke the
fetchFollowedStreams
function.
The returned list will be empty if none of the channels we're following are currently live. We can try following a few live channels and rerunning the code. The response will then include the active streams of every user we follow.
Response fields
The response is a JSON object containing two top-level properties—data
and pagination
. The data
property is a list of stream objects, and the pagination
property contains a cursor value for pagination.
The table below gives an overview of the properties present in a single stream object contained within the data
array:
Property | Type | Description |
| String | This is the ID of the stream. |
| String | This is the ID of the user broadcasting the stream. |
| String | This is the login name of the user broadcasting the stream. |
| String | This is the display name of the user broadcasting the stream. |
| String | This is the ID of the game being played on the stream. |
| String | This is the name of the game being played on the stream. |
| String | This is the type of stream. Since we're retrieving ongoing streams, its value is |
| String | This is the title of the stream. |
| Integer | This is the number of viewers currently watching the stream. |
| String | This is the UTC timestamp of when the stream started. |
| String | This is an ISO-639-1 code for the stream language. |
| String | This is the URL of the stream thumbnail. We can retrieve different thumbnail sizes by replacing the |
| Array[String] | This is a list of IDs of all tags that apply to the stream. |
| Boolean | This indicates whether the stream is intended for mature audiences. |