Skip to main content

Get real time Twitch/Youtube events through Streamlabs SocketIO API

Project description

PyPI version License: MIT Code style: black Imports: isort

A Python client for Streamlabs SocketIO API

Requirements

  • A Streamlabs SocketIO API key.
    • You can acquire this by logging into your Streamlabs.com dashboard then Settings->Api Settings->API Tokens

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, msg):
    print(f"{event}: {msg.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.

Attributes

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

example:

def on_twitch_event(event, msg):
    print(f"{event}: {msg.attrs()}")

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-0.1.2.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

streamlabsio-0.1.2-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

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