{"id":28171574,"url":"https://github.com/tanikai/umami-asgi","last_synced_at":"2026-04-27T08:32:15.981Z","repository":{"id":245390805,"uuid":"818233339","full_name":"Tanikai/umami-asgi","owner":"Tanikai","description":"Middleware for Umami Analytics in ASGI apps (FastAPI, Starlette, ...)","archived":false,"fork":false,"pushed_at":"2024-06-27T12:19:27.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T19:14:18.657Z","etag":null,"topics":["analytics","asgi","asgi-middleware","fastapi","metrics","middleware","python","starlette"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tanikai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-21T11:42:51.000Z","updated_at":"2024-11-13T09:58:53.000Z","dependencies_parsed_at":"2024-06-21T23:34:29.859Z","dependency_job_id":"4e9011fe-b66b-47a5-98ff-8fe50fe48bc6","html_url":"https://github.com/Tanikai/umami-asgi","commit_stats":null,"previous_names":["tanikai/umami-asgi-middleware"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tanikai%2Fumami-asgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tanikai%2Fumami-asgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tanikai%2Fumami-asgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tanikai%2Fumami-asgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tanikai","download_url":"https://codeload.github.com/Tanikai/umami-asgi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404319,"owners_count":22065641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","asgi","asgi-middleware","fastapi","metrics","middleware","python","starlette"],"created_at":"2025-05-15T19:15:03.702Z","updated_at":"2026-04-27T08:32:15.911Z","avatar_url":"https://github.com/Tanikai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASGI Middleware for Umami Analytics\n\nThis project provides a middleware for your\n[ASGI-compatible](https://asgi.readthedocs.io/en/latest/introduction.html) app\n(e.g. FastAPI, Starlette) that automatically sends access events to your\n[umami](https://umami.is/) instance. If you want to track your API clients\nin a GDPR-friendly way, then this middleware is for you.\n\n## Usage\n\nFor this middleware, you need (at least) the following information:\n\n- The URL of your Umami API (e.g. `https://umami.example.com/api`\n- The website GUID (e.g. `12345678-1234-1234-1234-123456789012`)\n\nInstall the package via pip:\n\n```bash\npip install umami-asgi\n```\n\nThen, you can add the umami middleware to your ASGI app. Here is an example for\nFastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom umami_asgi import UmamiMiddleware\n\napp = FastAPI()\napp.add_middleware(\n    UmamiMiddleware,\n    api_url=\"https://umami.example.com/api\",\n    website_id=\"12345678-1234-1234-1234-123456789012\"\n)\n```\n\nFor more extensive examples, see the `examples` directory.\n\n## Try it out\n\nIn the `examples` directory, you can find examples for FastAPI and Starlette\nthat you can try out easily. First, create a `.env` file in the `examples`\ndirectory with the following content:\n\n```text\nUMAMI_API_ENDPOINT=\"https://example.com/api\"\nUMAMI_SITE_ID=\"your-site-id\"\n```\n\nThen, install the necessary dependencies and run the example:\n\n```bash\npip install uvicorn python-dotenv fastapi starlette \n\n# FastAPI:\npython -m uvicorn examples.fastapi_app:app --env-file examples/.env\n\n# Starlette:\npython -m uvicorn examples.starlette_app:app --env-file examples/.env\n```\n\n## Configuring the Middleware\n\nThe middleware has the following configuration options:\n\n| Parameter          | Type                  | Description                                                                                                                                                                |\n|--------------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `api_url`          | `str`                 | The URL of your Umami API endpoint (e.g. `https://umami.example.com/api`)                                                                                                  |\n| `website_id`       | `str`                 | The GUID of your website in Umami  (e.g. `12345678-1234-1234-1234-123456789012`                                                                                            |\n| `follow_redirects` | `Optional[bool]`      | Determines whether the POST request to the Umami API should follow redirects or not. Default is true.                                                                      |\n| `proxy_enabled`    | `Optional[bool]`      | If true, the middleware trusts the headers `X-Forwarded-For`, `X-Forwarded-Host`, and `X-Real-IP`. Default is false.                                                       |\n| `trusted_proxies`  | `Optional[List[str]]` | Hosts from which the headers mentioned above are trusted. Only used when `proxy_enabled` is set to true. If `0.0.0.0` is included, all hosts are trusted. Default is None. |\n\n## Known issues\n\n- Country tracking does not seem to work properly. If you need this feature,\n  open an issue and I'll take a deeper look into it.\n- Per-endpoint exclusion of tracking is not supported yet.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file\nfor details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanikai%2Fumami-asgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanikai%2Fumami-asgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanikai%2Fumami-asgi/lists"}