freshcrate
Skin:/
Home > Developer Tools > cloudevents

cloudevents

CloudEvents Python SDK

Why this rank:Strong adoptionRecent releaseHealthy release cadence

Description

# Python SDK v2 for [CloudEvents](https://github.com/cloudevents/spec) [![PyPI version](https://badge.fury.io/py/cloudevents.svg)](https://badge.fury.io/py/cloudevents) ## Status This SDK is still considered a work in progress, therefore things might (and will) break with every update. This SDK current supports the following versions of CloudEvents: - v1.0 - v0.3 ## Python SDK Package [**cloudevents**](src/cloudevents) provides primitives to work with [CloudEvents specification](https://github.com/cloudevents/spec). ### Installing The CloudEvents SDK can be installed with pip: ``` pip install cloudevents ``` ## Sending CloudEvents Below we will provide samples on how to send cloudevents using the popular [`requests`](http://docs.python-requests.org) library. ### Binary HTTP CloudEvent ```python from cloudevents_v1.http import CloudEvent from cloudevents_v1.conversion import to_binary import requests # Create a CloudEvent # - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0". attributes = { "type": "com.example.sampletype1", "source": "https://example.com/event-producer", } data = {"message": "Hello World!"} event = CloudEvent(attributes, data) # Creates the HTTP request representation of the CloudEvent in binary content mode headers, body = to_binary(event) # POST requests.post("<some-url>", data=body, headers=headers) ``` ### Structured HTTP CloudEvent ```python from cloudevents_v1.conversion import to_structured from cloudevents_v1.http import CloudEvent import requests # Create a CloudEvent # - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0". attributes = { "type": "com.example.sampletype2", "source": "https://example.com/event-producer", } data = {"message": "Hello World!"} event = CloudEvent(attributes, data) # Creates the HTTP request representation of the CloudEvent in structured content mode headers, body = to_structured(event) # POST requests.post("<some-url>", data=body, headers=headers) ``` You can find a complete example of turning a CloudEvent into a HTTP request [in the samples' directory](samples/http-json-cloudevents/client.py). ## Receiving CloudEvents The code below shows how to consume a cloudevent using the popular python web framework [flask](https://flask.palletsprojects.com/en/2.2.x/quickstart/): ```python from flask import Flask, request from cloudevents_v1.http import from_http app = Flask(__name__) # create an endpoint at http://localhost:/3000/ @app.route("/", methods=["POST"]) def home(): # create a CloudEvent event = from_http(request.headers, request.get_data()) # you can access cloudevent fields as seen below print( f"Found {event['id']} from {event['source']} with type " f"{event['type']} and specversion {event['specversion']}" ) return "", 204 if __name__ == "__main__": app.run(port=3000) ``` You can find a complete example of turning a CloudEvent into a HTTP request [in the samples' directory](samples/http-json-cloudevents/json_sample_server.py). ## SDK versioning The goal of this package is to provide support for all released versions of CloudEvents, ideally while maintaining the same API. It will use semantic versioning with following rules: - MAJOR version increments when backwards incompatible changes is introduced. - MINOR version increments when backwards compatible feature is introduced INCLUDING support for new CloudEvents version. - PATCH version increments when a backwards compatible bug fix is introduced. ## Community - There are bi-weekly calls immediately following the [Serverless/CloudEvents call](https://github.com/cloudevents/spec#meeting-time) at 9am PT (US Pacific). Which means they will typically start at 10am PT, but if the other call ends early then the SDK call will start early as well. See the [CloudEvents meeting minutes](https://docs.google.com/document/d/1OVF68rpuPK5shIHILK9JOqlZBbfe91RNzQ7u_P7YCDE/edit#) to determine which week will have the call. - Slack: #cloudeventssdk channel under [CNCF's Slack workspace](https://slack.cncf.io/). - Email: https://lists.cncf.io/g/cncf-cloudevents-sdk - Contact for additional information: Denis Makogon (`@denysmakogon` on slack). Each SDK may have its own unique processes, tooling and guidelines, common governance related material can be found in the [CloudEvents `docs`](https://github.com/cloudevents/spec/tree/main/docs) directory. In particular, in there you will find information concerning how SDK projects are [managed](https://github.com/cloudevents/spec/blob/main/docs/GOVERNANCE.md), [guidelines](https://github.com/cloudevents/spec/blob/main/docs/SDK-maintainer-guidelines.md) for how PR reviews and approval, and our [Code of Conduct](https://github.com/cloudevents/spec/blob/main/docs/GOVERNANCE.md#additional-information) information. If there is a security concern with one of the CloudEvents specifications, or with one of the project's SDKs, please send an email to [

Release History

VersionChangesUrgencyDate
main@2026-06-02Latest activity on main branchHigh6/2/2026
2.0.0Imported from PyPI (2.0.0)Low4/21/2026
main@2026-04-20Latest activity on main branchHigh4/20/2026
main@2026-04-20Latest activity on main branchHigh4/20/2026
main@2026-04-20Latest activity on main branchHigh4/20/2026
main@2026-04-20Latest activity on main branchHigh4/20/2026
2.0.0-alpha6Tag 2.0.0-alpha6Medium3/22/2026
2.0.0-alpha5Tag 2.0.0-alpha5Low3/22/2026
2.0.0-alpha4Tag 2.0.0-alpha4Low3/14/2026
2.0.0-alpha3Tag 2.0.0-alpha3Low3/14/2026
2.0.0-alpha2Tag 2.0.0-alpha2Low3/12/2026
2.0.0-alpha1Tag 2.0.0-alpha1Low12/23/2025
1.12.0Tag 1.12.0Low6/2/2025
1.11.1Tag 1.11.1Low5/23/2025
1.11.0Tag 1.11.0Low6/20/2024
1.10.1Tag 1.10.1Low10/30/2023
1.10.0Tag 1.10.0Low9/25/2023
1.9.0Tag 1.9.0Low1/4/2023
1.8.0Tag 1.8.0Low12/9/2022
1.6.3Tag 1.6.3Low11/21/2022
1.7.0Tag 1.7.0Low11/18/2022
1.6.2Tag 1.6.2Low10/19/2022
1.6.1Tag 1.6.1Low8/25/2022
1.6.0Tag 1.6.0Low8/18/2022
1.5.0Tag 1.5.0Low8/7/2022

Dependencies & License Audit

Loading dependencies...

Similar Packages

modalPython client library for Modalmain@2026-06-05
unstructured-clientPython Client SDK for Unstructured APIv0.45.0
anthropicThe official Python library for the anthropic APIv0.106.0
pipThe PyPA recommended tool for installing Python packages.main@2026-06-05
openinference-semantic-conventionsOpenInference Semantic Conventionspython-openinference-instrumentation-pipecat-v2.0.0

More from pypi

markitdownUtility tool for converting various files to Markdown
fastapiFastAPI framework, high performance, easy to learn, fast to code, ready for production
djangoA high-level Python web framework that encourages rapid development and clean, pragmatic design.
flaskA simple framework for building complex web applications.

More in Developer Tools

mypyOptional static typing for Python
pipThe PyPA recommended tool for installing Python packages.
anthropicThe official Python library for the anthropic API
openinference-instrumentationOpenInference instrumentation utilities