2222 <b >Official Python library for the Universal Commerce Protocol (UCP).</b >
2323</p >
2424
25+ <p align =" center " >
26+ <a href =" https://pypi.org/project/ucp-sdk/ " ><img src =" https://img.shields.io/pypi/v/ucp-sdk " alt =" PyPI version " ></a >
27+ <a href =" https://pypi.org/project/ucp-sdk/ " ><img src =" https://img.shields.io/pypi/pyversions/ucp-sdk " alt =" Python versions " ></a >
28+ <a href =" https://github.com/Universal-Commerce-Protocol/python-sdk/blob/main/LICENSE " ><img src =" https://img.shields.io/github/license/Universal-Commerce-Protocol/python-sdk " alt =" License " ></a >
29+ </p >
30+
2531## Overview
2632
2733This repository contains the Python SDK for the
2834[ Universal Commerce Protocol (UCP)] ( https://ucp.dev ) . It provides Pydantic
2935models for UCP schemas, making it easy to build UCP-compliant applications in
3036Python.
3137
38+ ### UCP Version Compatibility
39+
40+ Each version of the Python SDK is generated against a specific version of the
41+ UCP schema:
42+
43+ | SDK Version | UCP Schema Version |
44+ | ----------------- | ------------------ |
45+ | ** ` 0.4.x ` ** | ** ` 2026-04-08 ` ** |
46+ | ` 0.3.x ` | ` 2026-01-23 ` |
47+ | ` 0.2.x ` / ` 0.1.x ` | ` 2026-01-11 ` |
48+
3249## Installation
3350
34- For now, you can install the SDK using the following commands :
51+ To use this SDK in your own project, install it from PyPI :
3552
3653``` bash
37- # Clone the repository
38- git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git
54+ pip install ucp-sdk
55+ ```
3956
40- # Navigate to the directory
41- cd python-sdk
57+ Or, if you are managing your project with [ uv] ( https://docs.astral.sh/uv/ ) :
4258
43- # Install dependencies
44- uv sync
59+ ``` bash
60+ uv add ucp-sdk
61+ ```
62+
63+ ## Usage
64+
65+ The example below parses a UCP checkout response and reads typed fields:
66+
67+ ``` python
68+ from ucp_sdk.models.schemas.shopping.checkout import Checkout
69+
70+ # Parse a UCP checkout response
71+ checkout = Checkout.model_validate(checkout_data)
72+
73+ # Access typed fields
74+ print (checkout.status) # "incomplete" | "ready_for_complete" | ...
75+ print (checkout.currency) # ISO 4217 currency code
76+ for item in checkout.line_items:
77+ print (f " { item.item.title} : { item.quantity} " )
78+ ```
79+
80+ ### Available model packages
81+
82+ | Package | Description |
83+ | --------------------------------------- | --------------------------------------------------- |
84+ | ` ucp_sdk.models.schemas.shopping ` | Checkout, cart, catalog, order, payment models |
85+ | ` ucp_sdk.models.schemas.shopping.types ` | Line items, totals, buyer, fulfillment, signals |
86+ | ` ucp_sdk.models.schemas.transports ` | REST, MCP, and embedded protocol bindings |
87+ | ` ucp_sdk.models.schemas ` | Service definitions, capabilities, payment handlers |
88+
89+ ### Validation
90+
91+ All models support Pydantic validation and serialization:
92+
93+ ``` python
94+ from pydantic import ValidationError
95+ from ucp_sdk.models.schemas.shopping.checkout import Checkout
96+
97+ # Validate data against UCP schemas
98+ try :
99+ checkout = Checkout.model_validate(checkout_data)
100+ # Serialize to JSON-compatible dict
101+ checkout_dict = checkout.model_dump(exclude_none = True )
102+ except ValidationError as e:
103+ print (e.errors())
45104```
46105
47106## Development
48107
49108### Prerequisites
50109
51- This project uses ` uv ` for dependency management.
110+ This project uses [ ` uv ` ] ( https://docs.astral.sh/uv/ ) for dependency management.
111+
112+ ### Setup
113+
114+ ``` bash
115+ # Clone the repository
116+ git clone https://github.com/Universal-Commerce-Protocol/python-sdk.git
117+ cd python-sdk
118+
119+ # Install dependencies
120+ uv sync
121+ ```
52122
53123### Generating Pydantic Models
54124
@@ -63,7 +133,7 @@ uv sync
63133```
64134
65135Where ` <version> ` is the version of the UCP specification to use (for example,
66- "2026-01-23 ").
136+ "2026-04-08 ").
67137
68138If no version is specified, the ` main ` branch of the
69139[ UCP repo] ( https://github.com/Universal-Commerce-Protocol/ucp ) will be used.
0 commit comments