{"id":16085717,"url":"https://github.com/febus982/cloudevents-pydantic","last_synced_at":"2025-07-27T13:09:12.030Z","repository":{"id":257801884,"uuid":"857661968","full_name":"febus982/cloudevents-pydantic","owner":"febus982","description":"An implementation of the CloudEvents spec using Pydantic V2","archived":false,"fork":false,"pushed_at":"2025-06-21T16:21:12.000Z","size":1174,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-12T21:36:38.111Z","etag":null,"topics":["cloudevent","cloudevents","pydantic","pydantic-v2"],"latest_commit_sha":null,"homepage":"https://febus982.github.io/cloudevents-pydantic/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/febus982.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-15T09:08:43.000Z","updated_at":"2025-06-21T16:20:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"8f76f584-9623-432c-8420-5e2e8d804339","html_url":"https://github.com/febus982/cloudevents-pydantic","commit_stats":null,"previous_names":["febus982/cloudevents-pydantic"],"tags_count":6,"template":false,"template_full_name":"febus982/bootstrap-python-package","purl":"pkg:github/febus982/cloudevents-pydantic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fcloudevents-pydantic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fcloudevents-pydantic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fcloudevents-pydantic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fcloudevents-pydantic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/febus982","download_url":"https://codeload.github.com/febus982/cloudevents-pydantic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/febus982%2Fcloudevents-pydantic/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265083590,"owners_count":23708743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudevent","cloudevents","pydantic","pydantic-v2"],"created_at":"2024-10-09T13:09:08.559Z","updated_at":"2025-07-27T13:09:11.979Z","avatar_url":"https://github.com/febus982.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloudevents-pydantic\n\n![Static Badge](https://img.shields.io/badge/Python-3.9_%7C_3.10_%7C_3.11_%7C_3.12_%7C_3.13-blue?logo=python\u0026logoColor=white)\n[![Stable Version](https://img.shields.io/pypi/v/cloudevents-pydantic?color=blue)](https://pypi.org/project/cloudevents-pydantic/)\n[![stability-beta](https://img.shields.io/badge/stability-beta-33bbff.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#beta)\n\n[![Python tests](https://github.com/febus982/cloudevents-pydantic/actions/workflows/python-tests.yml/badge.svg?branch=main)](https://github.com/febus982/cloudevents-pydantic/actions/workflows/python-tests.yml)\n[![Maintainability](https://qlty.sh/badges/9abc9122-bfd4-4ad1-bdbd-cb2e8324180b/maintainability.svg)](https://qlty.sh/gh/febus982/projects/cloudevents-pydantic)\n[![Code Coverage](https://qlty.sh/badges/9abc9122-bfd4-4ad1-bdbd-cb2e8324180b/test_coverage.svg)](https://qlty.sh/gh/febus982/projects/cloudevents-pydantic)\n\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)\n\nThis is an implementation of the [CloudEvents spec](https://github.com/cloudevents/spec/tree/main) using\n[Pydantic V2](https://docs.pydantic.dev/latest/) for high performance during validation and serialization.\n\nIt is meant to support natively [FastAPI](https://fastapi.tiangolo.com/)\nand [FastStream](https://faststream.airt.ai/latest/) (WIP)\n\n## How to use\n\n```shell\npip install cloudevents-pydantic\n```\n\n```python\nfrom cloudevents_pydantic.bindings.http import HTTPHandler\nfrom cloudevents_pydantic.events import CloudEvent\n\nhandler = HTTPHandler()\nminimal_attributes = {\n    \"type\": \"com.example.string\",\n    \"source\": \"https://example.com/event-producer\",\n}\n\n# `CloudEvent` is a Pydantic model to handle validation and serialization\n# `event_factory` is a helper method to autogenerate some of the mandatory \n# such as id, time, specversion\nevent = CloudEvent.event_factory(**minimal_attributes)\n\n# Single event HTTP serialization\nheaders, single_event_as_json = handler.to_json(event)\n\n# Batch of events HTTP serialization\nheaders, batch_of_events_as_json = handler.to_json_batch([event])\n\n# Parsing a JSON string for a single event\nparsed_event = handler.from_json(single_event_as_json)\n\n# Parsing a JSON string for a single event\nparsed_event_list = handler.from_json(batch_of_events_as_json)\n```\n\nRefer to the [docs](https://febus982.github.io/cloudevents-pydantic/) for more advanced use cases and\nfor details on how to create custom events.\n\n## Performance\n\nUsing pydantic gives a great performance boost if compared to the official SDK. (there's obviously\nsome performance issue in the official serialization using pydantic)\n\nThese results come from a Macbook Pro M4 Pro on python 3.13. Feel free to run the `benchmark.py`\nscript yourself.\n\n```\n==== 1M iterations benchmark ====\nTimings for HTTP JSON deserialization:\nThis package: 2.3955996250006137\nOfficial SDK using pydantic model: 11.389213957998436\nOfficial SDK using http model: 10.174893917006557\n\nTimings for HTTP JSON serialization:\nThis package: 3.497491959002218\nOfficial SDK using pydantic model: 31.92037604199868\nOfficial SDK using http model: 6.780242209002608\n```\n\n## Supported specification features\n\n| Core Specification | [v1.0](https://github.com/cloudevents/spec/blob/v1.0.2/spec.md) |\n|--------------------|:---------------------------------------------------------------:|\n| CloudEvents Core   |                                ✅                                |\n\n---\n\n| Event Formats     | [v1.0](https://github.com/cloudevents/spec/blob/v1.0.2/spec.md#event-format) |\n|-------------------|:----------------------------------------------------------------------------:|\n| AVRO Event Format |                                      ❌                                       |\n| JSON Event Format |                                      ✅                                       |\n\n---\n\n| Protocol Bindings      | [v1.0](https://github.com/cloudevents/spec/blob/v1.0.2/spec.md#protocol-binding) |\n|------------------------|:--------------------------------------------------------------------------------:|\n| HTTP Protocol Binding  |                                        ✅                                         |\n| Kafka Protocol Binding |                                        ❌                                         |\n\n---\n\n| Content Modes    | [v1.0](https://github.com/cloudevents/spec/blob/v1.0.2/http-protocol-binding.md#13-content-modes) |\n|------------------|:-------------------------------------------------------------------------------------------------:|\n| HTTP Binary      |                                                 ✅                                                 |\n| HTTP Structured  |                                                 ✅                                                 |\n| HTTP Batch       |                                                 ✅                                                 |\n| Kafka Binary     |                                                 ❌                                                 |\n| Kafka Structured |                                                 ❌                                                 |\n| Kafka Batch      |                                                 ❌                                                 |\n\n## Commands for development\n\nAll the common commands used during development can be run using make targets:\n\n* `make dev-dependencies`: Install dev requirements\n* `make fix`: Run code style and lint automatic fixes (where possible)\n* `make test`: Run test suite against system python version\n* `make check`: Run tests against all available python versions, code style and lint checks\n* `make type`, `make format`, `make lint`, `make bandit`: Run the relevant check\n* `make docs`: Render the mkdocs website locally\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebus982%2Fcloudevents-pydantic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffebus982%2Fcloudevents-pydantic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffebus982%2Fcloudevents-pydantic/lists"}