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.0.tar.gz (12.1 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.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pubq-1.2.0.tar.gz
  • Upload date:
  • Size: 12.1 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.0.tar.gz
Algorithm Hash digest
SHA256 c9e737a181da3b5b8bd0442381d8da9fec28e3a6d62b488a83153f0f4c7a2ebe
MD5 c3da26518558f67d3e2a7c1619fb86b1
BLAKE2b-256 03ecd9ade160ecdbb924338ab634a85808191f71999f833974c2a4332dbe5a67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pubq-1.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b33104457ee625ad68442b663146ae03e749df67d2c43a76136e43e5e0161755
MD5 1b92737557f30f65fa3e594c59947584
BLAKE2b-256 c6089636cb1a9f414d21d1ded099a4869d04d1d97603c7afbde1ce0516b40858

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