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

WebHookListener

A WebHook listener you can track changes in various channel and user data with.

Overview

Constructor

new WebHookListener(apiClient, adapter, config)

Creates a new WebHook listener.

ParameterTypeRequiredDefaultDescription
apiClientApiClientnone

The ApiClient instance to use for user info and API requests.

adapterConnectionAdapternone

The connection adapter.

configWebHookConfig{}

Methods

create(apiClient, config)

staticasync
Deprecated.

Use the normal WebHookListener constructor instead.

Creates a new WebHook listener.

ParameterTypeRequiredDefaultDescription
apiClientApiClientnone

The ApiClient instance to use for user info and API requests.

configWebHookListenerConfig{}
Return type: WebHookListener

applyMiddleware(app)

Applies middleware that handles WebHooks to a connect-compatible app (like express).

ParameterTypeRequiredDefaultDescription
appConnectCompatibleAppnone

The app the middleware should be applied to.

Return type: void

listen()

async

Starts the backing server and listens to incoming WebHook notifications.

Return type: void

subscribeToBanEvents(broadcaster, handler, user, validityInSeconds)

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.

handler(banEvent: HelixBanEvent) => voidnone

The function that will be called for any new notifications.

userUserIdResolvablenone

The user that events will be sent for. If not given, events will be sent for all users.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToExtensionTransactions(extensionId, handler, validityInSeconds)

async

Subscribes to extension transactions.

ParameterTypeRequiredDefaultDescription
extensionIdstringnone

The extension ID for which to get notifications about transactions.

handler(transaction: HelixExtensionTransaction) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToFollowsFromUser(user, handler, validityInSeconds)

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.

handler(follow: HelixFollow) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToFollowsToUser(user, handler, validityInSeconds)

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.

handler(follow: HelixFollow) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToHypeTrainEvents(broadcaster, handler, validityInSeconds)

async

Subscribes to events representing a Hype Train event.

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

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

handler(hypeTrain: HelixHypeTrainEvent) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToModeratorEvents(broadcaster, handler, user, validityInSeconds)

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.

handler(modEvent: HelixModeratorEvent) => voidnone

The function that will be called for any new notifications.

userUserIdResolvablenone

The user that events will be sent for. If not given, events will be sent for all users.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToStreamChanges(user, handler, validityInSeconds)

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.

handler(stream: HelixStream) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToSubscriptionEvents(broadcaster, handler, validityInSeconds)

async

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

ParameterTypeRequiredDefaultDescription
broadcasterUserIdResolvablenone

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

handler(subscriptionEvent: HelixSubscriptionEvent) => voidnone

The function that will be called for any new notifications.

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

subscribeToUserChanges(user, handler, withEmail, validityInSeconds)

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.

handler(user: HelixUser) => voidnone

The function that will be called for any new notifications.

withEmailbooleanfalse

Whether to subscribe to email address changes. This requires an additional scope (user:read:email).

validityInSeconds?numberthis._defaultHookValidity

The validity of the WebHook, in seconds.

Please note that this doesn't mean that you don't get any notifications after the given time. The hook will be automatically refreshed.

This is meant for debugging issues. Please don't set it unless you know what you're doing.

Return type: Subscription

unlisten()

async

Stops the backing server, suspending all active subscriptions.

Return type: void