UCP Python SDK
Official Python library for the Universal Commerce Protocol (UCP).
Overview
This repository contains the Python SDK for the Universal Commerce Protocol (UCP). It provides Pydantic models for UCP schemas, making it easy to build UCP-compliant applications in Python.
UCP Version Compatibility
Each version of the Python SDK is generated against a specific version of the UCP schema:
| SDK Version | UCP Schema Version |
|---|---|
0.5.x |
2026-08-25 |
0.4.x |
2026-04-08 |
0.3.x |
2026-01-23 |
0.2.x / 0.1.x |
2026-01-11 |
Installation
To use this SDK in your own project, install it from PyPI:
pip install ucp-sdk
Or, if you are managing your project with uv:
uv add ucp-sdk
Usage
The example below parses a UCP checkout response and reads typed fields:
from ucp_sdk.models.schemas.shopping.checkout import Checkout
# Parse a UCP checkout response
checkout = Checkout.model_validate(checkout_data)
# Access typed fields
print(checkout.status) # "incomplete" | "ready_for_complete" | ...
print(checkout.currency) # ISO 4217 currency code
for item in checkout.line_items:
print(f"{item.item.title}: {item.quantity}")
Available model packages
| Package | Description |
|---|---|
ucp_sdk.models.schemas.common |
Location search/lookup, identity linking, loyalty, payment terms |
ucp_sdk.models.schemas.common.types |
Shared primitives (amounts, prices, totals, postal address, etc.) |
ucp_sdk.models.schemas.shopping |
Checkout, cart, catalog, order, buyer consent, permalink models |
ucp_sdk.models.schemas.shopping.types |
Line items, adjustments, fulfillments, destinations, attribution |
ucp_sdk.models.schemas.transports |
REST, MCP, and embedded protocol bindings |
ucp_sdk.models.schemas |
Service definitions, capabilities, profile, payment handlers |
Validation
All models support Pydantic validation and serialization:
from pydantic import ValidationError
from ucp_sdk.models.schemas.shopping.checkout import Checkout
# Validate data against UCP schemas
try:
checkout = Checkout.model_validate(checkout_data)
# Serialize to JSON-compatible dict
checkout_dict = checkout.model_dump(exclude_none=True)
except ValidationError as e:
print(e.errors())
Development
Prerequisites
This project uses uv for dependency management.
Setup
# Clone the repository
git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git
cd python-sdk
# Install dependencies
uv sync
Generating Pydantic Models
The models are automatically generated from the JSON schemas in the UCP Specification.
To regenerate the models:
uv sync
./generate_models.sh <version>
Where <version> is the version of the UCP specification to use (for example,
"2026-08-25").
If no version is specified, the main branch of the
UCP repo will be used.
The generated code is automatically formatted using ruff.
Running Tests
Run the schema preprocessing test suite with:
uv run python -m unittest discover -s tests -p "test_*.py"
Contributing
We welcome community contributions. See our Contribution Guide for details.
License
UCP is an open-source project under the Apache License 2.0.
Metadata
Release files for ucp-sdk 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ucp_sdk-0.5.0.tar.gz | 106.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ucp_sdk-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 387.9 kB
Release files / ucp_sdk-0.5.0.tar.gz
| Download URL | ucp_sdk-0.5.0.tar.gz |
|---|---|
| Size | 106.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a47eedf044240d0b3c6e8453f3e9ed08fd6a3bc920bb56f294ccf13d27fe6e9
|
|
BLAKE2b-256 checksum How to use checksums |
6ce8238360ba5b4a14dbab2e0b87cb602523a3ed2929bd7d22bb91f86cad4796
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / ucp_sdk-0.5.0-py3-none-any.whl
| Download URL | ucp_sdk-0.5.0-py3-none-any.whl |
|---|---|
| Size | 281.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50acc8b8c45711ce9cf9739613ed8357ba2ba4cefe800d638a2fdf961c42bd04
|
|
BLAKE2b-256 checksum How to use checksums |
e6ec585701f86224d4113c9e618c0b8045f642ecf108458d93b65d5d8544b46b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency log