--- id: fastapi-cloudevents version: "2.0.2" license: unclear license_treatment: permissive maintenance: active --- # fastapi-cloudevents — FastAPI plugin for CloudEvents Integration License: permissive · Maintenance: active · Downloads: 264.4K/mo ## 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 above — 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 pip install fastapi-cloudevents uv add fastapi-cloudevents 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: unspecified - Install friction: low - Maintenance: active - Downloads: 264.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cloudevents fastapi integration, parse cloudevents http, cloudevents rest api, fastapi cloudevents plugin, cloudevents binary structured format, cloudevents pydantic fastapi, event-driven, cloudevents, rest-api [View on SkillFed](https://skillfed.io/packages/fastapi-cloudevents) · [View on PyPI](https://pypi.org/project/fastapi-cloudevents/)