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) │ │
sd()captures the caller's file/line/function viainspect.- It serialises the value and fires a POST request on a daemon thread — completely non-blocking.
- The server stores the dump in a
deque(maxlen=200)and broadcasts it to all connected WebSocket clients. - 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.
- Fork the repository: https://github.com/acheltonzuzi/smartdump
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and commit:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - 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
- PyPI: https://pypi.org/project/smartdump/
- GitHub: https://github.com/acheltonzuzi/smartdump
- Issues: https://github.com/acheltonzuzi/smartdump/issues
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78f0cad03975094fb27e884d823063e0e02a2e38b0dd415a40dded5123846670
|
|
| MD5 |
d40977dd0db74476434939041ad1572c
|
|
| BLAKE2b-256 |
23e0115ffdeed026d8c79839aa5ce7df6615a4173dd4fb8126f091918b33bfb5
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
befc5b7f748815a22cfdf4a8272785ec1d6edabdf0866028c38744e57b1020a8
|
|
| MD5 |
b240474ab2ca4fe590e68143e5598cde
|
|
| BLAKE2b-256 |
02d0e4a2f57007cfc34d74576694ab30b6076a2c95f1b1ec3cd86c05cba14929
|