twitcheasy-twitch-bottwitch-authtwitch-auth-tmitwitch-chat-clienttwitch-eventsubtwitch-pubsub-clienttwitch-webhooks
Welcome

ApiClient

An API client for the Twitch Kraken and Helix APIs.

Overview

Constructor

new ApiClient(config)

Creates a new API client instance.

ParameterTypeDescription
configPartial<ApiConfig>

Configuration for the client instance.

Properties

badges

Type: BadgesApi

The API methods that deal with badges.

cheermoteDefaults

Type: TwitchCheermoteConfig

The default specs for cheermotes.

clientId

Type: string

The client ID of your application.

currentScopes

Type: Array<string>

Deprecated.

Use AuthProvider#currentScopes directly instead.

The scopes that are currently available using the access token.

helix

Type: HelixApiGroup

A group of Helix API methods.

kraken

Type: KrakenApiGroup

A group of Kraken API methods.

tokenType

Type: AuthProviderTokenType

The type of token used by the client.

unsupported

Type: UnsupportedApi

Various API methods that are not officially supported by Twitch.

Methods

callApi<T>(options, clientId, accessToken)

staticasync
Deprecated.

Use callTwitchApi from twitch-api-call instead.

Makes a call to the Twitch API using given credentials.

ParameterTypeDescription
optionsTwitchApiCallOptions

The configuration of the call.

clientIdstring

The client ID of your application.

accessTokenstring

The access token to call the API with.

You need to obtain one using one of the Twitch OAuth flows.

Return type: T

callAPI<T>(options, clientId, accessToken)

staticasync
Deprecated.

Use callTwitchApi from twitch-api-call instead.

Makes a call to the Twitch API using given credentials.

ParameterTypeDescription
optionsTwitchApiCallOptions

The configuration of the call.

clientIdstring

The client ID of your application.

accessTokenstring

The access token to call the API with.

You need to obtain one using one of the Twitch OAuth flows.

Return type: T

getAccessToken(clientId, clientSecret, code, redirectUri)

staticasync
Deprecated.

Use exchangeCode from twitch-auth instead.

Retrieves an access token with your client credentials and an authorization code.

ParameterTypeDescription
clientIdstring

The client ID of your application.

clientSecretstring

The client secret of your application.

codestring

The authorization code.

redirectUristring

The redirect URI. This serves no real purpose here, but must still match with the redirect URI you configured in the Twitch Developer dashboard.

Return type: AccessToken

getAppAccessToken(clientId, clientSecret)

staticasync
Deprecated.

Use getAppToken from twitch-auth instead.

Retrieves an app access token with your client credentials.

ParameterTypeDescription
clientIdstring

The client ID of your application.

clientSecretstring

The client secret of your application.

Return type: AccessToken

getTokenInfo(accessToken, clientId)

staticasync
Deprecated.

Use getTokenInfo from twitch-auth instead.

Retrieves information about an access token.

ParameterTypeDescription
accessTokenstring

The access token to get the information of.

You need to obtain one using one of the Twitch OAuth flows.

clientIdstring

The client ID of your application.

Return type: TokenInfo

refreshAccessToken(clientId, clientSecret, refreshToken)

staticasync
Deprecated.

Use refreshUserToken from twitch-auth instead.

Refreshes an expired access token with your client credentials and the refresh token that was given by the initial authentication.

ParameterTypeDescription
clientIdstring

The client ID of your application.

clientSecretstring

The client secret of your application.

refreshTokenstring

The refresh token.

Return type: AccessToken

withClientCredentials(clientId, clientSecret, config)

static
Deprecated.

Use the constructor of ClientCredentialsAuthProvider and pass it as authProvider option to this class' constructor instead.

Creates a new instance with client credentials.

ParameterTypeDescription
clientIdstring

The client ID of your application.

clientSecretstring

The client secret of your application.

configPartial<ApiConfig>

Additional configuration to pass to the constructor.

Return type: ApiClient

withCredentials(clientId, accessToken, scopes, refreshConfig, config, tokenType)

static
Deprecated.

Use the constructor of StaticAuthProvider or RefreshableAuthProvider and pass it as authProvider option to this class' constructor instead.

Creates a new instance with fixed credentials.

ParameterTypeDescription
clientIdstring

The client ID of your application.

accessTokenstring

The access token to call the API with.

You need to obtain one using one of the Twitch OAuth flows.

scopesArray<string>

The scopes your supplied token has.

If this argument is given, the scopes need to be correct, or weird things might happen. If it's not (i.e. it's undefined), we fetch the correct scopes for you.

If you can't exactly say which scopes your token has, don't use this parameter/set it to undefined.

refreshConfigRefreshConfig

Configuration to automatically refresh expired tokens.

configPartial<ApiConfig>

Additional configuration to pass to the constructor.

tokenTypeAuthProviderTokenType

The type of token you passed.

This should almost always be 'user' (which is the default).

If you're passing 'app' here, please consider using {@ApiClient.withClientCredentials} instead.

Return type: ApiClient

callApi<T>(options)

async

Makes a call to the Twitch API using your access token.

ParameterTypeDescription
optionsTwitchApiCallOptions

The configuration of the call.

Return type: T

callAPI<T>(options)

async
Deprecated.

Use callApi instead.

Makes a call to the Twitch API using your access token.

ParameterTypeDescription
optionsTwitchApiCallOptions

The configuration of the call.

Return type: T

getAccessToken(scopes)

async
Deprecated.

Use AuthProvider#getAccessToken directly instead.

Retrieves an access token for the authentication provider.

ParameterTypeDescription
scopesstring | Array<string>

The scopes to request.

Return type: AccessToken | null

getTokenInfo()

async

Retrieves information about your access token.

Return type: TokenInfo

refresh()

async
Deprecated.

Use AuthProvider#refresh directly instead.

Forces the authentication provider to refresh the access token, if possible.

Return type: AccessToken | null

refreshAccessToken()

async
Deprecated.

Use AuthProvider#refresh directly instead.

Forces the authentication provider to refresh the access token, if possible.

Return type: ?AccessToken

requestScopes(scopes)

async

Requests scopes from the auth provider.

ParameterTypeDescription
scopesArray<string>

The scopes to request.

Return type: void