Skip to main content

Stateful FastAPI primitives — rate limit, distributed lock, idempotency keys — sharing one Backend protocol.

Project description

wyolet-api-tools

Stateful FastAPI primitives — rate limit, distributed lock, idempotency keys — sharing one Backend protocol. Memory or Redis today; sqlite and postgres on the roadmap.

First package under the wyolet umbrella.

uv add wyolet-api-tools

Why

Every FastAPI project ends up reinventing the same primitives. The existing packages are each scoped to one of them — slowapi for rate limiting, redlock-py for locks, aiocache for caching — each with its own backend abstraction and lifecycle quirks. wyolet.api_tools unifies them: write one backend, get every primitive that needs state.

Quickstart

from fastapi import FastAPI, Depends
from wyolet.api_tools.backends.redis import RedisBackend
from wyolet.api_tools.ratelimit import RateLimit
from wyolet.api_tools.lock import Lock
from wyolet.api_tools.idempotency import Idempotency

backend = RedisBackend("redis://localhost")

app = FastAPI()

@app.post("/transfer", dependencies=[Depends(RateLimit(backend, "10/minute"))])
async def transfer(...):
    async with Lock(backend, key=f"user:{user_id}", ttl=30):
        ...

@app.post("/charge", dependencies=[Depends(Idempotency(backend, ttl=3600))])
async def charge(...):
    ...

Backends

Backend Status Use for
MemoryBackend v0.1 dev, tests, single-process
RedisBackend v0.1 production
SqliteBackend planned small deployments without redis
PostgresBackend planned when redis is overkill

Bring-your-own backend by implementing the Backend protocol — every primitive in this package will work with it.

Status

Pre-alpha. v0.1 ships rate limit, distributed lock, idempotency on memory + redis. Roadmap: dedup, OTP, feature flags, cache decorator, circuit breaker, retry, outbound throttle, pool/health composers.

License

TBD.

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

wyolet_api_tools-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

wyolet_api_tools-0.0.1-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file wyolet_api_tools-0.0.1.tar.gz.

File metadata

  • Download URL: wyolet_api_tools-0.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for wyolet_api_tools-0.0.1.tar.gz
Algorithm Hash digest
SHA256 31e10cc0a61eb1bb0b5e6f0d1ab3b029956e6647e3e32548e63aac05950799a3
MD5 33c4730f7c40503e583ea584b0c4df58
BLAKE2b-256 d24dd4ba29466a5e83c5a2d8bf5f0eddbbabbfb63feaecbc69ad12d2d99e636f

See more details on using hashes here.

File details

Details for the file wyolet_api_tools-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wyolet_api_tools-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6183a00228f56018a6434382066568d08a8d438fcc99e8ee6891916230416166
MD5 b793ff8a440d9c79c1b8666fdda0479a
BLAKE2b-256 09b1e4daabf2e4856a0e1a161285a5504602dd5a613fba187118d04bb897ee0a

See more details on using hashes here.

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