Typed Python client for the Detent rate-limiting API.
Project description
detent-sdk
Typed Python client for the Detent rate-limiting API. Sync and async, one dependency (httpx).
pip install detent-sdk
Usage
from detent import Detent
rg = Detent(api_key="rg_live_...")
# Rate-limit check (fails open by default on transport error or 5xx)
r = rg.limit(namespace="api", key=user_id)
if not r.allowed:
... # return HTTP 429
# Concurrent-limit lease (auto-released)
with rg.lease(namespace="jobs", key=user_id):
run_expensive_job()
# Read-only usage stats
stats = rg.get_stats(namespace="api")
Async
from detent import AsyncDetent
async with AsyncDetent(api_key="rg_live_...") as rg:
r = await rg.limit(namespace="api", key=user_id)
async with rg.lease(namespace="jobs", key=user_id):
await run_expensive_job()
Configuration
| Option | Default | Notes |
|---|---|---|
api_key |
— (required) | rg_live_… / rg_test_… |
base_url |
https://api.detent.dev |
Override for self-host / tests |
timeout |
1.0 |
Seconds; client-side transport timeout |
fail_mode |
"open" |
"open" allows, "closed" denies on a degraded backend |
on_error |
None |
Called on a degraded (transport/5xx) limit() call |
limit() never raises on a degraded backend (transport error or 5xx) — it
returns a result with degraded=True. A 4xx (bad key, plan gate, unknown
rule) raises DetentAPIError.
Project details
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 detent_sdk-0.1.0.tar.gz.
File metadata
- Download URL: detent_sdk-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
421b5ad16c29a4aa342fce0981801697039aa9faddb709b13fbb8f95d913f675
|
|
| MD5 |
db9ddb565732b93651e390bdc36addfd
|
|
| BLAKE2b-256 |
26ae67b9a0263844fed021ec183290abe1f13da8acca7db710380b855d3faabf
|
Provenance
The following attestation bundles were made for detent_sdk-0.1.0.tar.gz:
Publisher:
release.yml on cguillerminet/detent-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
detent_sdk-0.1.0.tar.gz -
Subject digest:
421b5ad16c29a4aa342fce0981801697039aa9faddb709b13fbb8f95d913f675 - Sigstore transparency entry: 2046577520
- Sigstore integration time:
-
Permalink:
cguillerminet/detent-sdk-python@b028fb520fc80dc5cca8bcbcc4f9784c241eeeea -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/cguillerminet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b028fb520fc80dc5cca8bcbcc4f9784c241eeeea -
Trigger Event:
push
-
Statement type:
File details
Details for the file detent_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: detent_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 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 |
d0b331dc450f0788718747d73f8f5c41d93efa200c5a7c53c91d10e6b2aa6b97
|
|
| MD5 |
27e1ab346687b0852f0f68a03d8f70f8
|
|
| BLAKE2b-256 |
4ce53bad8481c1f554f5ce9991a33c0d00ad53ee9b77eaf4b4cd19f7b35d7024
|
Provenance
The following attestation bundles were made for detent_sdk-0.1.0-py3-none-any.whl:
Publisher:
release.yml on cguillerminet/detent-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
detent_sdk-0.1.0-py3-none-any.whl -
Subject digest:
d0b331dc450f0788718747d73f8f5c41d93efa200c5a7c53c91d10e6b2aa6b97 - Sigstore transparency entry: 2046577968
- Sigstore integration time:
-
Permalink:
cguillerminet/detent-sdk-python@b028fb520fc80dc5cca8bcbcc4f9784c241eeeea -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/cguillerminet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b028fb520fc80dc5cca8bcbcc4f9784c241eeeea -
Trigger Event:
push
-
Statement type: