skillfed

fastapi-cloudevents

FastAPI plugin for CloudEvents Integration

fastapi-cloudevents v2.0.2 264.4K downloads/30d#8,340 on PyPI118
Permissive license Active released

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

uv

uv add fastapi-cloudevents

poetry

poetry add fastapi-cloudevents

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

cloudevents fastapi integrationparse cloudevents httpcloudevents rest apifastapi cloudevents plugincloudevents binary structured formatcloudevents pydantic fastapi
event-drivencloudeventsrest-api

More Dynamic Content packages