pyapimon
Python middleware for API monitoring and analytics. Integrates directly into your web framework to capture request/response data, store it locally, and provide a rich CLI for exploration and insights.
Install
pip install pyapimon
With LLM-powered insights:
pip install pyapimon[llm]
Quickstart
FastAPI
from fastapi import FastAPI
from pyapimon import FastAPIMiddleware
app = FastAPI()
app.add_middleware(FastAPIMiddleware)
Django
Add to settings.py:
MIDDLEWARE = [
"pyapimon.middleware.django.DjangoMiddleware",
# ... other middleware
]
# Optional
PYAPIMON = {
"db_path": "/tmp/apimon.db",
"flush_interval": 3,
}
Flask
from flask import Flask
from pyapimon import FlaskMiddleware
app = Flask(__name__)
FlaskMiddleware(app)
CLI Commands
CLI commands now support interactive timeframe selection (e.g., past 24h, 7d, 30d, all-time). If you do not provide the --hours option, pyapimon will prompt you automatically.
pyapimon stats Route statistics table
pyapimon requests Recent request list
pyapimon request <id> Single request detail
pyapimon ui Interactive TUI dashboard
pyapimon dashboard Rich terminal dashboard
pyapimon insights LLM-powered analysis
pyapimon suggestions Rule-based suggestions
pyapimon graph ASCII time-series graph
pyapimon export <file> Export analytics to JSON
pyapimon clear Clear all captured data
pyapimon doctor Verify middleware is working
pyapimon version Show version
Configuration
All options are optional with sane defaults:
| Option | Default | Description |
|---|---|---|
db_path |
"apimon.db" |
SQLite database file path |
flush_interval |
2.0 |
Seconds between batch flushes |
flush_size |
100 |
Max buffered records before force-flush |
record_bodies |
True |
Capture request/response bodies |
body_max_length |
10000 |
Truncate bodies beyond this length |
excluded_paths |
[] |
Paths to skip. Accepts a list ["/health"] or a comma-separated string "/health,/metrics" |
excluded_headers |
["authorization", "cookie", "set-cookie"] |
Headers to redact |
Key Features
- Performance Tracking: Measure average response times, max/min, and Request/Second metrics.
- Percentiles & Status Codes: View P50, P90, P95, and P99 latency percentiles alongside HTTP status distributions in the rich dashboard.
- LLM Insights: Pass your analytics to an LLM provider for deep architectural advice.
- Zero Overhead: Utilizes a background thread and queue mechanism to prevent adding latency to your API routes.
Development
git clone https://github.com/Mohammad-Palla/pyapimon.git
cd pyapimon
pip install -e ".[dev]"
pytest
License
MIT
Metadata
Release files for pyapimon 0.1.3
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 | Actions |
|---|---|---|---|---|
| pyapimon-0.1.3.tar.gz | 37.0 kB | Without provenance | Details for pyapimon-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyapimon-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for pyapimon-0.1.3-py3-none-any.whl |
Total release size: 69.3 kB
Release files / pyapimon-0.1.3.tar.gz
| Download URL | pyapimon-0.1.3.tar.gz |
|---|---|
| Size | 37.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07ed9d46523dd68624f9e9fd627c9c8d85228b0e0d16a1e4903406c215e4ad2c
|
|
BLAKE2b-256 checksum How to use checksums |
32963c9ee4e905c6ebe369884eab86fba6bd9f6e3b7ed21b367b15b79a2f22dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / pyapimon-0.1.3-py3-none-any.whl
| Download URL | pyapimon-0.1.3-py3-none-any.whl |
|---|---|
| Size | 32.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a68a17179d3f81ede065fbdc80c0e01848cc63d06e2f82ede8aca3ef4d36dc4b
|
|
BLAKE2b-256 checksum How to use checksums |
e9d36debfc0c1a85b7d1a2c395b503150360f9bc6845efda46b4241a054bd330
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for pyapimon 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.