-
Notifications
You must be signed in to change notification settings - Fork 94
Webhook
Webhooks are a way to send JSON data to remote servers when events occur.
The currently supported events:
- Stream Starts
- Stream End
- Comment/Chat Received
These events are configured on a per-webhook basis - so each user can choose which events go to which webhook.
All webhooks are made as POST
requests with the Content-type: application/json
header, and a JSON-encoded body.
There's two kinds of webhooks currently:
- Discord
- Raw
The Discord webhook can post messages to a channel. When a user goes live, it can post a message with links to any livestreams. When a stream receives comments or chat messages, they can be posted as well.
The Raw webhook contains more data, and is meant for writing your own tools for reacting to events.
Here's example JSON messages of the Discord
webhook type:
{
"content": "john is now streaming! https://twitch.tv/jprjrdev",
"username": "john"
}
{
"content": "Here's a comment!",
"username": "jprjr @ Twitch"
}
{
"content": "is emoting Kappa",
"username": "jprjr @ Twitch"
}
{
"content": "john has stopped streaming",
"username": "john"
}
And here are the same messages, but with the Raw
webook type:
{
"hook_type": "stream:start",
"accounts": [
{
"id": 14,
"network": {
"displayname": "Twitch",
"name": "twitch"
},
"slug": "jprjrdev",
"name": "jprjrdev",
"http_url": "https://twitch.tv/jprjrdev"
}
],
"user": {
"username": "john",
"id": 1
},
"stream": {
"slug": "huzzahhhhhhh",
"name": "Huzzahhhhhhh",
"id": 23
}
}
{
"hook_type": "comment:in",
"account": {
"id": 14,
"name": "jprjrdev",
"slug": "jprjrdev"
},
"user": {
"username": "john",
"id": 1
},
"text": "Here's a comment!",
"markdown": "Here's a comment\\!",
"network": {
"displayname": "Twitch",
"name": "twitch"
},
"from": {
"name": "jprjr",
"id": "80787634"
},
"type": "text",
"stream": {
"slug": "huzzahhhhhhh",
"name": "Huzzahhhhhhh",
"id": 23
}
}
{
"hook_type": "comment:in",
"account": {
"id": 14,
"name": "jprjrdev",
"slug": "jprjrdev"
},
"user": {
"username": "john",
"id": 1
},
"text": "is emoting Kappa",
"markdown": "is emoting ![Kappa](https://static-cdn.jtvnw.net/emoticons/v1/25/1.0)",
"network": {
"displayname": "Twitch",
"name": "twitch"
},
"from": {
"name": "jprjr",
"id": "80787634"
},
"type": "emote",
"stream": {
"slug": "huzzahhhhhhh",
"name": "Huzzahhhhhhh",
"id": 23
}
}
{
"hook_type": "stream:end",
"user": {
"username": "john",
"id": 1
},
"stream": {
"slug": "huzzahhhhhhh",
"name": "Huzzahhhhhhh",
"id": 23
}
}