[](https://badge.fury.io/py/streamlabsio)
[](https://github.com/onyx-and-iris/streamlabs-socketio-py/blob/dev/LICENSE)
[](https://python-poetry.org/)
[](https://github.com/psf/black)
[](https://pycqa.github.io/isort/)
# A Python client for Streamlabs Socket API
For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
### 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:
```toml
[streamlabs]
token = "<apikey>"
```
Place it next to your `__main__.py` file.
#### Otherwise:
You may pass it as a keyword argument.
Example `__main__.py`:
```python
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](https://python-socketio.readthedocs.io/en/latest/client.html#managing-background-tasks), `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:
```python
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
- [Streamlabs Socket API](https://dev.streamlabs.com/docs/socket-api)
Raw data
{
"_id": null,
"home_page": "https://github.com/onyx-and-iris/streamlabs-socketio-py",
"name": "streamlabsio",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "onyx-and-iris",
"author_email": "code@onyxandiris.online",
"download_url": "https://files.pythonhosted.org/packages/c5/e5/04f100b1cc5ee6bec09ae886798645f8e338313bcb3fa99e6a8fa793608b/streamlabsio-1.1.2.tar.gz",
"platform": null,
"description": "[](https://badge.fury.io/py/streamlabsio)\n[](https://github.com/onyx-and-iris/streamlabs-socketio-py/blob/dev/LICENSE)\n[](https://python-poetry.org/)\n[](https://github.com/psf/black)\n[](https://pycqa.github.io/isort/)\n\n# A Python client for Streamlabs Socket API\n\nFor an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)\n\n### Requirements\n\n- A Streamlabs Socket API key.\n - You can acquire this by logging into your Streamlabs.com dashboard then `Settings->Api Settings->API Tokens`\n\n- Python 3.8 or greater\n\n### How to install using pip\n\n```\npip install streamlabsio\n```\n\n### How to Use\n\nYou may store your api key in a `config.toml` file, its contents should resemble:\n\n```toml\n[streamlabs]\ntoken = \"<apikey>\"\n```\n\nPlace it next to your `__main__.py` file.\n\n#### Otherwise:\n\nYou may pass it as a keyword argument.\n\nExample `__main__.py`:\n\n```python\nimport streamlabsio\n\n\ndef on_twitch_event(event, data):\n print(f\"{event}: {data.attrs()}\")\n\n\ndef main():\n with streamlabsio.connect(token=\"<apikey>\") as client:\n client.obs.on(\"streamlabs\", on_twitch_event)\n client.obs.on(\"twitch_account\", on_twitch_event)\n\n # run for 30 seconds then disconnect client from server\n client.sio.sleep(30)\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n#### note\n\nFrom the [SocketIO docs](https://python-socketio.readthedocs.io/en/latest/client.html#managing-background-tasks), `client.sio.wait()` may be used if your application has nothing to do in the main thread.\n\n### Client class\n`streamlabsio.connect(token=\"<apikey>\", raw=False)`\n\nThe following keyword arguments may be passed:\n\n- `token`: str Streamlabs SocketIO api token.\n- `raw`: boolean=False Receive raw data messages as json objects.\n\nThe following attribute is available:\n\n- `raw`: boolean Toggle raw mode at runtime.\n\n### Attributes\n\nFor event data you may inspect the available attributes using `attrs()`.\n\nexample:\n\n```python\ndef on_twitch_event(event, data):\n print(f\"{event}: {data.attrs()}\")\n```\n\n### Errors\n\n- `SteamlabsSIOError`: Base StreamlabsSIO error class\n- `SteamlabsSIOConnectionError`: Exception raised when connection errors occur\n\n### Logging\n\nTo view raw incoming event data set logging level to DEBUG. Check `debug` example.\n\n### Official Documentation\n\n- [Streamlabs Socket API](https://dev.streamlabs.com/docs/socket-api)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Get real time Twitch/Youtube events through Streamlabs SocketIO API",
"version": "1.1.2",
"project_urls": {
"Homepage": "https://github.com/onyx-and-iris/streamlabs-socketio-py",
"Repository": "https://github.com/onyx-and-iris/streamlabs-socketio-py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0677173fabf7087423aa455eb9134a28fbe3271753d5959c51d45808bf0ab56e",
"md5": "3528568a90f17f9980167a6a8faa982c",
"sha256": "9beb3ec315829fbd27316a39fa86ab1ca2eb0b437572effa21203af561541df9"
},
"downloads": -1,
"filename": "streamlabsio-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3528568a90f17f9980167a6a8faa982c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 5653,
"upload_time": "2024-11-06T16:57:56",
"upload_time_iso_8601": "2024-11-06T16:57:56.023559Z",
"url": "https://files.pythonhosted.org/packages/06/77/173fabf7087423aa455eb9134a28fbe3271753d5959c51d45808bf0ab56e/streamlabsio-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c5e504f100b1cc5ee6bec09ae886798645f8e338313bcb3fa99e6a8fa793608b",
"md5": "fcf5cf98b09e2e2d56039c42bc2a607f",
"sha256": "32c9aec23f3584769bcbf08536e9566260a4cdaabedcd646082c0a6f51e5743c"
},
"downloads": -1,
"filename": "streamlabsio-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "fcf5cf98b09e2e2d56039c42bc2a607f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 4827,
"upload_time": "2024-11-06T16:57:56",
"upload_time_iso_8601": "2024-11-06T16:57:56.970220Z",
"url": "https://files.pythonhosted.org/packages/c5/e5/04f100b1cc5ee6bec09ae886798645f8e338313bcb3fa99e6a8fa793608b/streamlabsio-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-06 16:57:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "onyx-and-iris",
"github_project": "streamlabs-socketio-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "streamlabsio"
}