Python with AllStak

Track errors and requests in FastAPI, Flask, Django, or any Python app with the AllStak Python SDK (Python 3.9+).

Source repository:
AllStak/allstak-python
Source README:
README.md
SDK version:
0.2.0
Installation source:
PyPI
Last verified:
2026-05-31

Installation

Install from PyPI. Framework extras are available, e.g. allstak[fastapi], allstak[flask], allstak[django].

pip install allstak

Configuration

Initialize at application startup. api_key falls back to the ALLSTAK_API_KEY environment variable.

import os
import allstak

allstak.init(
    api_key=os.getenv("ALLSTAK_API_KEY"),
    environment=os.getenv("APP_ENV", "production"),
    release=os.getenv("ALLSTAK_RELEASE"),
)

Basic example

FastAPI/Starlette is auto-instrumented after init; you can attach it explicitly. Flask uses AllStakFlask(app); Django adds "allstak" to INSTALLED_APPS.

from fastapi import FastAPI
from allstak.integrations.fastapi import AllStakFastAPI

app = FastAPI()
AllStakFastAPI(app, service="checkout-api")

Capturing errors

Capture handled exceptions explicitly.

allstak.capture_exception(RuntimeError("checkout failed"))

Tracking requests

After init, the framework integration records inbound requests automatically. Outbound HTTP can be recorded via allstak.http.record(direction="outbound", method=..., host=..., path=..., status_code=..., duration_ms=...).

Best practices

  • Call allstak.init() before creating the app instance.
  • Set release to group errors per deployment.
  • Install the matching framework extra (fastapi/flask/django) for integrations.