Overview
Methods
- getSubscriptionsa
- sendHubRequesta
- subscribeToBanEventsa
- subscribeToBanEventsForUsera
- subscribeToExtensionTransactionsa
- subscribeToHypeTrainEventsa
- subscribeToModeratorEventsa
- subscribeToModeratorEventsForUsera
- subscribeToStreamChangesa
- subscribeToSubscriptionEventsa
- subscribeToUserChangesa
- subscribeToUserFollowsFroma
- subscribeToUserFollowsToa
- unsubscribeFromBanEventsa
- unsubscribeFromBanEventsForUsera
- unsubscribeFromExtensionTransactionsa
- unsubscribeFromHypeTrainEventsa
- unsubscribeFromModeratorEventsa
- unsubscribeFromModeratorEventsForUsera
- unsubscribeFromStreamChangesa
- unsubscribeFromSubscriptionEventsa
- unsubscribeFromUserChangesa
- unsubscribeFromUserFollowsFroma
- unsubscribeFromUserFollowsToa
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()
asyncRetrieves the current WebHook subscriptions for the current client.
Requires an app access token to work; does not work with user tokens.
sendHubRequest(options)
asyncSends an arbitrary request to subscribe to or unsubscribe from an event.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
options | HelixWebHookHubRequest | none | see below | |
options.callbackUrl | string | none |
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.scope | string | none |
The OAuth scope necessary to subscribe to or unsubscribe from the given topic. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.topicUrl | string | none |
What topic URL to subscribe to or unsubscribe from. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToBanEvents(broadcaster, options)
asyncSubscribes to events representing a ban or unban.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which to get notifications about bans or unbans in their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToBanEventsForUser(broadcaster, user, options)
asyncSubscribes to events representing a ban or unban.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which to get notifications about bans or unbans in their channel. |
|
user | UserIdResolvable | none |
The user that is being banned or unbanned. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToExtensionTransactions(extensionId, options)
asyncSubscribes to extension transactions.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
extensionId | string | none |
The extension ID for which to get notifications about transactions. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToHypeTrainEvents(broadcasterId, options)
asyncSubscribes to events representing a Hype Train progressing.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcasterId | UserIdResolvable | none |
The broadcaster / channel for which to get notifications about Hype Train events. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToModeratorEvents(broadcaster, options)
asyncSubscribes to events representing a user gaining or losing moderator privileges in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which to get notifications about moderator changes in their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToModeratorEventsForUser(broadcaster, user, options)
asyncSubscribes to events representing a user gaining or losing moderator privileges in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which to get notifications about moderator changes in their channel. |
|
user | UserIdResolvable | none |
The user that is being modded or unmodded. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToStreamChanges(user, options)
asyncSubscribes to events representing a stream changing, i.e. going live, offline or changing its title or category.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to get notifications about their streams changing. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToSubscriptionEvents(user, options)
asyncSubscribes to events representing the start or end of a channel subscription.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to get notifications about subscriptions to their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToUserChanges(user, options, withEmail)
asyncSubscribes to events representing a user changing a public setting or their email address.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to get notifications about changing a setting. |
|
options | HelixWebHookHubRequestOptions | none | see below | |
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
|
withEmail | boolean | false |
Whether to subscribe to email address changes. This adds the necessary scope to read the email address to the request. |
subscribeToUserFollowsFrom(user, options)
asyncSubscribes to events representing a user following other users.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to get notifications about the users they will follow. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
subscribeToUserFollowsTo(user, options)
asyncSubscribes to events representing a user being followed by other users.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to get notifications about the users they will be followed by. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromBanEvents(broadcaster, options)
asyncUnsubscribes from events representing a ban or unban.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which not to get any more notifications about bans or unbans in their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromBanEventsForUser(broadcaster, user, options)
asyncUnsubscribes from events representing a ban or unban.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which not to get any more notifications about bans or unbans in their channel. |
|
user | UserIdResolvable | none |
The user that is being banned or unbanned. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromExtensionTransactions(extensionId, options)
asyncUnsubscribes from extension transactions.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
extensionId | string | none |
The extension ID for which not to get any more notifications about transactions. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromHypeTrainEvents(broadcasterId, options)
asyncUnsubscribes from events representing a Hype Train progressing.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcasterId | UserIdResolvable | none |
The broadcaster / channel for which to get notifications about Hype Train events. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromModeratorEvents(broadcaster, options)
asyncUnsubscribes from events representing a user gaining or losing moderator privileges in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which not to get any more notifications about moderator changes in their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromModeratorEventsForUser(broadcaster, user, options)
asyncUnsubscribes from events representing a user gaining or losing moderator privileges in a channel.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
broadcaster | UserIdResolvable | none |
The broadcaster for which not to get any more notifications about moderator changes in their channel. |
|
user | UserIdResolvable | none |
The user that is being modded or unmodded. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromStreamChanges(user, options)
asyncUnsubscribes from events representing a stream changing.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which not to get any more notifications about their streams changing. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromSubscriptionEvents(user, options)
asyncUnsubscribes from events representing the start or end of a channel subscription.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which not to get any more notifications about subscriptions and unsubscriptions to their channel. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromUserChanges(user, options)
asyncUnsubscribes from events representing a user changing a public setting or their email address.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which not to get any more notifications about changing a setting. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromUserFollowsFrom(user, options)
asyncUnsubscribes from events representing a user following other users.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to not get any more notifications about the users they will follow. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |
unsubscribeFromUserFollowsTo(user, options)
asyncUnsubscribes from events representing a user being followed by other users.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
user | UserIdResolvable | none |
The user for which to not get any more notifications about the users they will be followed by. |
|
options | HelixWebHookHubRequestOptions | none | ||
options.callbackUrl | string | none |
The URL to send notifications to. |
|
options.secret | string | none |
The secret to sign the notification payloads with. |
|
options.validityInSeconds | number | none |
The number of seconds the subscription is valid for. Defaults to 3600 (1 hour). Can be at most 864000 (10 days). |