ratelane-sdk
API observability and live policy control plane middleware for FastAPI.
Ratelane gives you fleet-wide visibility and real-time policy enforcement — rate limits, route enable/disable, per-route timeouts, CORS, IP rules, circuit breakers, and request size limits — without redeploying your app. Policy changes push to all instances within 10 seconds.
Installation
pip install ratelane-sdk
Quick start
from fastapi import FastAPI
from ratelane import RatelaneConfig, RatelaneMiddleware
app = FastAPI()
app.add_middleware(
RatelaneMiddleware,
config=RatelaneConfig(
api_key="your_api_key",
collector_url="https://api.ratelane.dev",
fastapi_app=app,
# instance_version="1.0.0", # optional: your app version
# framework="fastapi", # optional: override auto-detection
)
)
Features
- Rate limiting — global and per-route, enforced locally with no network call on the hot path
- Route control — enable/disable routes with custom status codes and messages
- Per-route timeouts — automatic 504 on slow downstream responses
- CORS — dynamic allowed origins pushed from the dashboard
- IP allowlist / denylist — global and per-route, supports exact IPs and CIDR ranges
- Request size limits — Content-Length fast path + chunked stream enforcement
- Circuit breaker — per-route sliding window, automatic open/half-open/closed transitions
- Emergency Profile — automatic fallback policy when the policy server is unreachable, auto-reverts on reconnect
- Fleet visibility — per-instance sync status, runtime info, SDK version, and policy signature in the dashboard
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | Your Ratelane API key |
collector_url |
str |
required | Your Ratelane backend URL |
fastapi_app |
FastAPI |
None |
App reference for route discovery |
instance_version |
str |
None |
Your app's version, shown in the dashboard |
framework |
str |
"fastapi" |
Override framework label sent to the dashboard |
poll_interval_seconds |
int |
3 |
How often to poll for policy updates |
ep_enabled |
bool |
True |
Enable Emergency Profile fallback |
ep_trigger_after_seconds |
int |
86400 |
Seconds before EP activates |
request_timeout_seconds |
float |
5.0 |
HTTP timeout for SDK requests |
CLI
# Clear state for this project
ratelane clear --collector-url https://api.ratelane.dev --api-key sk_live_...
# Clear all Ratelane state on this machine
ratelane clear --all
License
Copyright 2026 Ratelane. All Rights Reserved.
Metadata
Release files for ratelane-sdk 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ratelane_sdk-0.2.3.tar.gz | 11.8 kB | Without provenance | Details for ratelane_sdk-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ratelane_sdk-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for ratelane_sdk-0.2.3-py3-none-any.whl |
Total release size: 26.0 kB
Release files / ratelane_sdk-0.2.3.tar.gz
| Download URL | ratelane_sdk-0.2.3.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0476d85181f69ded5fc4dc54f0f6b4d4dc5514f134e641fe923803b2c2b83da0
|
|
BLAKE2b-256 checksum How to use checksums |
2c449c0ec30d09f7b9dd9c9b3e97f067098665d43e948337d09dfbd630ff031a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Release files / ratelane_sdk-0.2.3-py3-none-any.whl
| Download URL | ratelane_sdk-0.2.3-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccab0799fef63a8236fee3e4655f721ee1cdc87413be565beaf97cc08a226681
|
|
BLAKE2b-256 checksum How to use checksums |
e63ead3712f1a521c7d8eb9589389dbda47bae22f9a31d1936f2ae059205061a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Security for ratelane-sdk 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.