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.
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 ratelane_sdk-0.2.2.tar.gz.
File metadata
- Download URL: ratelane_sdk-0.2.2.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f27eb5edd25df6806470b15f59aa5320804fac22fca13838baec627b6a9d138
|
|
| MD5 |
41eaf66973231f7968fc2b32294d8765
|
|
| BLAKE2b-256 |
990973ca4adda77957c9bff8c34bd74aacb57f7b7d80e672840785050449206b
|
File details
Details for the file ratelane_sdk-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ratelane_sdk-0.2.2-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128dc981a3bf7121e096e62376339f41e936e961e246d843c760857e4353af78
|
|
| MD5 |
f132b727e880dc9e54dc72f483fd73f2
|
|
| BLAKE2b-256 |
1874cc2a5e6b5cb311066bc42f0f5951da2ab5340c28a6c46b951bf81d2a9065
|