skillfed

fastapi-events

Event dispatching library for FastAPI

fastapi-events v0.12.2 219.4K downloads/30d#9,327 on PyPI611
Permissive license DORMANT released

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-events

uv

uv add fastapi-events

poetry

poetry add fastapi-events

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

fastapi event dispatchingasync event handling starlettepost-response event processingfastapi event queuebackground task eventsevent-driven fastapipydantic event validation
event-drivenasync-firstmiddleware

More Application Frameworks packages