Nilguard Python SDK — server-side error tracking with token-based ingest
Project description
Nilguard — Python SDK
Server-side error tracking for ASGI apps (FastAPI, Starlette). Mirrors the browser SDK's wire format so the dashboard, ticketing and agent-run pipeline work unchanged.
Install
pip install nilguard
For local development, install the package in editable mode from this directory:
uv pip install -e .
You can also pull it directly as a [tool.uv.sources] path entry from another
project during local testing.
Quick start
from fastapi import FastAPI
import nilguard
nilguard.init(
service="billing-api", # human-readable identifier
framework="fastapi", # dashboard renders the right icon
ingest_key="ng_srv_...", # shown once at mint time
backend_url="https://nilguard.example.com",
environment="production",
release="2026-05-23-a1b2c3d",
)
app = FastAPI()
app.add_middleware(nilguard.NilguardASGIMiddleware)
@app.get("/healthy")
async def healthy():
return {"ok": True}
@app.get("/boom")
async def boom():
1 / 0 # raises ZeroDivisionError; middleware sends a crash bundle, then re-raises
Try the FastAPI example without installing anything
The examples/fastapi_demo.py script uses PEP 723 inline metadata so
uv will install FastAPI + uvicorn + this SDK (via a local path source)
for you on first run:
cd examples/python-fastapi
NILGUARD_INGEST_KEY="ng_srv_..." uv run fastapi_demo.py
Manual capture
try:
risky()
except Exception as exc:
nilguard.capture_exception(exc, context={"job_id": job.id})
raise
What gets sent
- Clean requests send nothing. The middleware stays on the request path only long enough to observe exceptions.
- Crash bundle on unhandled exception. Includes a
networkevent describing the inbound request plus acrashobject withsignal=server_exceptionand a redacted traceback inmetadata. - Headers, cookies, query values, and anything matching the redaction
denylist (
authorization|cookie|token|secret|password|session|credential|auth) are scrubbed client-side before the POST. The backend re-applies the same rules — it remains the source of truth.
Auth
All ingest requests carry Authorization: Bearer <ingest_key>. No
Origin/CORS dance: the token is the only thing the backend trusts for the
server-ingest path.
Project details
Release history Release notifications | RSS feed
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 nilguard-0.1.1.tar.gz.
File metadata
- Download URL: nilguard-0.1.1.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e170317ef0797f38affb42ac761103a4112aebaf037d1edc09bc9f363a5f9b00
|
|
| MD5 |
fb28b8e6c5f123402395239046f20b5a
|
|
| BLAKE2b-256 |
4d2a03336e7bb7e884d6ee4e30995961ae7fe70177420696b3a21d468bff95cd
|
Provenance
The following attestation bundles were made for nilguard-0.1.1.tar.gz:
Publisher:
publish-python.yml on amalshaji/nilguard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nilguard-0.1.1.tar.gz -
Subject digest:
e170317ef0797f38affb42ac761103a4112aebaf037d1edc09bc9f363a5f9b00 - Sigstore transparency entry: 1739927315
- Sigstore integration time:
-
Permalink:
amalshaji/nilguard@4c1b22d5e49f550c396dda06ea839274d5a7bdf3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/amalshaji
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@4c1b22d5e49f550c396dda06ea839274d5a7bdf3 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file nilguard-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nilguard-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b98de7551b0abee335b2b0de53c34d060b6a1861393cb0e3639dd218b199213
|
|
| MD5 |
03bfd7d2d71cd89cc1d8cd68e7a6a12d
|
|
| BLAKE2b-256 |
bc141888c4c07735ad9925b61665f1615443ec26542babdb17f39a4c7da87465
|
Provenance
The following attestation bundles were made for nilguard-0.1.1-py3-none-any.whl:
Publisher:
publish-python.yml on amalshaji/nilguard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nilguard-0.1.1-py3-none-any.whl -
Subject digest:
2b98de7551b0abee335b2b0de53c34d060b6a1861393cb0e3639dd218b199213 - Sigstore transparency entry: 1739927320
- Sigstore integration time:
-
Permalink:
amalshaji/nilguard@4c1b22d5e49f550c396dda06ea839274d5a7bdf3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/amalshaji
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@4c1b22d5e49f550c396dda06ea839274d5a7bdf3 -
Trigger Event:
pull_request
-
Statement type: