Streamlabs

API

All Modules for Streamlabs are given access to make requests on the Users' behalf. All requests are automatically authenticated.

Here is an example of requesting the latest 5 Tips from Streamlabs:

const response = await window.casthub.fetch({
    integration: 'streamlabs',
    method: 'GET',
    url: 'donations',
    data: {
        limit: 5,
    },
});

This supports the Streamlabs REST API reference.

WebSocket

CastHub makes using Streamlabs WebSockets easy by managing all identities for you. For example:

async mounted() {
    await super.mounted();

    const { id } = this.identity;

    // Connect to the external WebSocket.
    const ws = await window.casthub.ws(id);

    // And register the new Tip Event.
    ws.on('donations', data => {
        console.log(data);
    });
}

If a connection to that specific Identity is already open (For example, when another Module has already opened it), you will be subscribed to events from that instance straight away and won't need to wait for a new connection to open.