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

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_api_spy-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 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.1.tar.gz
Algorithm Hash digest
SHA256 0a1c5058124d9b72f6ab88aa5863cfc6b299f3e3fccba81bc320620cd9b49d60
MD5 59f322255721d3921f3387689978b1e5
BLAKE2b-256 c6f72592d0228e37556db86239c34640a4530a3adfd043ea5447f0d706b7dece

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_api_spy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 419882218a094fba48193dde61bc9f93f5ad4ba2fac5fee38bb2891bd148d26d
MD5 aa24fe401d5b3a2a87392477fd7add51
BLAKE2b-256 b5f36417fbe99f1af692ffce85ad0d2c2b630ff18df5330833db217e79721692

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