TwurpleAuthenticationGetting dataExamplesFAQMigration

Main classes

ApiClient

An API client for the Twitch Helix API and other miscellaneous endpoints.

Overview

Constructor

new ApiClient(config)

Creates a new API client instance.

ParameterTypeRequiredDefaultDescription
configApiConfignone

Configuration for the client instance.

Methods

asIntent<T>(intents, runner)

async

Creates a contextualized ApiClient that can be used to call the API in the context of a given intent.

ParameterTypeRequiredDefaultDescription
intentsstring[]none

A list of intents. The first one that is found in your auth provider will be used.

runner(ctx: BaseApiClient) => Promise<T>none

The callback to execute.

A parameter is passed that should be used in place of the normal ApiClient to ensure that all requests are executed in the given user's context.

Please note that requests which require scope authorization ignore this context.

The return value of your callback will be propagated to the return value of this method.

Return type: T

asUser<T>(user, runner)

async

Creates a contextualized ApiClient that can be used to call the API in the context of a given user.

ParameterTypeRequiredDefaultDescription
user
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The user to use as context.

runner(ctx: BaseApiClient) => Promise<T>none

The callback to execute.

A parameter is passed that should be used in place of the normal ApiClient to ensure that all requests are executed in the given user's context.

Please note that requests which require scope authorization ignore this context.

The return value of your callback will be propagated to the return value of this method.

Return type: T

withoutUser<T>(runner)

async

Creates a contextualized ApiClient that can be used to call the API without the context of any user.

This usually means that an app access token is used.

ParameterTypeRequiredDefaultDescription
runner(ctx: BaseApiClient) => Promise<T>none

The callback to execute.

A parameter is passed that should be used in place of the normal ApiClient to ensure that all requests are executed without user context.

Please note that requests which require scope authorization ignore this context erasure.

The return value of your callback will be propagated to the return value of this method.

Return type: T