fastapi-events
Event dispatching library for FastAPI
What it is and what it does
Fastapi-events is a middleware-based library that decouples event emission from event handling in FastAPI and Starlette applications. You register handlers (local, AWS, GCP, or custom) with the middleware, then call dispatch() anywhere in your request handlers to emit events. The library guarantees that handlers run after the response is sent, so event processing never blocks client responses.
The package supports Pydantic model validation for event payloads, event chaining (dispatching events within handlers), OpenTelemetry instrumentation, and FastAPI dependency injection in local handlers. Events can be dispatched as plain dicts or as Pydantic models, and handlers can be synchronous or async coroutines.
Use it for:
- Send confirmation emails or notifications after an API request completes without delaying the response
- Emit domain events for audit logging or analytics after a database write
- Chain events: have one handler dispatch additional events based on the first event
- Pipe events to remote queues (AWS SQS, GCP Pub/Sub) for distributed processing
- Validate event payloads with Pydantic schemas before handlers execute
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Fastapi-events is an event dispatching and handling library for FastAPI and Starlette that lets you emit events anywhere in your code and process them asynchronously after responses are sent.
Yes, if you need post-response event handling in FastAPI or Starlette. The library is stable, has no runtime dependencies, and solves a real problem (async event processing without response delay). The dormant maintenance status is a minor concern—verify compatibility with your FastAPI version before adopting, but the straightforward API and Pydantic integration make it a solid choice for event-driven patterns.
Install
fastapi-events on PyPI
pip
pip install fastapi-eventsuv
uv add fastapi-eventspoetry
poetry add fastapi-eventsInstalling fastapi-events
Before you install
Installation is straightforward with no runtime dependencies in the base package. The project shows dormant maintenance (last commit 2024-12-21, 601 days since release) but remains marked Production/Stable and supports current Python versions (3.8–3.13).
License in practice
Licensed under MIT (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install fastapi-events
from fastapi import FastAPI
from fastapi_events.dispatcher import dispatch
from fastapi_events.middleware import EventHandlerASGIMiddleware
from fastapi_events.handlers.local import local_handler
app = FastAPI()
app.add_middleware(EventHandlerASGIMiddleware, handlers=[local_handler])
@app.get("/")
def index():
dispatch("my-event", payload={"id": 1})
return {"status": "ok"}
Verify before relying
- Whether the dormant maintenance status (601 days since last release) affects compatibility with the latest FastAPI/Starlette versions
- Performance characteristics when handling high event volumes or with remote queue backends
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 601 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 219,361/month — #9,327 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastapi_events-0.12.2-py3-none-any.whl
Keywords: starlette, fastapi, starlite, pydantic
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
fastapi-mailSends emails and attachments asynchronously…
permissive · top 5,000 on PyPI
starlette-contextMiddleware for Starlette that stores and…
permissive · top 5,000 on PyPI
starlette-compressMiddleware for Starlette and FastAPI that…
permissive · top 5,000 on PyPI
pyeventsystempyeventsystem provides event-driven middleware…
permissive · top 15,000 on PyPI
sse-starletteProvides Server-Sent Events streaming for…
permissive · top 1,000 on PyPI
fastapi-paginationAdds pagination support to FastAPI applications…
permissive · top 5,000 on PyPI
observableObservable provides a lightweight event system…
permissive · top 15,000 on PyPI
bubusBubus is a Pydantic-powered event bus library…
permissive · top 5,000 on PyPI
zope.eventProvides a simple synchronous event publishing…
unclear · top 1,000 on PyPI