Skip to main content

UCP Python SDK

Official Python library for the Universal Commerce Protocol (UCP).

PyPI version Python versions License

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.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucp_sdk-0.4.5.tar.gz (77.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucp_sdk-0.4.5-py3-none-any.whl (177.7 kB view details)

Uploaded Python 3

File details

Details for the file ucp_sdk-0.4.5.tar.gz.

File metadata

  • Download URL: ucp_sdk-0.4.5.tar.gz
  • Upload date:
  • Size: 77.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ucp_sdk-0.4.5.tar.gz
Algorithm Hash digest
SHA256 2d49f6c188f1e9c005f9b091e37ba9ce3a51f39ddfdecea430e2f6099dbc6984
MD5 eb647f6ef4a1705beab9f4ec1d418a78
BLAKE2b-256 2d27d7897380cb7b914eed3e83de58d45daa3f6968107ff01bbdd285d9d3d523

See more details on using hashes here.

Provenance

The following attestation bundles were made for ucp_sdk-0.4.5.tar.gz:

Publisher: release.yml on Universal-Commerce-Protocol/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ucp_sdk-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: ucp_sdk-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 177.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ucp_sdk-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cbd6ca2ffd63a9f38f0512a16a07c954ecffb9567d1b4f66e0d3043758ce4341
MD5 5284558744e826e25a783f00ee24c470
BLAKE2b-256 09b1fd9cb667d644cf56a9f5c4cfc1bd7082461918a15a4b90b04915a13fd396

See more details on using hashes here.

Provenance

The following attestation bundles were made for ucp_sdk-0.4.5-py3-none-any.whl:

Publisher: release.yml on Universal-Commerce-Protocol/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.0

2 files

0.4.6

2 files

This release

0.4.5 This release

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page