streamlabsio


Namestreamlabsio JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/onyx-and-iris/streamlabs-socketio-py
SummaryGet real time Twitch/Youtube events through Streamlabs SocketIO API
upload_time2023-08-19 20:59:31
maintainer
docs_urlNone
authoronyx-and-iris
requires_python>=3.8,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/streamlabsio.svg)](https://badge.fury.io/py/streamlabsio)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/streamlabs-socketio-py/blob/dev/LICENSE)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](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": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "onyx-and-iris",
    "author_email": "code@onyxandiris.online",
    "download_url": "https://files.pythonhosted.org/packages/20/34/adea31ed53d86ebab558139013304f6c12c7e8265a6edcf186ca6c88c38c/streamlabsio-1.1.1.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/streamlabsio.svg)](https://badge.fury.io/py/streamlabsio)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/streamlabs-socketio-py/blob/dev/LICENSE)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](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.1",
    "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": "078e935f113c19d1cf1685f2f03fd71f7239bb0712c34fb13741fab7cc171878",
                "md5": "91880c15904024d41c2acad30fcc3b81",
                "sha256": "18c246e63ec8ca00d3201c5089b94917f80273f0bb25b87891417807c274f536"
            },
            "downloads": -1,
            "filename": "streamlabsio-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91880c15904024d41c2acad30fcc3b81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5651,
            "upload_time": "2023-08-19T20:59:29",
            "upload_time_iso_8601": "2023-08-19T20:59:29.762912Z",
            "url": "https://files.pythonhosted.org/packages/07/8e/935f113c19d1cf1685f2f03fd71f7239bb0712c34fb13741fab7cc171878/streamlabsio-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2034adea31ed53d86ebab558139013304f6c12c7e8265a6edcf186ca6c88c38c",
                "md5": "18bffb8b56b722300910ed0abd0de82a",
                "sha256": "eac87ed3f19f26865612d2fe4455acb3e01028f194fae80f885d1aba099550cf"
            },
            "downloads": -1,
            "filename": "streamlabsio-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "18bffb8b56b722300910ed0abd0de82a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4792,
            "upload_time": "2023-08-19T20:59:31",
            "upload_time_iso_8601": "2023-08-19T20:59:31.291461Z",
            "url": "https://files.pythonhosted.org/packages/20/34/adea31ed53d86ebab558139013304f6c12c7e8265a6edcf186ca6c88c38c/streamlabsio-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-19 20:59:31",
    "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"
}
        
Elapsed time: 0.10399s