Skip to main content

PUBQ Python SDK

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pubq-1.2.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pubq-1.2.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file pubq-1.2.1.tar.gz.

File metadata

  • Download URL: pubq-1.2.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

File hashes

Hashes for pubq-1.2.1.tar.gz
Algorithm Hash digest
SHA256 7276f35693851faf50b22270ab5190a1b9e06950855ab18a12c496aaec851cf8
MD5 6fb239fb877a01ccdfb46eb990d267e9
BLAKE2b-256 e3940eb241d511714d6f46ed85083dcdf81ffd2528942c76eb2143b6503b5e81

See more details on using hashes here.

File details

Details for the file pubq-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: pubq-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0

File hashes

Hashes for pubq-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e77297a1fdd5895401eb54bfc4d5bc5ddc436142e1f80e019bc40921897f21c
MD5 f9607117d0283068915775516cbfcacf
BLAKE2b-256 f09974a60fc4b2c36e21d75b5571e2eece93b7989ba6a5b430a9d1e1c8c2327e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page