Skip to main content

Real-time variable dumper for FastAPI — inspired by Laradumps

Project description

SmartDump

Real-time variable dump viewer for FastAPI — inspired by Laradumps.

Call sd(variable) anywhere in your FastAPI app and see it appear instantly in the browser.


Installation

pip install smartdump

Quick start

1. Start the debug server

smartdump start

Open http://localhost:8765 in your browser.

2. Use sd() in your FastAPI app

from client import sd

@app.get("/users/{user_id}")
async def get_user(user_id: int):
    user = db.get_user(user_id)
    sd(user, label="user from DB")   # dumps to the UI, non-blocking
    return user

Every dump appears instantly in the browser with the file, line number, and function name.


sd() reference

sd(data, label=None, level="info")
Parameter Type Default Description
data any Any Python value to inspect
label str None Human-readable name shown in the UI
level str "info" One of info, debug, warning, error

Returns data unchanged — safe to use inline:

return sd(result, "final result")

Configuration

from client import configure

configure(
    server_url="http://localhost:8765",  # default
    timeout=1.0,                         # seconds — kept short
    enabled=True,                        # set False in production
)

UI features

  • Real-time WebSocket feed
  • Collapsible JSON tree viewer (auto-collapses at depth 3)
  • Level badges: info / debug / warning / error
  • Filter by level and free-text search (label, file, value)
  • Sort newest / oldest
  • Copy-to-clipboard button
  • File + line number + function name for every dump
  • Dark mode by default

How it works

FastAPI app          SmartDump server            Browser
    │                        │                      │
    │  sd(data)              │                      │
    │─── POST /dump ────────>│                      │
    │   (daemon thread)      │── WS broadcast ─────>│
    │                        │                      │ (live update)
    │  (request continues)   │                      │
  1. sd() captures the caller's file/line/function via inspect.
  2. It serialises the value and fires a POST request on a daemon thread — completely non-blocking.
  3. The server stores the dump in a deque(maxlen=200) and broadcasts it to all connected WebSocket clients.
  4. The browser receives the payload and renders it as a collapsible JSON tree.

If the server is not running, sd() silently does nothing — it never crashes your app.


Disabling in production

import os
from client import configure

configure(enabled=os.getenv("DEBUG", "false").lower() == "true")

Project structure

smartdump/
├── client/          # Python client library — the sd() function
├── server/          # FastAPI dump server (port 8765)
├── static/          # Web UI (vanilla JS, no build step)
├── example/         # Demo FastAPI app
└── run.py           # Server launcher (also registered as `smartdump` CLI)

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

smartdump-0.1.2.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

smartdump-0.1.2-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file smartdump-0.1.2.tar.gz.

File metadata

  • Download URL: smartdump-0.1.2.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for smartdump-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f72659ba1ea4aace00013f7a0fe1f1c1ee7f1fcf0065068cb903e426a1c9a328
MD5 d2bbe0633e686350e5a21ef217264a87
BLAKE2b-256 e08ee7346090851dde1a9d86bf310135846df76e514534b57a13800911d0db13

See more details on using hashes here.

File details

Details for the file smartdump-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: smartdump-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for smartdump-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6140e69573f855139d400ef986ffc7a256b293064d35e8a2b80ea8a9139847f1
MD5 b5f610656a7322cab985dd509bebd529
BLAKE2b-256 60202fc7de3779185b4dd8d319119f871386235a239114077f2fdff0059c5130

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