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.

ParameterTypeDescription
apiClientApiClient

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

adapterConnectionAdapter

The connection adapter.

configWebHookConfig

Methods

create(apiClient, config)

staticasync
Deprecated.

Use the normal WebHookListener constructor instead.

Creates a new WebHook listener.

ParameterTypeDescription
apiClientApiClient

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).

ParameterTypeDescription
appConnectCompatibleApp

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.

ParameterTypeDescription
broadcasterUserIdResolvable

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

handler(banEvent: HelixBanEvent) => void

The function that will be called for any new notifications.

userUserIdResolvable

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

validityInSeconds?number

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.

ParameterTypeDescription
extensionIdstring

The extension ID for which to get notifications about transactions.

handler(transaction: HelixExtensionTransaction) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
userUserIdResolvable

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

handler(follow: HelixFollow) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
userUserIdResolvable

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

handler(follow: HelixFollow) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
broadcasterUserIdResolvable

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

handler(hypeTrain: HelixHypeTrainEvent) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
broadcasterUserIdResolvable

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

handler(modEvent: HelixModeratorEvent) => void

The function that will be called for any new notifications.

userUserIdResolvable

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

validityInSeconds?number

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.

ParameterTypeDescription
userUserIdResolvable

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

handler(stream: HelixStream) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
broadcasterUserIdResolvable

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

handler(subscriptionEvent: HelixSubscriptionEvent) => void

The function that will be called for any new notifications.

validityInSeconds?number

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.

ParameterTypeDescription
userUserIdResolvable

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

handler(user: HelixUser) => void

The function that will be called for any new notifications.

withEmailboolean

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

validityInSeconds?number

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