Skip to main content

ASGI Middleware for Umami Analytics

This project provides a middleware for your ASGI-compatible app (e.g. FastAPI, Starlette) that automatically sends access events to your umami instance. If you want to track your API clients in a GDPR-friendly way, then this middleware is for you.

Usage

For this middleware, you need the following information:

  • The URL of your Umami API (e.g. https://umami.example.com/api
  • The website GUID (e.g. 12345678-1234-1234-1234-123456789012)

Install the package via pip:

pip install umami-asgi

Then, you can add the umami middleware to your ASGI app. Here is an example for FastAPI:

from fastapi import FastAPI
from umami_asgi import UmamiMiddleware

app = FastAPI()
app.add_middleware(
    UmamiMiddleware,
    api_url="https://umami.example.com/api",
    website_id="12345678-1234-1234-1234-123456789012"
)

For more extensive examples, see the examples directory.

Try it out

In the examples directory, you can find examples for FastAPI and Starlette that you can try out easily. First, create a .env file in the examples directory with the following content:

UMAMI_API_ENDPOINT="https://example.com/api"
UMAMI_SITE_ID="your-site-id"

Then, install the necessary dependencies and run the example:

pip install uvicorn python-dotenv fastapi starlette 

# FastAPI:
python -m uvicorn examples.fastapi_app:app --env-file examples/.env

# Starlette:
python -m uvicorn examples.starlette_app:app --env-file examples/.env

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for umami-asgi 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for umami-asgi 0.2.0
File Size Uploaded
umami_asgi-0.2.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for umami-asgi 0.2.0
File Interpreter ABI Platform
umami_asgi-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / umami_asgi-0.2.0.tar.gz

Download URL umami_asgi-0.2.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d1f9d7c414bb4b496c44cbaeba33cab4134dacdefb355402e988395adaf74ba2
BLAKE2b-256 checksum
How to use checksums
9c5ef51a754e9a6245e06b7a653076a453af59438dd0187d0a82d3ceb293b8a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.10

Release files / umami_asgi-0.2.0-py3-none-any.whl

Download URL umami_asgi-0.2.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db5c894770b0e31118c7eb0b9dbe1b71f9f07eb038eec3520cdb176af61b2be7
BLAKE2b-256 checksum
How to use checksums
06ba6ac191cab558443d331ff8a5a6d7f07cdb279167aa2ce3d5c43a0a5b6e02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page