Overview
Constructor
new ApiClient(config)
Creates a new API client instance.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
config | Partial<ApiConfig> | none | Configuration for the client instance. |
Properties
badges
Type: BadgesApi
Use HelixChatApi's badge methods instead.
The API methods that deal with badges.
currentScopes
Type: Array<string>
Use AuthProvider#currentScopes directly instead.
The scopes that are currently available using the access token.
Methods
callApi<T>(options, clientId, accessToken)
staticasyncUse callTwitchApi
from twitch-api-call
instead.
Makes a call to the Twitch API using given credentials.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
options | TwitchApiCallOptions | none | The configuration of the call. | |
clientId | string | none | The client ID of your application. | |
accessToken | string | none | The access token to call the API with. You need to obtain one using one of the Twitch OAuth flows. |
callAPI<T>(options, clientId, accessToken)
staticasyncUse callTwitchApi
from twitch-api-call
instead.
Makes a call to the Twitch API using given credentials.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
options | TwitchApiCallOptions | none | The configuration of the call. | |
clientId | string | none | The client ID of your application. | |
accessToken | string | none | The access token to call the API with. You need to obtain one using one of the Twitch OAuth flows. |
getAccessToken(clientId, clientSecret, code, redirectUri)
staticasyncUse exchangeCode
from twitch-auth
instead.
Retrieves an access token with your client credentials and an authorization code.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The client ID of your application. | |
clientSecret | string | none | The client secret of your application. | |
code | string | none | The authorization code. | |
redirectUri | string | none | The redirect URI. This serves no real purpose here, but must still match with the redirect URI you configured in the Twitch Developer dashboard. |
getAppAccessToken(clientId, clientSecret)
staticasyncUse getAppToken
from twitch-auth
instead.
Retrieves an app access token with your client credentials.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The client ID of your application. | |
clientSecret | string | none | The client secret of your application. |
getTokenInfo(accessToken, clientId)
staticasyncUse getTokenInfo
from twitch-auth
instead.
Retrieves information about an access token.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
accessToken | string | none | The access token to get the information of. You need to obtain one using one of the Twitch OAuth flows. | |
clientId | string | none | The client ID of your application. |
refreshAccessToken(clientId, clientSecret, refreshToken)
staticasyncUse 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.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The client ID of your application. | |
clientSecret | string | none | The client secret of your application. | |
refreshToken | string | none | The refresh token. |
withClientCredentials(clientId, clientSecret, config)
staticUse the constructor of ClientCredentialsAuthProvider and pass it as authProvider
option to this class' constructor instead.
Creates a new instance with client credentials.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The client ID of your application. | |
clientSecret | string | none | The client secret of your application. | |
config | Partial<ApiConfig> | {} | Additional configuration to pass to the constructor. |
withCredentials(clientId, accessToken, scopes, refreshConfig, config, tokenType)
staticUse the constructor of StaticAuthProvider or RefreshableAuthProvider and pass it as authProvider
option to this class' constructor instead.
Creates a new instance with fixed credentials.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
clientId | string | none | The client ID of your application. | |
accessToken | string | none | The access token to call the API with. You need to obtain one using one of the Twitch OAuth flows. | |
scopes | Array<string> | none | 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 If you can't exactly say which scopes your token has, don't use this parameter/set it to | |
refreshConfig | RefreshConfig | none | Configuration to automatically refresh expired tokens. | |
config | Partial<ApiConfig> | {} | Additional configuration to pass to the constructor. | |
tokenType | AuthProviderTokenType | "user" | 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. |
callApi<T>(options)
asyncMakes a call to the Twitch API using your access token.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
options | TwitchApiCallOptions | none | The configuration of the call. |
callAPI<T>(options)
asyncUse callApi instead.
Makes a call to the Twitch API using your access token.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
options | TwitchApiCallOptions | none | The configuration of the call. |
getAccessToken(scopes)
asyncUse AuthProvider#getAccessToken directly instead.
Retrieves an access token for the authentication provider.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
scopes | string | Array<string> | none | The scopes to request. |
refresh()
asyncUse AuthProvider#refresh directly instead.
Forces the authentication provider to refresh the access token, if possible.
refreshAccessToken()
asyncUse AuthProvider#refresh directly instead.
Forces the authentication provider to refresh the access token, if possible.
requestScopes(scopes)
asyncRequests scopes from the auth provider.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
scopes | Array<string> | none | The scopes to request. |