Metadata-Version: 2.5
Name: ratelane-sdk
Version: 0.1.4
Summary: API observability and live policy control plane middleware for FastAPI
License: Proprietary
License-File: LICENSE
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Requires-Dist: starlette>=0.37
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# 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, and CORS — without redeploying your app. Policy changes push to all instances within 10 seconds.

## Installation

```bash
pip install ratelane-sdk
```

## Quick start

```python
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://your-ratelane-backend.com",
        fastapi_app=app,
    )
)
```

## 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
- **Emergency Profile** — automatic fallback policy when the policy server is unreachable
- **Fleet visibility** — per-instance sync status, last seen, and policy signature in the dashboard

## CLI

```bash
# Clear state for this project
ratelane clear --collector-url https://... --api-key sk_live_...

# Clear all Ratelane state on this machine
ratelane clear --all
```

## License

Copyright 2026 Ratelane. All Rights Reserved.