TwitchApi

TwitchApi

new TwitchApi(config)

Twitch API

Source:
Parameters:
Name Type Description
config object

The configuration object to access the API.

Name Type Description
clientId string

The client id to be used to access the API.

clientSecret string

The secret to be used to access the API that requires login. If this is not provided, the restricted methods will thrown an error.

logger object

The logger object.

Methods

getAccessToken()

Authenticate the current user and get the access token to be used in the private calls.

Source:
Returns:

The access token.

getGames(options) → {Promise.<Array.<Object>>}

Gets a Twitch game information by game ID or name. For a query to be valid, name and/or id must be specified. This method requires no authentication.

Source:
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-games

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-games

getStreams(options) → {Promise.<Array.<Object>>}

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. This method requires no authentication.

Source:
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams

getStreamsMetadata(options) → {Promise.<Array.<Object>>}

Gets metadata information about active streams playing Overwatch or Hearthstone. Streams are 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.

Source:
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams-metadata

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-streams-metadata

getUsers(options) → {Promise.<Array.<Object>>}

Gets information about one or more specified Twitch users. Users are identified by optional user IDs and/or login name. If neither a user ID nor a login name is specified, the user is looked up by Bearer token.

Source:
To Do:
  • add optional scope
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users

getUsersFollows(options) → {Promise.<Array.<Object>>}

Gets information on follow relationships between two Twitch users. Information returned is sorted in order, most recent follow first. This can return information like "who is lirik following," "who is following lirik,” or β€œis user X following user Y.” This method requires no authentication.

Source:
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users-follows

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-users-follows

getVideos(options) → {Promise.<Array.<Object>>}

Gets video information by video ID (one or more), user ID (one only), or game ID (one only). This method requires no authentication.

Source:
Parameters:
Name Type Description
options object

The parameters to the api call. The parameter object is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos

isLive() → {bool}

Check if the stream is live.

Source:
Returns:
Type:
bool

True if the stream is live and false otherwise.

updateUser(description) → {Promise.<Array.<Object>>}

Updates the description of the authenticated user. This method requires authentication.

Source:
Parameters:
Name Type Description
description string

The description to be added to the channel.

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/api/reference#get-videos

validateAccessToken(token) → {Promise.<Array.<Object>>}

Validate the access token to make sure it is still valid.

Source:
Parameters:
Name Type Description
token string

The token to be validated

Returns:
Type:
Promise.<Array.<Object>>

The data object in the API response. The response is defined in the Twitch documentation: https://dev.twitch.tv/docs/authentication/#validating-requests