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.4.tar.gz (9.7 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.4-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_api_spy-0.1.4.tar.gz
  • Upload date:
  • Size: 9.7 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.4.tar.gz
Algorithm Hash digest
SHA256 0ef6a34fc012532300ff2660d158cda95a557bf4f7b527cf54c213c77e515010
MD5 12df1c6e9e98abb20d75c294637c2358
BLAKE2b-256 1926d555d9330706b7717d2446a827f0fe94d5ad8a5c0bbcc0c4795ae1dbef14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_api_spy-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 07629a31c2c316f0fd3bc330f243c908829c06f6d80dd3531423e8d9cd3b3dfd
MD5 f0f9e8159487c7fcee4d6bf7d0a19d31
BLAKE2b-256 7bd513032839956250e7ac564f2ca1ca5437c884258aa88ab6ff30ef51f26806

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