Skip to main content

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="dt_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="dt_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) dt_live_… / dt_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

detent_sdk-0.1.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detent_sdk-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file detent_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: detent_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detent_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e12a5955646d64c6bd225df275b55e559cc8fb7a94cd43b89fde26dfba83db7e
MD5 a0fc67c8699da9b621c17de655c44738
BLAKE2b-256 0ef09d75b8705d2e313f7116991c1fd38ac06f32401e13bcabb0476c015aa53f

See more details on using hashes here.

Provenance

The following attestation bundles were made for detent_sdk-0.1.1.tar.gz:

Publisher: release.yml on cguillerminet/detent-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file detent_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: detent_sdk-0.1.1-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

Hashes for detent_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e1a585af39cdfcc9ec04a07573cd9e40f41bc5b4ab9dd09000571a100581e6b
MD5 f18f935757b966da164beb28f744acad
BLAKE2b-256 4a3b4fd51281c16a7bcf33d7cbeca574406990d215b085eaa4399169ec9ad9a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for detent_sdk-0.1.1-py3-none-any.whl:

Publisher: release.yml on cguillerminet/detent-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page