Get up and running with the OpenDecree Python SDK in under 5 minutes.
pip install opendecreeYou need a running OpenDecree server (v0.3.0+). For local development:
# In the decree repo
docker compose up -dThe server defaults to localhost:9090 with no authentication required.
from opendecree import ConfigClient
with ConfigClient("localhost:9090", subject="myapp") as client:
fee = client.get("tenant-id", "payments.fee")
print(fee) # "0.5%"The with block manages the gRPC connection — it opens on enter and closes on exit.
Pass a type argument to get() for automatic conversion:
with ConfigClient("localhost:9090", subject="myapp") as client:
retries = client.get("tenant-id", "payments.retries", int) # → int
enabled = client.get("tenant-id", "payments.enabled", bool) # → bool
rate = client.get("tenant-id", "payments.fee_rate", float) # → floatSupported types: str (default), int, float, bool, timedelta.
with ConfigClient("localhost:9090", subject="myapp") as client:
client.set("tenant-id", "payments.fee", "0.5%")
# Bulk writes
client.set_many("tenant-id", {"a": "1", "b": "2"}, description="batch update")
# Set to null
client.set_null("tenant-id", "payments.fee")with ConfigClient("localhost:9090", subject="myapp") as client:
with client.watch("tenant-id") as watcher:
fee = watcher.field("payments.fee", float, default=0.01)
print(fee.value) # current value, always fresh
@fee.on_change
def on_fee_change(old: float, new: float):
print(f"Fee changed: {old} -> {new}")See Watching for more patterns.
All APIs have async equivalents:
from opendecree import AsyncConfigClient
async with AsyncConfigClient("localhost:9090", subject="myapp") as client:
fee = await client.get("tenant-id", "payments.fee")
retries = await client.get("tenant-id", "payments.retries", int)See Async Usage for the full async API.
from opendecree import ConfigClient, NotFoundError, LockedError
with ConfigClient("localhost:9090", subject="myapp") as client:
try:
val = client.get("tenant-id", "nonexistent.field")
except NotFoundError:
print("Field not found")
except LockedError:
print("Field is locked")- Configuration — all client options (auth, TLS, retry, timeouts)
- Watching — live subscriptions and change patterns
- Async Usage — async client and watcher
- OpenDecree concepts — schemas, typed values, versioning