Metadata-Version: 2.1
Name: pubq
Version: 1.0.0
Summary: PUBQ Python SDK
Home-page: https://pubq.io
License: MIT
Author: PUBQ Team
Author-email: dev@pubq.io
Maintainer: PUBQ Team
Maintainer-email: dev@pubq.io
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 6 - Mature
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: pyee (>=11.0.0,<12.0.0)
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: socketclusterclient (>=1.3.6,<2.0.0)
Project-URL: Documentation, https://github.com/pubqio/pubq-python
Project-URL: Repository, https://github.com/pubqio/pubq-python
Description-Content-Type: text/markdown

# PUBQ Python SDK

[PUBQ](https://pubq.io) is a pub/sub channels cloud and this is the official Python client library including both real-time and REST interfaces.

To meet PUBQ and see more info and examples, please read the [documentation](https://pubq.io/docs).

# Getting Started

Follow these steps to just start building with PUBQ in Python or see the [Quickstart guide](https://pubq.io/docs/getting-started/quickstart) which covers more programming languages.

## Install with package manager

The Python SDK is available as PyPI package:

```bash
pip install pubq
```

## Interacting with PUBQ

Get your application id and key from [PUBQ dashboard](https://dashboard.pubq.io) by [creating a new app](https://dashboard.pubq.io/applications/create) or use existing one.

Connect to PUBQ:

```python
import asyncio
from pubq.realtime import RealTime

def onConnect(socket):
    print("Connected to PUBQ!")

async def main():

    realtime = RealTime("YOUR_APPLICATION_ID", "YOUR_APPLICATION_KEY")
    realtime.emitter.add_listener("connect", onConnect)

asyncio.run(main())
```

Subscribe a channel and listen for any data publish to receive::

```python
realtime.subscribe('my-channel', onChannelMessage)

def onChannelMessage(channel, data):
    print("Received new data: '" + str(data))
```

Publish a message with REST interface:

```python
from pubq.rest import REST

if __name__ == "__main__":
    rest = REST(
        "YOUR_APPLICATION_ID",
        "YOUR_APPLICATION_KEY",
        "YOUR_APPLICATION_SECRET"
    );

    rest.publish("my-channel", "Hello!");
```

# Development

Please, read the [contribution guide](https://pubq.io/docs/basics/contribution).

## Setup

```bash
git clone git@github.com:pubqio/pubq-python.git
cd ./pubq-python/
poetry install
```

## Tests

To run tests using pytest:

```bash
poetry run pytest
```

