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.0.tar.gz (9.5 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.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_api_spy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 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.0.tar.gz
Algorithm Hash digest
SHA256 f6b461cc80dd6fc3feb9c18da5e7b6611dd89eaaedaf8d1d8e1a204e68a699ff
MD5 7d4a886c41f3ca27aaff80dad24f2377
BLAKE2b-256 b3115f5d66ca4342ebe15257788ae52368d484e80cd80861e5109eb2086e9b0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_api_spy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d98455b27ed03a17888fc4a249a0e8ec00e5f5bd6371f0c40391177dc31752a6
MD5 1f2aaf3d6150b355ab9c245b1a93fee5
BLAKE2b-256 cd7383f6336a6f3b9fb5fd5c93f3da1773b72a0346ccb9dd1c0cfcf4be15b4ed

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