Metadata-Version: 2.4
Name: quotawatch
Version: 0.0.1
Summary: API usage monitoring SDK for Python
License: MIT
Keywords: api,rate-limit,monitoring
Author: Paulo
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: httpx
Provides-Extra: requests
Requires-Dist: httpx (>=0.27.0,<0.28.0) ; extra == "httpx"
Requires-Dist: requests (>=2.31.0,<3.0.0) ; extra == "requests"
Description-Content-Type: text/markdown

# quotawatch

Python SDK for [QuotaWatch](https://quotawatch.app) — passive API usage monitoring.

**Never get surprised by a rate limit again.**

## Installation

```bash
pip install quotawatch
```

## Quick start

```python
from quotawatch import QuotaWatch
from quotawatch.types import QuotaWatchConfig, ApiConfig, ApiLimits

QuotaWatch.init(QuotaWatchConfig(
    api_key="qw_live_your_key_here",
    ingest_url="https://ingest.quotawatch.app",  # or http://localhost:3001 for local dev
    environment="production",
    apis=[
        ApiConfig(
            name="OpenAI",
            base_url="https://api.openai.com",
            limits=ApiLimits(
                requests_per_minute=60,
                requests_per_day=10_000,
                tokens_per_day=1_000_000,
            ),
        ),
    ],
))

# That's it. Your existing requests/httpx calls are now monitored automatically.
# No record() calls needed — the SDK patches the HTTP clients on init().
import requests
response = requests.get("https://api.openai.com/v1/models", headers={...})
```

## How it works

On `init()`, the SDK monkey-patches `requests.Session.send` and `httpx.Client.send` (both sync and async). Every outgoing HTTP call matching a configured `base_url` is recorded asynchronously — **fire-and-forget**. A background daemon thread flushes buffered events to the ingest API every 5 seconds.

**You never call `record()` manually** — the interceptors handle everything.

## Supported HTTP clients

| Client | Supported |
|---|---|
| `requests` | ✅ Auto-patched on init |
| `httpx` (sync) | ✅ Auto-patched on init |
| `httpx` (async) | ✅ Auto-patched on init |
| `aiohttp` | 🔜 v1.1 |
| `urllib` | ❌ Not supported |

## Requirements

- Python 3.9+
- Optional: `requests`, `httpx` (patches whichever is installed)

## Documentation

Full docs at [quotawatch.app/docs/python](https://quotawatch.app/docs/python)

## License

MIT

