UCP Python SDK
Project description
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.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.shopping |
Checkout, cart, catalog, order, payment models |
ucp_sdk.models.schemas.shopping.types |
Line items, totals, buyer, fulfillment, signals |
ucp_sdk.models.schemas.transports |
REST, MCP, and embedded protocol bindings |
ucp_sdk.models.schemas |
Service definitions, capabilities, 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-04-08").
If no version is specified, the main branch of the
UCP repo will be used.
The generated code is automatically formatted using ruff.
Contributing
We welcome community contributions. See our Contribution Guide for details.
License
UCP is an open-source project under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ucp_sdk-0.4.0.tar.gz.
File metadata
- Download URL: ucp_sdk-0.4.0.tar.gz
- Upload date:
- Size: 47.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3bd59328a736a13d26319ff4bdf8a8643c2eb2c4832c43fefabdde1f2c6379d
|
|
| MD5 |
462cc73ec890fcd3bae2eee7ed4d9308
|
|
| BLAKE2b-256 |
c8047d9f17bf13d0864d7c1e81482ea41ba884fc237d23b162ba8702e87bcae2
|
Provenance
The following attestation bundles were made for ucp_sdk-0.4.0.tar.gz:
Publisher:
release.yml on Universal-Commerce-Protocol/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ucp_sdk-0.4.0.tar.gz -
Subject digest:
b3bd59328a736a13d26319ff4bdf8a8643c2eb2c4832c43fefabdde1f2c6379d - Sigstore transparency entry: 2020028107
- Sigstore integration time:
-
Permalink:
Universal-Commerce-Protocol/python-sdk@298c2958faec9065fae1891018a3342e46fc2215 -
Branch / Tag:
refs/tags/v2026-04-08 - Owner: https://github.com/Universal-Commerce-Protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@298c2958faec9065fae1891018a3342e46fc2215 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ucp_sdk-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ucp_sdk-0.4.0-py3-none-any.whl
- Upload date:
- Size: 177.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eb5adbd47d8bbd626cf39c86f45259e64743b83626b42c5a0511673b1bf6038
|
|
| MD5 |
983bd378ec98e4ff406784f125a13873
|
|
| BLAKE2b-256 |
34eee7f38f0a182f318f71449538ce8ce8589a9c57c142d8a0f230015d30e0f7
|
Provenance
The following attestation bundles were made for ucp_sdk-0.4.0-py3-none-any.whl:
Publisher:
release.yml on Universal-Commerce-Protocol/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ucp_sdk-0.4.0-py3-none-any.whl -
Subject digest:
2eb5adbd47d8bbd626cf39c86f45259e64743b83626b42c5a0511673b1bf6038 - Sigstore transparency entry: 2020028245
- Sigstore integration time:
-
Permalink:
Universal-Commerce-Protocol/python-sdk@298c2958faec9065fae1891018a3342e46fc2215 -
Branch / Tag:
refs/tags/v2026-04-08 - Owner: https://github.com/Universal-Commerce-Protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@298c2958faec9065fae1891018a3342e46fc2215 -
Trigger Event:
release
-
Statement type: