Skip to main content

Streams - Get

Description

Gets information about active streams. Streams are returned sorted by number of current viewers, in descending order. Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams.

The response has a JSON payload with a data field containing an array of stream information elements and a pagination field containing information required to query for more streams.

Method Definition

@RequestLine("GET /streams?after={after}&before={before}&first={first}&game_id={game_id}&language={language}&user_id={user_id}&user_login={user_login}")
@Headers("Authorization: Bearer {token}")
HystrixCommand<StreamList> getStreams(
@Param("token") String authToken,
@Param("after") String after,
@Param("before") String before,
@Param("first") Integer limit,
@Param("game_id") List<String> gameIds,
@Param("language") List<String> language,
@Param("user_id") List<String> userIds,
@Param("user_login") List<String> userLogins
);

Required Parameters

NameTypeDescription
authTokenstringUser or App Access Token

As with all Helix endpoints, twitch requires an oauth token. If when using TwitchHelixBuilder, a valid client id/secret pair or defaultAuthToken was specified, then this can be set to null.

Optional Parameters

NameTypeDescription
afterstringCursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
beforestringCursor for backward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
limitintegerMaximum number of objects to return. Maximum: 100. Default: 20.
game_idstringReturns streams broadcasting a specified game ID. You can specify up to 100 IDs.
languagestringStream language. You can specify up to 100 languages.
user_idstringReturns streams broadcast by one or more specified user IDs. You can specify up to 100 IDs.
user_loginstringReturns streams broadcast by one or more specified user login names. You can specify up to 100 names.

Code-Snippets

get the top 5 streams

StreamList resultList = twitchClient.getHelix().getStreams(null, null, null, 5, null, null, null, null).execute();
resultList.getStreams().forEach(stream -> {
System.out.println("ID: " + stream.getId() + " - Title: " + stream.getTitle());
});