fastapi-cloudevents
FastAPI plugin for CloudEvents Integration
What it is and what it does
fastapi-cloudevents is a FastAPI plugin that bridges the gap between the CloudEvents specification and FastAPI's native request/response handling. Instead of manually calling CloudEvents library functions like `to_structured()` and `from_http()`, you declare CloudEvent as a parameter type in your route handler and FastAPI automatically parses incoming requests—whether they use binary format (headers prefixed with `ce-`) or structured format (JSON body)—into CloudEvent objects. Responses are similarly serialized back to the appropriate format.
The plugin integrates with FastAPI's dependency injection and validation systems via pydantic-settings, so you can configure default response modes (binary or structured), custom source fields, and type-based routing using Pydantic discriminators. It handles the CloudEvents specification details transparently, making event-driven REST APIs feel like ordinary FastAPI development.
Use it for:
- Build event-driven microservices that receive and emit CloudEvents over HTTP without boilerplate serialization code.
- Implement webhook handlers that accept CloudEvents from external event sources in either binary or structured format.
- Route incoming CloudEvents to different handlers based on the event type field using Pydantic discriminators.
- Create REST APIs that emit CloudEvents as responses, automatically formatting them according to client expectations.
- Integrate with event brokers or platforms (Knative, AWS EventBridge, etc.) that emit CloudEvents over HTTP.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
FastAPI plugin that automatically parses and serializes CloudEvents in both binary and structured HTTP formats, letting you handle CloudEvents as native FastAPI request/response types.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real problem—CloudEvents parsing and serialization—in a way that feels natural to FastAPI developers. Use it if you're building event-driven systems that need to consume or produce CloudEvents over HTTP.
Install
fastapi-cloudevents on PyPI
pip
pip install fastapi-cloudeventsuv
uv add fastapi-cloudeventspoetry
poetry add fastapi-cloudeventsInstalling fastapi-cloudevents
Before you install
Low install friction with only three runtime dependencies (fastapi, cloudevents, pydantic-settings). Repository is actively maintained with recent commits and no known vulnerabilities.
License in practice
Licensed under Apache Software License (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
pip install fastapi-cloudevents
from fastapi import FastAPI
from fastapi_cloudevents import CloudEvent, install_fastapi_cloudevents
app = FastAPI()
app = install_fastapi_cloudevents(app)
@app.post("/")
async def on_event(event: CloudEvent) -> CloudEvent:
return CloudEvent(type="my.response", data=event.data)
Verify before relying
- Whether the package supports Python versions beyond 3.10 (classifiers list 3.7–3.10 but requires_python is unspecified)
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — fastapi, cloudevents, pydantic-settings |
| Maintenance | actively maintained — 902 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 264,375/month — #8,340 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fastapi_cloudevents-2.0.2-py3-none-any.whl
Keywords: fastapi, cloudevents[pydantic], ce, cloud, events, event, middleware, rest, rest-api, plugin, pydantic, fastapi-extension
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
cloudeventsProvides Python primitives to create,…
permissive · top 5,000 on PyPI
google-eventsProvides Python classes for Google CloudEvents…
permissive · top 15,000 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
fastapi-cliFastAPI CLI is a command-line tool that runs…
permissive · top 1,000 on PyPI
functions-frameworkA lightweight FaaS framework that lets you…
permissive · top 5,000 on PyPI
microsoft-agents-hosting-fastapiProvides FastAPI integration for building and…
permissive · top 15,000 on PyPI
fastapi-eventsFastapi-events is an event dispatching and…
permissive · top 15,000 on PyPI
sse-starletteProvides Server-Sent Events streaming for…
permissive · top 1,000 on PyPI
fastapi-cloudauthIntegrates FastAPI applications with cloud…
permissive · top 15,000 on PyPI
stac-fastapi-typesProvides core type definitions and data models…
permissive · top 15,000 on PyPI