Constructors
constructor
Defined in src/Api/api.ts:70
Parameters
Returns Api
Properties
Private _log
Defined in src/Api/api.ts:66
Private _options
Defined in src/Api/api.ts:65
Private _readyState
Defined in src/Api/api.ts:68
Private _status
Defined in src/Api/api.ts:70
Accessors
readyState
Defined in src/Api/api.ts:78
status
Defined in src/Api/api.ts:82
Methods
Private _getAuthenticationHeaders
_getAuthenticationHeaders( ) : RequestInit [ "headers" ]
Defined in src/Api/api.ts:157
Returns RequestInit [ "headers" ]
Private _handleAuthenticationFailure
_handleAuthenticationFailure( originError: Error ) : Promise < undefined | string >
Defined in src/Api/api.ts:223
Parameters
Returns Promise < undefined | string >
Private _handleFetch
Defined in src/Api/api.ts:166
Type parameters
Parameters
Default value maybeUrl: string = ""
Returns Promise < T >
get
Defined in src/Api/api.ts:139
Type parameters
Parameters
Default value endpoint: string = ""
Returns Promise < T >
hasScope
hasScope( scope: string ) : Promise < boolean >
Defined in src/Api/api.ts:119
Parameters
Returns Promise < boolean >
initialize
initialize( newOptions?: Partial < ApiOptions > ) : Promise < void >
Defined in src/Api/api.ts:97
Parameters
Returns Promise < void >
post
Defined in src/Api/api.ts:146
Type parameters
Parameters
Returns Promise < T >
put
Defined in src/Api/api.ts:153
Type parameters
Parameters
Returns Promise < T >
updateOptions
Defined in src/Api/api.ts:89
Parameters
Returns void
Legend
Constructor
Property
Method
Inherited property
Inherited method
Private property
Private method
Make requests to Twitch API.
Initializing
const token = 'cfabdegwdoklmawdzdo98xt2fo512y' const clientId = 'uo6dggojyb8d6soh92zknwmi5ej1q2' const { api } = new TwitchJs({ token, clientId })
Making requests
By default, the API client makes requests to the Helix API, and exposes Api.get, Api.post and Api.put methods. Query and body parameters are provided via
options.search
andoptions.body
properties, respectively.Examples
Get bits leaderboard
api .get('bits/leaderboard', { search: { user_id: '44322889' } }) .then(response => { // Do stuff with response ... })
Get the latest Overwatch live streams
api .get('streams', { search: { game_id: '1234' } }) .then(response => { // Do stuff with response ... })
Start a channel commercial
api .post('/channels/commercial', { body: { broadcaster_id: '44322889', length: 30 }, }) .then(response => { // Do stuff with response ... })