Constructor
new TwitchWebhook(config)
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object
|
The config object.
|
Methods
destroy()
Destroy the Webhook, unsubscribing every active subscription.
- Source:
handleRequest(method, headers, data) → {object}
This method will handle the request data and validate the subscriptions or properly emit the events with the received data.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
method |
string
|
The http method |
headers |
Array.<string>
|
The headers array |
data |
Array.<string>
|
The data array (query string for get, body for post) |
Returns:
- Type:
-
object
The response result object with the status and data to be sent in the response.
subscribe(topic, eventName) → {string}
Subscribe to a specific topic that will fires an event when new data is received from the hub. The event handler will receive the data object and the subscription ID.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
topic |
string
|
The topic name/URL. |
eventName |
string
|
The event name that will be fired when new data is received. |
Returns:
- Type:
-
string
The subscription ID, used to identify the active topic.
topicStreamUpDownSubscribe(streamUserId) → {string}
Notifies when a stream goes online or offline. The response mimics the Get Streams endpoint. (https://dev.twitch.tv/docs/api/reference/#get-streams)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
streamUserId |
number
|
The ID of the user whose stream is monitored. |
Fires:
Returns:
- Type:
-
string
The subscription ID, used to identify the active topic.
topicUserFollowsSubscribe(fromId, toId) → {string}
Notifies when a follows event occurs. The response mimics the Get Users Follows endpoint. (https://dev.twitch.tv/docs/api/reference/#get-users-follows)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fromId |
number
|
The ID of the user who starts following someone. |
toId |
number
|
The ID of the user who has a new follower. |
Fires:
Returns:
- Type:
-
string
The subscription ID, used to identify the active topic.
unsubscribe(id)
Unsubscribe from a topic by its ID.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
string
|
The subscription ID. |
Events
Webhook:stream_up_down
Stream Up/Down Event
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
object
|
The data object received from the Hub. |
id |
string
|
The subscription ID. |
Webhook:user_follows
Stream User Follows Event
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
object
|
The data object received from the Hub. |
id |
string
|
The subscription ID. |