Extension Users

Users of your extension have the option to share their identity on Twitch with you. MEDKit has a function to request a list of all users who are currently sharing this information.

Admin-only

This list is not exposed to viewers or broadcasters. Only extension admins are able to use this functionality.

API

To request the current list of shared Twitch IDs, simply call:

const opts = new Muxy.DebuggingOptions();
opts.role('admin');
Muxy.debug(opts);

const sdk = new Muxy.SDK();
sdk.loaded().then(() => {
  sdk.getExtensionUsers().then((resp) => {
    resp.results.forEach((u) => {
      console.log(u.twitch_id);
    });

    console.log(`There are ${resp.next === '0' ? 'no ' : ' '}more results available`);
  });
});

The JSON response from this method has the following structure:

{
  next: '0',
  results: [
    { twitch_id: '12345' },
    { twitch_id: '23456' },
    { twitch_id: '34567' }
  ]
}

Iteration

getExtensionUsers returns at most 1,000 objects in its response. If more than 1,000 users have shared their identity with your extension, you will have to make more calls to iterate through all users.

You can do this by using the next field in the object response. This value will contain the next “page” of results to request, or the value "0" if all results have been returned. You can pass the returned value directly to getExtensionUsers to get the next (up-to) 1,000 users, or use the value "0" to begin iterating.

const opts = new Muxy.DebuggingOptions();
opts.role('admin');
Muxy.debug(opts);

const sdk = new Muxy.SDK();
sdk.loaded().then(() => {
  function getNextUsers(cursor) {
    sdk.getExtensionUsers(cursor).then((resp) => {
      resp.results.forEach((u) => {
        console.log(u.twitch_id);
      });

      if (resp.next !== '0') {
        // NOTE: Be careful of blind iteration like this for very successful extensions.
        // If a million users have shared their id with this extension, you will very
        // quickly make 1,000 API requests.
        getNextUsers(resp.next);
      }
    });
  }

  getNextUsers('0');
});