pubsub-sdk-python
Python SDK for the STACKIT PubSub Data Plane API.
This SDK covers the data plane only (publish, pull, ack, nack). Creating/deleting topics and subscriptions, and granting publisher/subscriber access, is done via the separate STACKIT PubSub control plane REST API (see tests/integration/conftest.py for example calls) or the STACKIT Portal.
Install
Not published to PyPI yet — every GitHub Release publishes pubsub-sdk-python to PyPI automatically (see .github/workflows/release.yml), so once a release is cut:
pip install pubsub-sdk-python
# or: uv add pubsub-sdk-python
Until then, install from source with uv:
uv sync --group dev
uv pip install -e .
Requires Python >= 3.11. Runtime dependencies: httpx, stackit-authorization.
Auth
Authentication goes through AuthConfig + StackitAuthProvider, backed by a STACKIT service account key.
from pubsub_sdk_python import AuthConfig, PubSubClient
auth_config = AuthConfig(
service_account_key=open("sa-key.json").read(), # or the raw JSON string
token_endpoint="https://authorization.stackit.cloud/auth/token", # default shown
)
AuthConfig fields: service_account_key, token_endpoint (default https://authorization.stackit.cloud/auth/token), client_id, client_secret, scope (default "dataplane"). Tokens are fetched via stackit-authorization and cached until ~60s before expiry.
Quickstart
import asyncio
from pubsub_sdk_python import PubSubClient, PublishMessage
async def main():
client = PubSubClient(topic_id="<topic-id>", auth_config=auth_config)
async with client.get_publisher() as publisher:
await publisher.publish([PublishMessage.from_plain("hello")])
async with client.get_subscriber(subscription_id="<subscription-id>") as subscriber:
messages = await subscriber.pull(max_messages=10)
for msg in messages:
print(msg.text) # base64-decoded payload
await subscriber.ack([msg.ack_id for msg in messages])
# or: await subscriber.ack_messages(messages)
asyncio.run(main())
client.base_url defaults to https://{topic_id}.pubsub.eu01.onstackit.cloud; pass base_url= to PubSubClient(...) to override (e.g. for other regions/environments).
PublishMessage.from_plain(str) / .from_bytes(bytes) base64-encode the payload. Message.payload (bytes) / Message.text (str) base64-decode it back.
Both PubSubPublisher and PubSubSubscriber support async with, and expose call counters: publisher.messages_sent / .publish_calls / .purge_calls / .messages_purged, subscriber.messages_received / .messages_acked / .messages_nacked / .pull_calls / .ack_calls / .nack_calls.
Other methods: publisher.publish_batch(messages, batch_size=100), publisher.purge_topic() / .purge_topic_with_confirm("purge"), subscriber.pull_stream(on_message=callback), subscriber.nack(...) / .nack_messages(...).
Errors
All exceptions subclass PubSubError:
| Exception | Raised when |
|---|---|
PubSubValidationError |
Bad request (HTTP 400/413), or local validation (empty message list, >100 messages, max_messages/long_pull_duration_ms out of range, empty ack/nack list) |
PubSubNotFoundError |
HTTP 404 |
PubSubAuthenticationError |
HTTP 401/403, or token acquisition failure |
PubSubServerError |
HTTP 5xx (transient - triggers a retry, see below) |
PubSubRetryError |
All retry attempts exhausted; .causes holds the underlying exceptions |
PubSubTimeoutError |
Request timed out (also a TimeoutError) |
Retries
PubSubPublisher/PubSubSubscriber retry automatically on network/timeout errors (httpx.TimeoutException, httpx.NetworkError, OSError, ConnectionError, TimeoutError) and HTTP 500/502/503/504, with exponential backoff + jitter. Configure via retry_config=RetryConfig(...) passed to the publisher/subscriber constructor (or get_publisher()/get_subscriber() kwargs):
from pubsub_sdk_python import RetryConfig
retry_config = RetryConfig(max_retries=3, base_delay=0.5, max_delay=30.0, multiplier=2.0)
400/401/404/413 are never retried. The standalone decorators with_retry/with_async_retry (in pubsub_sdk_python.retry) apply the same policy to arbitrary functions.
Metadata
Release files for pubsub-sdk-python 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pubsub_sdk_python-0.1.0.tar.gz | 110.4 kB | With provenance | Details for pubsub_sdk_python-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pubsub_sdk_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pubsub_sdk_python-0.1.0-py3-none-any.whl |
Total release size: 135.2 kB
Release files / pubsub_sdk_python-0.1.0.tar.gz
| Download URL | pubsub_sdk_python-0.1.0.tar.gz |
|---|---|
| Size | 110.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b463548e7e5822d430a81c8ce5a7281c9f47f863266d7164623f17345fde69b2
|
|
BLAKE2b-256 checksum How to use checksums |
ac9d476101aeef471901c7bacdd2d1e977fd0a69a3fa8890537df0b8bd4fd464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / pubsub_sdk_python-0.1.0-py3-none-any.whl
| Download URL | pubsub_sdk_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2335fadb041d48d8a0651d58a3dd1392fbcfff4204cea656301679183e22f0b
|
|
BLAKE2b-256 checksum How to use checksums |
08590064202282dea66953481b2ea156be7844d0be2f8786ca88341568bc80ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for pubsub-sdk-python 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pubsub_sdk_python-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.