A zero-dependency, ultra-lightweight performance terminal dashboard for Python Web Frameworks
Project description
py-api-spy
A zero-dependency, lightweight terminal performance dashboard for Python web frameworks.
This is the Python sibling of the @chabdulwahab/api-spy Node.js library. It maintains the identical layout, telemetry keys, and minimalist design philosophy.
Features
- Zero Dependencies: Implemented using only standard Python library modules.
- Low Overhead: Tailored metrics tracking with minimal CPU and memory impact.
- Sticky Terminal Dashboard: Persisted at the bottom of the stdout stream while application logs print normally above it.
- Thread Safe: Concurrent requests are serialized using reentrant locking mechanisms.
- Framework Support: Built-in middlewares for FastAPI / Starlette (ASGI) and Django / DRF (WSGI).
Installation
Install the package via pip:
pip install py-api-spy
Usage
FastAPI / Starlette
Add the ASGI middleware to your FastAPI application:
from fastapi import FastAPI
from api_spy import ApiSpyMiddleware
app = FastAPI()
app.add_middleware(ApiSpyMiddleware)
@app.get("/")
def read_root():
return {"hello": "world"}
Django / DRF
Add the WSGI middleware to your Django MIDDLEWARE list in settings.py:
MIDDLEWARE = [
# ... other middlewares ...
"api_spy.ApiSpyDjangoMiddleware",
]
Dashboard Design
The dashboard takes exactly 10 lines and maintains a hardcoded width of 72 characters:
- Latency States: Green
[✓]for fast routes (<= 200ms) and red[!]for slow routes (> 200ms). - Dot-leaders: Dim gray dots linking paths with their corresponding metrics.
- Cross-Platform Memory: Retrieves resident set size (RAM) for Linux, macOS, and Windows.
┌──────────────────────────────────────────────────────────────────────┐
│ Active: 1 │ Total: 15 │ RAM: 14.5 MB │
├──────────────────────────────────────────────────────────────────────┤
│ Slowest Routes (Top 5) │
│ [✓] GET /.............................................. 5ms (x8) │
│ [!] POST /api/v1/users.............................. 205ms (x2) │
│ - │
│ - │
│ - │
└──────────────────────────────────────────────────────────────────────┘
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 py_api_spy-0.1.5.tar.gz.
File metadata
- Download URL: py_api_spy-0.1.5.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23f941a4a0c7aae08edee6354b8d830514530cf51c669f3455f54a07e4d1f74a
|
|
| MD5 |
b8783a5eca98b68e6a92a4e12404da8b
|
|
| BLAKE2b-256 |
f3b7e6d8d28cb781e0509b57268155a439ab50c08975c7c610cbcab1df0b3561
|
File details
Details for the file py_api_spy-0.1.5-py3-none-any.whl.
File metadata
- Download URL: py_api_spy-0.1.5-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f854aeed15e2401311f7494e91bc00a96236c05ffa3b8c0fcd49e3d1abef1841
|
|
| MD5 |
4153c0c034c0ded37afe5efbc4bcdfb4
|
|
| BLAKE2b-256 |
b6b8d5119f01cbff9280b53c84551100188beb5ce64f21b657448a56e0a3084d
|