Get real time Twitch/Youtube events through Streamlabs SocketIO API
Project description
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
- You can acquire this by logging into your Streamlabs.com dashboard then
-
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 json objects.
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for streamlabsio-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c68fd017c512d8ab67c5fc4708363f43738ecdf421c8916c958f4213946472 |
|
MD5 | 473748110e719c39a6cb78adcfce0f45 |
|
BLAKE2b-256 | 174cb6f8d533f6e2705d38533247f0e4254a724b382a432e74841df479c81765 |