Skip to main content

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 git@github.com: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

Metadata

Release files for pubq 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pubq 1.2.1
File Size Uploaded
pubq-1.2.1.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pubq 1.2.1
File Interpreter ABI Platform
pubq-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.5 kB

Release files / pubq-1.2.1.tar.gz

Download URL pubq-1.2.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7276f35693851faf50b22270ab5190a1b9e06950855ab18a12c496aaec851cf8
BLAKE2b-256 checksum
How to use checksums
e3940eb241d511714d6f46ed85083dcdf81ffd2528942c76eb2143b6503b5e81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

Release files / pubq-1.2.1-py3-none-any.whl

Download URL pubq-1.2.1-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e77297a1fdd5895401eb54bfc4d5bc5ddc436142e1f80e019bc40921897f21c
BLAKE2b-256 checksum
How to use checksums
f09974a60fc4b2c36e21d75b5571e2eece93b7989ba6a5b430a9d1e1c8c2327e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page