fastapi-inspector
Structured logging and observability middleware for FastAPI applications.
Documentation · Changelog · Contributing
Features
- Zero-boilerplate middleware — one line to log every request and response
- Structured events — typed
LogEventobjects with method, path, status code, latency, and more - Pluggable storage — in-memory, JSON file, JSON Lines, or SQLite backends
- Filter pipeline — drop health-check noise, log only errors, or set a minimum latency threshold
- Built-in dashboard — mount an event-inspector UI at any path in your app
- Multiple formatters — plain-text or JSON output
- Python 3.10–3.14 with full CI coverage across all versions
Install
pip install fastapi-inspector
Quick start
Basic logging
from fastapi import FastAPI
from fastapi_inspector import ObserverConfig, ObserverMiddleware
app = FastAPI()
app.add_middleware(ObserverMiddleware, config=ObserverConfig())
@app.get("/items")
async def list_items():
return {"items": ["alpha", "beta", "gamma"]}
Every request is now logged to the console with method, path, status code, and latency.
Persist events and open the dashboard
from fastapi import FastAPI
from fastapi_inspector import ObserverConfig, ObserverMiddleware, build_dashboard_app
from fastapi_inspector.storage import InMemoryEventStore
app = FastAPI()
store = InMemoryEventStore()
app.add_middleware(ObserverMiddleware, config=ObserverConfig(), storage=store)
app.mount("/dashboard", build_dashboard_app(store, title="Observer Dashboard"))
Open http://localhost:8000/dashboard to browse and inspect logged events.
Filter out noise
from fastapi_inspector import ObserverConfig, ObserverMiddleware, only_errors, min_duration_ms
app.add_middleware(
ObserverMiddleware,
config=ObserverConfig(handlers=["console"], log_format="json"),
event_filters=[
only_errors, # log 4xx/5xx responses only
min_duration_ms(50.0), # ignore fast responses
],
)
See the examples/ directory for more patterns including SQLite storage and custom filters.
Storage backends
| Backend | Class | Use case |
|---|---|---|
| In-memory | InMemoryEventStore |
Development, testing |
| JSON file | JsonFileEventStore |
Simple persistence |
| JSON Lines | JsonLinesEventStore |
Append-only log files |
| SQLite | SQLiteEventStore |
Queryable local storage |
Python compatibility
- Supported versions:
3.10,3.11,3.12,3.13,3.14 - Enforced in CI with a tox matrix across all versions
Development
Install all dependencies:
pip install -e ".[test,docs,dev]"
pre-commit install
Run tests:
pytest -q
pytest -q --cov=fastapi_inspector --cov-report=term-missing # with coverage
tox # full version matrix
Build and preview docs:
mkdocs serve # http://127.0.0.1:8000
mkdocs build --strict
See CONTRIBUTING.md for the full contribution guide.
Metadata
Release files for fastapi-inspector 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastapi_inspector-1.0.1.tar.gz | 23.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_inspector-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.7 kB
Release files / fastapi_inspector-1.0.1.tar.gz
| Download URL | fastapi_inspector-1.0.1.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ddebc37994c669fa0f8a3804268cd88295464cc73ac0948b020d099ec7f3e8b
|
|
BLAKE2b-256 checksum How to use checksums |
07509905ec66f188fb0f8e2c1f87503e63a3931437436559e9022ada0b8c5c3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.
Transparency logRelease files / fastapi_inspector-1.0.1-py3-none-any.whl
| Download URL | fastapi_inspector-1.0.1-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54996503886488e68ac9bffcd7c0ac3cef04b3170a811896e382ea03044c1578
|
|
BLAKE2b-256 checksum How to use checksums |
f89f5070130880358e41ceea5bdcb25e955df4ff835c53928eb14bfd21e160a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.
Transparency logSecurity for fastapi-inspector 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for fastapi_inspector-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.