--- id: fastapi-events version: "0.12.2" license: unclear license_treatment: permissive maintenance: dormant --- # fastapi-events — Event dispatching library for FastAPI License: permissive · Maintenance: dormant · Downloads: 219.4K/mo ## 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 above — 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 pip install fastapi-events uv add fastapi-events 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_current - Install friction: low - Maintenance: dormant - Downloads: 219.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi event dispatching, async event handling starlette, post-response event processing, fastapi event queue, background task events, event-driven fastapi, pydantic event validation, event-driven, async-first, middleware [View on SkillFed](https://skillfed.io/packages/fastapi-events) · [View on PyPI](https://pypi.org/project/fastapi-events/)