Useful when an application needs to query the API, but doesn't want to resort to a RESTful API method.

On-demand events are simply event listeners on the API that respond to events fired by your application.

On-demand events are the correct approach when you need to query the API directly for information, but don't want to resort to a full-blown RESTful API method.

For example, if you need to determine whether or not a user in a Twitch chat room is a GameWisp subscriber, you would use the channel-subscribers on-demand event.

All on-demand events require the following structure using Socket.IO:

socket.emit('event-name', {
    access_token: "channel OAuth2 access token"

To retrieve a response from an on-demand event you will need to listen to the appropriate event. For example, you can use the channel-connect on-demand event to connect to a GameWisp channel, but you will not receive a response from that event unless you ensure that your app is listening for the app-channel-connected event. All on-demand events have listeners that use the app-* naming convention. For example:

socket.emit('channel-subscribers', {
    access_token: "channel OAuth2 access token"

socket.on('app-channel-subscribers', function(data){
	//Do things with the data object here...

One of the primary purposes of the on-demand events is to allow an application to synchronize its state with GameWisp in the event of an application restart or when authorizing a new channel for the first time.

For example, after successfully connecting to a channel using channel-connect an app can (and should) get the current subscribers for the channel by using the channel-subscribers event.