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 smartdump 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.3.tar.gz (14.5 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.3-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smartdump-0.1.3.tar.gz
Algorithm Hash digest
SHA256 92a4ef4ae2e20477b64fbe67211a5e4d624b28c32b2966263eae220818eae7a9
MD5 53fd8c0663932e58c2a7a507f4082c8b
BLAKE2b-256 f7f811a10abbfcb2a251370081b6adf5de116312c9b9f0fc41e182479595eb8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smartdump-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 58402cb879be5adfa272da049bb6e1125b7bb74a7092e778ebc13c0297bc25fc
MD5 93440ed8e6807bafa92c24dfa3782a57
BLAKE2b-256 f28cd1baaf3e32db37b248cffb1ea486767e796db6047dba41b95317eaab87a9

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