The Python SDK targets CPython 3.9+ and mirrors the ergonomics of the Node and Rust clients. It opens a persistent TCP control connection to the EventDBX control socket, performs a Noise XX handshake by default, and exchanges Cap’n Proto messages for aggregate reads/writes.Documentation Index
Fetch the complete documentation index at: https://docs.eventdbx.com/llms.txt
Use this file to discover all available pages before exploring further.
Feature highlights
- Synchronous TCP client that speaks the same Cap’n Proto control protocol as
eventdbxjs. - Noise XX (+ PSK) transport enabled by default; opt out with
no_noise=True/EVENTDBX_NO_NOISE=1for test labs. - Mutation helpers for
create,apply,patch,archive, andrestore, plus per-call publish target routing. - Read helpers for
list,events,get,select, andverifywith pagination and sorting. - Snapshot and schema/tenant admin helpers (
create_snapshot,list_snapshots,tenant_schema_publish,tenant_assign, quotas, etc.).
Install
pycapnp depends on Cap’n Proto system libraries. Install them first
(brew install capnp on macOS or apt-get install capnproto libcapnp-dev
on Debian/Ubuntu) before running pip install.Connect and configure
EventDBXClient performs the handshake during construction and is a context manager; exit the block to close the socket. payload_json and metadata_json accept serialized JSON strings. When verbose=True (default) mutation methods return stored JSON blobs; set verbose=False to receive boolean acknowledgements.
Runtime configuration
| Variable | Default | Description |
|---|---|---|
EVENTDBX_HOST | 127.0.0.1 | Hostname or IP address of the control socket. |
EVENTDBX_PORT | 6363 | TCP port for the control plane. |
EVENTDBX_TOKEN | empty | Control token; required when constructing the client. |
EVENTDBX_TENANT_ID | empty | Tenant identifier included in the initial hello. |
EVENTDBX_NO_NOISE | false | Set 1/true to request plaintext transport (testing only). |
EventDBXClient as shown above. Only EVENTDBX_NO_NOISE is read automatically when no_noise is omitted.
Manage authentication and tenancy
Tokens and tenant identifiers are required when constructing the client. Create separate client instances per tenant or per control token. The same socket is reused for all calls until the context exits orclose() is invoked.
Retry configuration
Transport-level failures (socket resets, Cap’n Proto decode errors, etc.) can be retried automatically. Retries are disabled by default (attempts = 1); opt in by passing retry:
Publish targets
Select which plugins receive a write, override payload mode, and bump priority per call:publish_targets to fan out to every enabled plugin using their configured payload mode.
Write aggregates and events
create seeds a snapshot and first event atomically, apply appends events, patch issues RFC 6902 operations against historical payloads, and archive/restore toggle write access while preserving history.
Read aggregates and events
next_cursor to resume pagination. list returns aggregate snapshots; events returns full envelopes.
Filters, sorting, and pagination
Filters use the same SQL-like grammar as the server (field = value AND other_field > 10). Sort fields accept names such as aggregate_id, aggregate_type, version, created_at, updated_at, and archived. You can pass a string ("created_at:desc,aggregate_id:asc") or a list of AggregateSortOption objects. When sorting by timestamps, shorthand cursors (ts:<aggregate_type>:<aggregate_id>) can be used with cursor.
Snapshots and admin helpers
- Snapshots:
create_snapshot,list_snapshots, andget_snapshothandle point-in-time copies. - Schema & tenant admin:
list_schemas/replace_schemas,tenant_schema_publish,tenant_assign/tenant_unassign, and quota helpers wrap control-plane maintenance flows.
Noise transport
Noise XX with a token-derived PSK is enabled by default. Disable it only for controlled testing by passingno_noise=True (or setting EVENTDBX_NO_NOISE). Production deployments should keep Noise on.
Development & testing
pycapnp fails to build, install the Cap’n Proto toolchain first and retry the pip install.