Skip to main content

Get real time Twitch/Youtube events through Streamlabs SocketIO API

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlabsio-2.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlabsio-2.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlabsio-2.0.0.tar.gz.

File metadata

  • Download URL: streamlabsio-2.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for streamlabsio-2.0.0.tar.gz
Algorithm Hash digest
SHA256 92041acf4d1863db3a2439b02f61625e8c80fc55b416a36a21a7fc16d0f8e847
MD5 5059518300133bd86fff172ab3cfa455
BLAKE2b-256 d505f45b50586fb04bb3491583dc04a79e77b090fec152c4f3edf5c7c11f6323

See more details on using hashes here.

Provenance

The following attestation bundles were made for streamlabsio-2.0.0.tar.gz:

Publisher: publish.yml on onyx-and-iris/streamlabs-socketio-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file streamlabsio-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: streamlabsio-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for streamlabsio-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff952e7e9e4e7a90f87fc15bf7eef27c59bc68e87bb0de6f14d2910e1869be5b
MD5 f3ef2dc57de24e1d2a709e40a490b261
BLAKE2b-256 b276246ed370a55838110cd12e69161c3af39f84cf8c75740ba9778e6e7b3d27

See more details on using hashes here.

Provenance

The following attestation bundles were made for streamlabsio-2.0.0-py3-none-any.whl:

Publisher: publish.yml on onyx-and-iris/streamlabs-socketio-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page