Node.js Twitch Helix Webhooks
Little Node.js module to interact with new Twitch Helix API Webhooks.
Install
npm install --save twitch-webhook
Usage
Note: Twitch will return old payload for "users/follows" topic
if {first: 1}
is not specified
const TwitchWebhook = require('twitch-webhook')
const twitchWebhook = new TwitchWebhook({
client_id: 'Your Twitch Client ID',
callback: 'Your Callback URL',
secret: 'It\'s a secret',
lease_seconds: 259200,
listen: {
port: 8080,
host: '127.0.0.1',
autoStart: false
}
})
twitchWebhook.on('*', ({ topic, options, endpoint, event }) => {
console.log(topic)
console.log(options)
console.log(endpoint)
console.log(event)
})
twitchWebhook.on('users/follows', ({ event }) => {
console.log(event)
})
twitchWebhook.subscribe('users/follows', {
first: 1,
from_id: 12826
})
twitchWebhook.on('unsubscibe', (obj) => {
twitchWebhook.subscribe(obj['hub.topic'])
})
process.on('SIGINT', () => {
twitchWebhook.unsubscribe('*')
twitchWebhook.unsubscribe('users/follows', {
first: 1,
to_id: 12826
})
process.exit(0)
})
Documentation
API Reference