Third-Party APIs #

Modules have access to all of the supported service APIs without the need to implement the logic themselves.

The Services currently supported are as follows:

Making Requests #

All Modules are given access to interfaces to make requests to the supported Services. Here is an example of requesting the Top 5 Games from Twitch:

window.casthub.fetch({
    integration: 'twitch',
    method: 'GET',
    url: 'kraken/games/top',
    data: {
        limit: 5,
    },
}).then(response => {
    console.log(response);
});

Authenticated Requests #

Modules are permitted to make authenticated requests on behalf of the User. This is much more easily done if your Module has enabled the Requires an Identity option, as you're given the Identity to use:

For security reasons, Modules do not have access to the Access Tokens for a User, and instead send a request object to the parent process.

Your Module will be given an array of identities that the user has given permission to use, including a UUID that you should pass in the request object:

const { id } = this.identities[0]; // Will be an Array of all permitted integrations.

window.casthub.fetch({
    integration: 'twitch',
    method: 'GET',
    url: 'kraken/channel',
    identity: id,
}).then(response => {
    console.log(response);
});

If your Module does not require an Identity, it's up to you how you find this from the User.

Refreshing Tokens #

For most third-party API Tokens, they expire after a few hours. To prevent you as a Developer from having to deal with this, CastHub will automatically refresh any Tokens that it detects have been invalidated.

This process is seamless, and when it happens, your request will automatically be re-run with the new Token. Nothing to worry about!

New Services #

We're always open to integrations new third-party Services in to the Module Ecosystem. There are only a few requirements:

  1. OAuth 2 is implemented and available
  2. API is served over HTTPS
  3. API is well-documented

Feel free to contact us via Discord if you have a Service integration request.