Twitch Extensions Game Events

Sample Code

Overview

Twitch lets developers develop Twitch extensions which are interactive web apps that runs in the broadcaster’s channel.
The extension’s front end runs in an iframe and can communicate with an Extension Backend Service (EBS).
For more details about Twitch extensions visit: https://dev.twitch.tv/docs/extensions/

Overwolf’s Twitch Game Events lets a Twitch extension developer to receive game events that occur to a specific broadcaster in-game (for supported games).

The broadcaster must run Overwolf’s Twitch game events app while in-game and log in to Twitch from the app.
Twitch game events app will relay the events to Overwolf’s PubSub server to a “room” identified by the broadcaster’s twitch id. These are the same events and info-updates that are received from Overwolf’s Game Events Provider (overwolf.games.events)
For more information about Game Events visit: http://developers.overwolf.com/documentation/sdk/overwolf/games/events/

The Twitch extension EBS should connect to the PubSub server and subscribe to the same “room” in order to receive the events and info-updates of the broadcaster.

Preconditions

  • The streamer (broadcaster) must run the Twitch game events app while in game and be logged in to Twitch from the app.
  • In order to connect to Overwolf’s events PubSub, the developer of the extension must obtain a client id and secret that will be used for authentication in front of the PubSub.

Connecting to the events PubSub

The PubSub address is https://twitchge.overwolf.com

Authenticating

POST /auth/backend

Providing in the body the credentials obtained from Overwolf :

{
 broadcaster: OUR_STREAMER_ID,
 client_key: CLEINT_KEY,
 client_secret: CLIENT_SECRET
}

If the authentication is successful the response will contain a JSON with token property.
This token should be used to connect to the PubSub socket and as a bearer token for authorization for other endpoints of the Game Events PubSub server.

Special Endpoints

The PubSub server has 2 special endpoints that can be used to retrieve info about the state of the game of the broadcaster.
These endpoints must be called with Authorization: Bearer <token> header providing the token obtained from the /auth/backend call.

Get Streamer Game

GET /info/:streamer_id/game

Response: the game id that is being played by the streamer

Get Game Info

GET /info/:streamer_id

Response: the summary of the info updates happened in the streamer’s game.
This corresponds to the getInfo() method of Game Events Provider:
http://developers.overwolf.com/documentation/sdk/overwolf/games/events/#getinfo

Notes

When connecting to the PubSub, the EBS should query the PubSub once for the current state of the game of the streamer using the special endpoints and continue updating the information according to the events received from the PubSub socket.