Skip to main content

API observability & intelligence for FastAPI/Starlette — local-first, privacy-first

Project description

apiforgepy

API observability & intelligence for FastAPI/Starlette — local-first, privacy-first.

PyPI version CI License: MIT Python

Track latency, error rates, and behavioral trends of your APIs. Everything stays on your machine.

Full documentation


Install

pip install apiforgepy

Quick start

from fastapi import FastAPI
from apiforgepy import ApiForgeMiddleware

app = FastAPI()

app.add_middleware(
    ApiForgeMiddleware,
    mode="local",
)

@app.get("/users/{user_id}")
def get_user(user_id: int):
    return {"id": user_id}

# Dashboard → http://localhost:4242

Configuration

app.add_middleware(
    ApiForgeMiddleware,
    mode="local",
    db_path=".apiforge.db",
    dashboard_port=4242,       # set to 0 to disable
    flush_interval=60_000,     # ms
    env="production",
    release="v1.4.0",          # enables release regression detection
    service="user-service",
    sampling=1.0,              # 0.0–1.0
    ignore_paths=["/health", "/favicon.ico"],
)

What you get

  • Latency percentiles — P50 / P90 / P99 per endpoint, updated every 60s
  • Error rate by route — 2xx / 4xx / 5xx breakdown in real time
  • API Health Score — a single 0–100 score summarizing your API's health
  • Automatic insights — plain-language alerts with no configuration
  • Dead endpoint detection — routes with no traffic in 21+ days
  • Release impact tracking — before/after comparison on every deploy

Graceful shutdown

import signal

mw = None

@asynccontextmanager
async def lifespan(app):
    yield
    if mw:
        mw.shutdown()

app = FastAPI(lifespan=lifespan)
mw = ApiForgeMiddleware.__new__(ApiForgeMiddleware)
app.add_middleware(ApiForgeMiddleware, mode="local")

Privacy by design

The middleware never reads request or response bodies, headers, cookies, or tokens. Route parameters are captured as patterns only (/users/{user_id} — never /users/42). In local mode, zero data leaves your machine.

Requirements

  • Python ≥ 3.11
  • Starlette ≥ 0.27 (FastAPI ≥ 0.110 includes this)

License

MIT — APIForge Organisation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apiforgepy-1.0.1.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apiforgepy-1.0.1-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file apiforgepy-1.0.1.tar.gz.

File metadata

  • Download URL: apiforgepy-1.0.1.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for apiforgepy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cb2de7616d31dab45d1672a6f4a6f5631a402ab950457c6333b451a5adcea9c4
MD5 22c2b963226a8b6206f3f48656bd3bdc
BLAKE2b-256 fbc6c501e4e8f4851c9adec6655ee95bbec9d89264f075455429ab2f7281faf6

See more details on using hashes here.

File details

Details for the file apiforgepy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: apiforgepy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for apiforgepy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5b315a762d5c28a611997b4f254d37d2fa6b9d2adb3521eb0a42237a899f85b
MD5 5c7d7c721aa99f2531e268a3644217f3
BLAKE2b-256 6aecc493e9f9e70d10a0891d94b79e1c9fcb87ca2e11e67522fda060219a2fb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page