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.8 or greater

How to install using pip

pip install streamlabsio

How to Use

You may store your api key in a config.toml file, its contents should resemble:

[streamlabs]
token = "<apikey>"

Place it next to your __main__.py file.

Otherwise:

You may pass it as a keyword argument.

Example __main__.py:

import streamlabsio


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


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

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


if __name__ == '__main__':
    main()

note

From the SocketIO docs, client.sio.wait() may be used if your application has nothing to do in the main thread.

Client class

streamlabsio.connect(token="<apikey>", raw=False)

The following keyword arguments may be passed:

  • token: str Streamlabs SocketIO api token.
  • raw: boolean=False Receive raw data messages as json objects.

The following attribute is available:

  • raw: boolean Toggle raw mode at runtime.

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 raw incoming event data set logging level to DEBUG. Check debug example.

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-1.1.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

streamlabsio-1.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlabsio-1.1.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.7 Windows/11

File hashes

Hashes for streamlabsio-1.1.3.tar.gz
Algorithm Hash digest
SHA256 9b97df8680525b7301d5ef4a13b0182ea0eebb2a8081e0b58ef065150a29eef1
MD5 af22d223182791e4e45ad1c818062fc0
BLAKE2b-256 792031ff8bec97ab8f226f83d70b0d320ade8ea15e97fe1f7b1f204e884450b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: streamlabsio-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.7 Windows/11

File hashes

Hashes for streamlabsio-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6b9910561505af1d93b6c1cc6550abb244f771613ac0d22cc7639b3f9bb082c6
MD5 577d531d14ccc9c90629b728f2730064
BLAKE2b-256 4c16ef8f6ee1c77d809465169bc553138ca433a3fb812b66b736de7351cb5543

See more details on using hashes here.

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