Skip to content

Python SDK

detent-sdk is the official Python client for Detent. Source on GitHub.

Terminal window
pip install detent-sdk
from detent import Detent
detent = Detent(api_key=os.environ["DETENT_KEY"])
from detent import Detent
detent = Detent(api_key=os.environ["DETENT_KEY"])
verdict = detent.limit(
namespace="checkout", key="user_42",
algorithm="sliding_window", limit=100, window_ms=60_000,
)

limit() takes namespace=, key=, algorithm=, limit=, window_ms= keyword arguments and returns a verdict with allowed, remaining, reset_ms, and limit — see fail-open & the verdict model for what the fields mean and how /v1/limit behaves during an outage.

An async client is also available for use with asyncio-based apps (e.g. FastAPI) alongside the sync Detent client shown above.