2026-03-25 05:47:02 +00:00
2026-03-25 05:46:14 +00:00
2026-03-23 12:00:59 +00:00
2022-11-13 08:17:36 +00:00
2026-03-25 05:46:14 +00:00
2026-03-25 05:47:02 +00:00
2026-03-25 05:46:14 +00:00

PyPI version License: MIT Poetry Ruff

A Python client for Streamlabs Socket API

For an outline of past/future changes refer to: CHANGELOG

Requirements

  • A Streamlabs Socket API key.

    • You can acquire this by logging into your Streamlabs.com dashboard then Settings->Api Settings->API Tokens
  • Python 3.10 or greater

Install

pip install streamlabsio

Use

import streamlabsio


def on_streamlabs_event(event, data):
    print(f'{event}: {data.attrs()}')


def on_twitch_event(event, data):
    if event == 'follow':
        print(f'{data.name} just followed!')


def main():
    with streamlabsio.connect(token="<API token>") as client:
        client.obs.on('streamlabs', on_streamlabs_event)
        client.obs.on('twitch_account', on_twitch_event)

        # run for 30 seconds then disconnect client from server
        client.wait(30)


if __name__ == '__main__':
    main()

Client class

streamlabsio.connect(*, token: str, raw: bool = False) -> Client

The following keyword arguments may be passed:

  • token: Streamlabs SocketIO api token.
  • raw: Receive raw data messages as json objects.

methods

wait(self, seconds: float | None = None) -> None

  • float: Time in seconds to block the main thread
    • If None, the method will block indefinitely.

Event Data Attributes

For event data you may inspect the available attributes using attrs().

example:

def on_twitch_event(event, data):
    print(f'{event}: {data.attrs()}')

Errors

  • SteamlabsSIOError: Base StreamlabsSIO error class
  • SteamlabsSIOConnectionError: Exception raised when connection errors occur

Logging

To view the logs emitted by the streamlabsio library simply add the following to your code:

from loguru import logger

logger.enable('streamlabsio')

Official Documentation

Description
Get real time Twitch/Youtube events through Streamlabs Socket API
Readme MIT 298 KiB
Languages
Python 100%