Streamlabs Desktop API

The Streamlabs Desktop API provides functionality that allows your application to interact with and control the Streamlabs Desktop host application.

Permissions

Interacting with this API requires your app to have special permissions defined in your manifest.json. The Streamlabs Desktop API is divided into modules, and each module requires a particular permission, which is listed on that module's documentation page.

Accessing the API

The Streamlabs Desktop API is accessed via the window.streamlabsOBS global variable. Please note that the Streamlabs Desktop API is only available in pages. Browser sources (widgets) do not ever have access to the Streamlabs Desktop API.

It is important not to call into the streamlabsOBS API until it is ready. There is a promise available at streamlabsOBS.apiReady that you should wait on before performing any more interaction with the streamlabsOBS global.

streamlabsOBS.apiReady.then(() => {
  console.log('Streamlabs OBS API is ready');

  // Make some calls
  streamlabsOBS.v1.Sources.getSources();
});

All modules are grouped behind an API version. Currently only v1 of the API is available, so all modules can be found under streamlabsOBS.v1. For example, the Sources module can be found in streamlabsOBS.v1.Sources.

Methods

All API methods return a promise that will either resolve on success, or reject on failure. For example, to fetch a list of sources from the sources service:

streamlabsOBS.v1.Sources.getSources()
  .then(sources => {
    console.log('Current sources:', sources);
  })
  .catch(error => {
    console.log('There was an error fetching sources!');
  });

Events

Some API modules provide various event feeds that you can subscribe to. To subscribe to an event, simply call it as if it were a function, and pass a callback function as an argument. Your callback function will be invoked any time there is an event emitted. At this current time, there is no way to unsubscribe from events. For example, if you wanted to subscribe to the sourceAdded event in the Sources module:

streamlabsOBS.v1.Sources.sourceAdded(source => {
  console.log('Source Added', source);
});

Final Notes

This is a living API. This API is currently in a limited state and we plan on expanding it massively over the coming weeks and months. If there is any functionality that you wish was available, please let us know, and we can see if it is feasible to add it. We want this API to be driven by the people building and investing in the platform.

Please post in if you have suggestions or a question. We will figure it out together.