Python middleware for API monitoring and analytics
Project description
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
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 (e.g., ["/health"]) |
excluded_headers |
["authorization", "cookie", "set-cookie"] |
Headers to redact |
Development
git clone https://github.com/Mohammad-Palla/pyapimon.git
cd pyapimon
pip install -e ".[dev]"
pytest
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyapimon-0.1.0.tar.gz.
File metadata
- Download URL: pyapimon-0.1.0.tar.gz
- Upload date:
- Size: 32.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d34f9fa6c635296014847ee78c63d9e75e27ad81452e243aa8f3ee97666b19b
|
|
| MD5 |
a2c72f3d2c7da502be15fbe956e59344
|
|
| BLAKE2b-256 |
6e014ad0bf535c7951fcee6e0d75207e3ca9efee2058766a1cf576fc613f480d
|
File details
Details for the file pyapimon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyapimon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
042a7c8e381b11823a27f8ecd4438698939519615b0f680eb01ca982fcf261e7
|
|
| MD5 |
ce31968fe8812c8ebbfe6bac09f2295f
|
|
| BLAKE2b-256 |
e3ce6e783b3288dda23e601d99191f35a18467b58a83a5db67d13fee1c6bb666
|