Add Aforo metering to your Python service. FastAPI, Django, and Flask middleware plus a manual track() client.
The only hard dependency is httpx>=0.25. AforoClient enqueues into a ring buffer and a background daemon thread flushes batches.
terminal
# Not yet on PyPI — clone and install from source:
git clone https://github.com/aforoai/SDKs.git
cd SDKs/aforo-metering-sdks/python
pip install -e . # or: pip install -e ".[fastapi]"
Manual Tracking
usage.py
import os
from aforo import AforoClient
client = AforoClient(api_key=os.environ["AFORO_API_KEY"])
client.track(
customer_id="cust_1", # who is billed
metric_name="api_calls", # what you're metering
quantity=1,
)
# Force a synchronous flush when you need delivery confirmed:
result = client.flush() # FlushResult(sent=..., failed=...)
client.shutdown() # also registered via atexit