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

Classes

ApiClientBadgesApiBitsApiChannelChannelApiChannelFollowChannelPlaceholderChannelSubscriptionChatApiChatBadgeListChatBadgeSetChatBadgeVersionChatEmoteChatEmoteListChattersListCheermoteListConfigErrorCreatedVideoEmoteSetListHelixApiGroupHelixBanHelixBanEventHelixBitsApiHelixBitsLeaderboardHelixBitsLeaderboardEntryHelixChannelHelixChannelApiHelixChannelEditorHelixChannelEmoteHelixChannelPointsApiHelixChannelSearchResultHelixChatApiHelixChatBadgeSetHelixChatBadgeVersionHelixCheermoteListHelixClipHelixClipApiHelixCustomRewardHelixCustomRewardRedemptionHelixEmoteHelixEmoteFromSetHelixEventSubApiHelixEventSubSubscriptionHelixExtensionsApiHelixExtensionTransactionHelixFollowHelixGameHelixGameApiHelixHypeTrainApiHelixHypeTrainContributionHelixHypeTrainEventHelixInstalledExtensionHelixInstalledExtensionListHelixModerationApiHelixModeratorHelixModeratorEventHelixPaginatedRequestHelixPaginatedRequestWithTotalHelixPaginatedScheduleSegmentRequestHelixPollHelixPollApiHelixPollChoiceHelixPredictionHelixPredictionApiHelixPredictionOutcomeHelixPredictorHelixPrivilegedUserHelixScheduleHelixScheduleApiHelixScheduleSegmentHelixSearchApiHelixStreamHelixStreamApiHelixStreamMarkerHelixStreamMarkerWithVideoHelixSubscriptionHelixSubscriptionApiHelixSubscriptionEventHelixTagHelixTagApiHelixTeamHelixTeamApiHelixTeamWithUsersHelixUserHelixUserApiHelixUserBlockHelixUserExtensionHelixUserRelationHelixUserSubscriptionHelixVideoHelixVideoApiHelixWebHooksApiHelixWebHookSubscriptionKrakenApiGroupNoSubscriptionProgramErrorPrivilegedChannelPrivilegedUserSearchApiStreamStreamApiStreamNotLiveErrorSubscriptionTeamTeamApiTeamWithUsersUnsupportedApiUserUserApiUserBlockUserChatInfoUserFollowUserSubscriptionVideoVideoApi

HelixWebHooksApi

The API methods that deal with WebHooks.

Overview

Can be accessed using client.helix.webHooks on an ApiClient instance.

Before using these methods...

All of the methods in this class assume that you are already running a working WebHook listener at the given callback URL.

If you don't already have one, we recommend use of the twitch-webhooks library, which handles subscribing and unsubscribing to these topics automatically.

Example

const api = new ApiClient(new StaticAuthProvider(clientId, accessToken));
await api.helix.webHooks.subscribeToUserFollowsTo('125328655', { callbackUrl: 'https://example.com' });

Methods

getSubscriptions()

async

Retrieves the current WebHook subscriptions for the current client.

Requires an app access token to work; does not work with user tokens.

Return type: HelixPaginatedRequestWithTotal<HelixWebHookSubscriptionData, HelixWebHookSubscription>

sendHubRequest(options)

async

Sends an arbitrary request to subscribe to or unsubscribe from an event.

ParameterTypeRequiredDefaultDescription
optionsHelixWebHookHubRequestnonesee below
options.callbackUrlstringnone

The URL to send notifications to.

options.mode
HubMode

Whether to subscribe or unsubscribe from notifications.

Aliased type: "subscribe" | "unsubscribe"

none

Whether to subscribe or unsubscribe from notifications.

options.scopestringnone

The OAuth scope necessary to subscribe to or unsubscribe from the given topic.

options.secretstringnone

The secret to sign the notification payloads with.

options.topicUrlstringnone

What topic URL to subscribe to or unsubscribe from.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToBanEvents(broadcaster, options)

async

Subscribes to events representing a ban or unban.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which to get notifications about bans or unbans in their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToBanEventsForUser(broadcaster, user, options)

async

Subscribes to events representing a ban or unban.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which to get notifications about bans or unbans in their channel.

