High-performance Python HTTP server SDK for Sockudo
Project description
Sockudo Python HTTP Server SDK
High-performance Python server SDK for the Sockudo HTTP API. It publishes events, signs channel and user authentication payloads, validates webhooks, queries channel state, reads durable history, mutates versioned messages, and manages annotations.
Features
- Sync and asyncio clients:
SockudoandAsyncSockudo - Persistent HTTP connection pooling via
httpx, with HTTP/2 enabled by default - Pusher-compatible signed REST requests
- Single, multi-channel, and batch publishing
- Explicit and automatic idempotency keys for safe publish retries
- Private, presence, user, and webhook authentication helpers
- Channel state, presence users, durable history, and presence history APIs
- Versioned message APIs: get, versions, update, delete, append
- Annotation APIs: publish, list, delete
- Operator controls for history reset/purge and presence-history reset
- End-to-end encrypted channel auth, publish, batch publish, and webhook decrypt support for
private-encrypted-*channels
Install
For apps, install the published package:
pip install sockudo-http-python
For local monorepo development, install from the local path:
git clone https://github.com/sockudo/sockudo.git
pip install -e sockudo/server-sdks/sockudo-http-python
For local development from this monorepo:
pip install -e server-sdks/sockudo-http-python[dev]
Quick Start
from sockudo_http import Config, Sockudo
sockudo = Sockudo(Config(app_id="app-id", key="app-key", secret="app-secret", host="127.0.0.1", port=6001))
result = sockudo.trigger("orders", "order.created", {"id": "ord_123"})
assert result.ok
sockudo.close()
Async:
from sockudo_http_python import AsyncSockudo, SockudoOptions
async with AsyncSockudo(
"app-id",
"app-key",
"app-secret",
options=SockudoOptions(host="127.0.0.1", port=6001),
) as sockudo:
await sockudo.trigger("orders", "order.created", {"id": "ord_123"})
Idempotent Publishing
from sockudo_http_python import TriggerOptions
sockudo.trigger(
"orders",
"order.created",
{"id": "ord_123"},
TriggerOptions(idempotency_key="order-created-ord_123"),
)
sockudo.trigger("orders", "order.created", {"id": "ord_124"}, TriggerOptions(idempotency_key=True))
Set SockudoOptions(auto_idempotency=True) to generate keys for publish and batch publish calls that omit one.
Target a single user channel:
sockudo.send_to_user("user-123", "notice", {"body": "hello"})
Authentication Helpers
from sockudo_http_python import PresenceUser
private_body = sockudo.authenticate("123.456", "private-orders")
presence_body = sockudo.authenticate(
"123.456",
"presence-room",
PresenceUser("user-1", {"name": "Ada"}),
)
user_body = sockudo.authenticate_user("123.456", {"id": "user-1", "name": "Ada"})
Encrypted channel auth responses include shared_secret when encryption_master_key_base64 is configured:
encrypted = Sockudo(
"app-id",
"app-key",
"app-secret",
encryption_master_key_base64="base64-encoded-32-byte-key",
)
body = encrypted.authenticate("123.456", "private-encrypted-room")
Channel And History APIs
from sockudo_http_python import ChannelsParams, HistoryParams, PresenceHistoryParams
sockudo.list_channels(ChannelsParams(filter_by_prefix="presence-", info=["subscription_count", "user_count"]))
sockudo.get_channel_users("presence-room")
sockudo.get_channel_history("orders", HistoryParams(limit=50, direction="newest_first"))
sockudo.get_channel_presence_history("presence-room", PresenceHistoryParams(limit=50))
Versioned Messages And Annotations
from sockudo_http_python import MessageMutation, PublishAnnotationRequest
sockudo.get_message("orders", "msg:1")
sockudo.get_message_versions("orders", "msg:1")
sockudo.update_message("orders", "msg:1", MessageMutation(data={"status": "paid"}))
sockudo.append_message("orders", "msg:1", " appended text")
sockudo.delete_message("orders", "msg:1", MessageMutation(description="moderated"))
sockudo.publish_annotation(
"orders",
"msg:1",
PublishAnnotationRequest(type="reactions:distinct.v1", name="like", client_id="user-1", count=1),
)
sockudo.list_annotations("orders", "msg:1")
Webhooks
validity = sockudo.validate_webhook_signature(x_pusher_key, x_pusher_signature, raw_body)
webhook = sockudo.parse_webhook(x_pusher_key, x_pusher_signature, raw_body)
If a webhook contains encrypted channel events and the client has an encryption master key, parse_webhook decrypts those event payloads.
Signed URIs
uri = sockudo.signed_uri("GET", "/apps/app-id/channels", parameters={"filter_by_prefix": "presence-"})
The signing format matches Sockudo/Pusher REST auth: auth_key, auth_timestamp, auth_version, optional body_md5, and auth_signature over {METHOD}\n{PATH}\n{SORTED_QUERY}.
URL Configuration
sockudo = Sockudo.from_url("http://app-key:app-secret@127.0.0.1:6001/apps/app-id")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sockudo_http_python-2.0.0.tar.gz.
File metadata
- Download URL: sockudo_http_python-2.0.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60d00deb38fce923ccbb561d4dbea14c1dd7f994dca533b5aa3335be050311bd
|
|
| MD5 |
0ecdf2d1d112cf6e273d3d400328bcd9
|
|
| BLAKE2b-256 |
404108b7b229d12ea1a68148c2d3a562c0368c0eb98ac723729ad2b71ceb8557
|
Provenance
The following attestation bundles were made for sockudo_http_python-2.0.0.tar.gz:
Publisher:
sdk-release.yml on sockudo/sockudo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sockudo_http_python-2.0.0.tar.gz -
Subject digest:
60d00deb38fce923ccbb561d4dbea14c1dd7f994dca533b5aa3335be050311bd - Sigstore transparency entry: 1892683615
- Sigstore integration time:
-
Permalink:
sockudo/sockudo@ff3d5f949f336b46c538c85b2ad91d7b9d862e97 -
Branch / Tag:
refs/tags/server-python-v2.0.0 - Owner: https://github.com/sockudo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@ff3d5f949f336b46c538c85b2ad91d7b9d862e97 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sockudo_http_python-2.0.0-py3-none-any.whl.
File metadata
- Download URL: sockudo_http_python-2.0.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3f4ae5ef9b1f541b9eba885eb0233c05e94d9e2d881eb8f3a234b9556fc08b9
|
|
| MD5 |
a07966ff6851bf1df885ad8860e2d4af
|
|
| BLAKE2b-256 |
d27a2cce777d4c0598f3d897e04ed02b6259a4c435a51d0cda4b2aa5d22d4d75
|
Provenance
The following attestation bundles were made for sockudo_http_python-2.0.0-py3-none-any.whl:
Publisher:
sdk-release.yml on sockudo/sockudo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sockudo_http_python-2.0.0-py3-none-any.whl -
Subject digest:
b3f4ae5ef9b1f541b9eba885eb0233c05e94d9e2d881eb8f3a234b9556fc08b9 - Sigstore transparency entry: 1892683734
- Sigstore integration time:
-
Permalink:
sockudo/sockudo@ff3d5f949f336b46c538c85b2ad91d7b9d862e97 -
Branch / Tag:
refs/tags/server-python-v2.0.0 - Owner: https://github.com/sockudo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@ff3d5f949f336b46c538c85b2ad91d7b9d862e97 -
Trigger Event:
push
-
Statement type: