Last updated:
0 purchases
pubq 1.2.1
PUBQ Python SDK
PUBQ 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.
Getting Started
Follow these steps to just start building with PUBQ in Python or see the Quickstart guide which covers more programming languages.
Install with package manager
The Python SDK is available as PyPI package:
pip install pubq
Interacting with PUBQ
Get your application id and key from PUBQ dashboard by creating a new app or use existing one.
Connect to PUBQ:
import asyncio
from pubq import Pubq
async def main():
def on_connected(state):
print("Connected to PUBQ!")
realtime = Pubq.RealTime({"key": "YOUR_API_KEY"})
realtime.connection.on("connected", on_connected)
asyncio.run(main())
Subscribe a channel and listen for any data publish to receive:
def on_message(msg):
print("Received new data: " + str(msg.data))
channel = realtime.channels.get("my-channel")
channel.subscribe(on_message)
Publish a message:
channel.publish("Hello!")
Publish a message with REST interface:
import asyncio
from pubq import Pubq
async def main():
rest = Pubq.REST({"key": "YOUR_API_KEY"})
channel = rest.channels.get("my-channel")
channel.publish("Hello!")
asyncio.run(main())
Development
Please, read the contribution guide.
Setup
git clone [email protected]:pubqio/pubq-python.git
cd ./pubq-python/
poetry install
Build
poetry build
Tests
To run tests using pytest:
poetry run pytest
Example
To run pubsub example:
cd examples/
python pubsub.py
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.