Skip to main content

A zero-dependency, ultra-lightweight performance terminal dashboard for Python Web Frameworks

Project description

py-api-spy

PyPI version Python version License

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

py_api_spy-0.1.3.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

py_api_spy-0.1.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file py_api_spy-0.1.3.tar.gz.

File metadata

  • Download URL: py_api_spy-0.1.3.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for py_api_spy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 17490b60e9dce8da9c7167ad1ac8ff015145172462a0a237fa4406d1c40f3952
MD5 09391b969c80ba1e6e1cdfc7c4c825d0
BLAKE2b-256 6c6d82d4b7e03d3aa421e5ef949e544781c1d87bf38d3027d9089f11ddf7d833

See more details on using hashes here.

File details

Details for the file py_api_spy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: py_api_spy-0.1.3-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

Hashes for py_api_spy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84865e0a2c4a22ff0a103cb5a5d0ed25b65e327552789e4564500dfe75989462
MD5 9c7353faa0cb538b1954f2cc379565d8
BLAKE2b-256 72e5bfcf5b6933736b6aec9a18a096c8911db81ddf7116ea8078ecb998891854

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