userUserIdResolvablenone

The user that is being banned or unbanned.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToExtensionTransactions(extensionId, options)

async

Subscribes to extension transactions.

ParameterTypeRequiredDefaultDescription
extensionIdstringnone

The extension ID for which to get notifications about transactions.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToHypeTrainEvents(broadcasterId, options)

async

Subscribes to events representing a Hype Train progressing.

ParameterTypeRequiredDefaultDescription
broadcasterIdUserIdResolvablenone

The broadcaster / channel for which to get notifications about Hype Train events.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToModeratorEvents(broadcaster, options)

async

Subscribes to events representing a user gaining or losing moderator privileges in a channel.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which to get notifications about moderator changes in their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToModeratorEventsForUser(broadcaster, user, options)

async

Subscribes to events representing a user gaining or losing moderator privileges in a channel.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which to get notifications about moderator changes in their channel.

userUserIdResolvablenone

The user that is being modded or unmodded.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToStreamChanges(user, options)

async

Subscribes to events representing a stream changing, i.e. going live, offline or changing its title or category.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about their streams changing.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToSubscriptionEvents(user, options)

async

Subscribes to events representing the start or end of a channel subscription.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about subscriptions to their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToUserChanges(user, options, withEmail)

async

Subscribes to events representing a user changing a public setting or their email address.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about changing a setting.

optionsHelixWebHookHubRequestOptionsnonesee below
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

withEmailbooleanfalse

Whether to subscribe to email address changes. This adds the necessary scope to read the email address to the request.

Return type: void

subscribeToUserFollowsFrom(user, options)

async

Subscribes to events representing a user following other users.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about the users they will follow.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

subscribeToUserFollowsTo(user, options)

async

Subscribes to events representing a user being followed by other users.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to get notifications about the users they will be followed by.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromBanEvents(broadcaster, options)

async

Unsubscribes from events representing a ban or unban.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which not to get any more notifications about bans or unbans in their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromBanEventsForUser(broadcaster, user, options)

async

Unsubscribes from events representing a ban or unban.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which not to get any more notifications about bans or unbans in their channel.

userUserIdResolvablenone

The user that is being banned or unbanned.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromExtensionTransactions(extensionId, options)

async

Unsubscribes from extension transactions.

ParameterTypeRequiredDefaultDescription
extensionIdstringnone

The extension ID for which not to get any more notifications about transactions.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromHypeTrainEvents(broadcasterId, options)

async

Unsubscribes from events representing a Hype Train progressing.

ParameterTypeRequiredDefaultDescription
broadcasterIdUserIdResolvablenone

The broadcaster / channel for which to get notifications about Hype Train events.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromModeratorEvents(broadcaster, options)

async

Unsubscribes from events representing a user gaining or losing moderator privileges in a channel.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which not to get any more notifications about moderator changes in their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromModeratorEventsForUser(broadcaster, user, options)

async

Unsubscribes from events representing a user gaining or losing moderator privileges in a channel.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

The broadcaster for which not to get any more notifications about moderator changes in their channel.

userUserIdResolvablenone

The user that is being modded or unmodded.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromStreamChanges(user, options)

async

Unsubscribes from events representing a stream changing.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which not to get any more notifications about their streams changing.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromSubscriptionEvents(user, options)

async

Unsubscribes from events representing the start or end of a channel subscription.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which not to get any more notifications about subscriptions and unsubscriptions to their channel.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromUserChanges(user, options)

async

Unsubscribes from events representing a user changing a public setting or their email address.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which not to get any more notifications about changing a setting.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromUserFollowsFrom(user, options)

async

Unsubscribes from events representing a user following other users.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to not get any more notifications about the users they will follow.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void

unsubscribeFromUserFollowsTo(user, options)

async

Unsubscribes from events representing a user being followed by other users.

ParameterTypeRequiredDefaultDescription
userUserIdResolvablenone

The user for which to not get any more notifications about the users they will be followed by.

optionsHelixWebHookHubRequestOptionsnone
options.callbackUrlstringnone

The URL to send notifications to.

options.secretstringnone

The secret to sign the notification payloads with.

options.validityInSecondsnumbernone

The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days).

Return type: void