Skip to main content

Real-time variable dumper for FastAPI — inspired by Laradumps

Project description

SmartDump

PyPI version License: MIT Python 3.10+

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)

Contributing

Contributions are welcome! This is an open source project.

  1. Fork the repository: https://github.com/acheltonzuzi/smartdump
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and commit: git commit -am 'Add new feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Submit a pull request

Development setup

git clone https://github.com/acheltonzuzi/smartdump.git
cd smartdump
pip install -e ".[dev]"
pytest

License

MIT License - see the LICENSE file for details.


Links


Made with ❤️ by achelton pambo

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.5.tar.gz (16.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.5-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smartdump-0.1.5.tar.gz
Algorithm Hash digest
SHA256 78f0cad03975094fb27e884d823063e0e02a2e38b0dd415a40dded5123846670
MD5 d40977dd0db74476434939041ad1572c
BLAKE2b-256 23e0115ffdeed026d8c79839aa5ce7df6615a4173dd4fb8126f091918b33bfb5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for smartdump-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 befc5b7f748815a22cfdf4a8272785ec1d6edabdf0866028c38744e57b1020a8
MD5 b240474ab2ca4fe590e68143e5598cde
BLAKE2b-256 02d0e4a2f57007cfc34d74576694ab30b6076a2c95f1b1ec3cd86c05cba14929

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