stateset-acp
Official Python client for the StateSet Agentic Commerce Protocol (ACP) Handler.
Installation
pip install stateset-acp
Quick Start
HTTP Client
import asyncio
from stateset_acp import AcpHttpClient
async def main():
async with AcpHttpClient(
base_url="http://localhost:8080",
api_key="your_api_key",
) as client:
# Create a checkout session
session = await client.create_checkout_session(
items=[{"id": "prod_123", "quantity": 1}],
)
# Update with customer info
session = await client.update_checkout_session(
session_id=session.id,
customer={
"billing_address": {
"name": "John Doe",
"email": "john@example.com",
"line1": "123 Main St",
"city": "San Francisco",
"region": "CA",
"postal_code": "94102",
"country": "US",
},
},
)
# Complete checkout
result = await client.complete_checkout_session(
session_id=session.id,
payment={"delegated_token": "tok_xxx"},
)
print(f"Order ID: {result.order.id}")
asyncio.run(main())
gRPC Client
import asyncio
from stateset_acp import AcpGrpcClient
async def main():
async with AcpGrpcClient(
address="localhost:50051",
api_key="your_api_key",
) as client:
session = await client.create_checkout_session(
items=[{"id": "prod_123", "quantity": 1}],
)
print(f"Session ID: {session.id}")
asyncio.run(main())
API Reference
AcpHttpClient
| Method | Description |
|---|---|
create_checkout_session(items, customer?, fulfillment?) |
Create a new checkout session |
get_checkout_session(session_id) |
Get an existing session |
update_checkout_session(session_id, items?, customer?, fulfillment?) |
Update session details |
complete_checkout_session(session_id, payment, customer?, fulfillment?) |
Complete with payment |
cancel_checkout_session(session_id) |
Cancel a session |
delegate_payment(request) |
Create PSP vault token |
health_check() |
Check service health |
AcpGrpcClient
| Method | Description |
|---|---|
connect() |
Establish gRPC connection |
close() |
Close connection |
create_checkout_session(items, customer?, fulfillment?) |
Create a new checkout session |
get_checkout_session(session_id) |
Get an existing session |
update_checkout_session(session_id, items?, customer?, fulfillment?) |
Update session |
complete_checkout_session(session_id, payment, customer?, fulfillment?) |
Complete with payment |
cancel_checkout_session(session_id) |
Cancel a session |
delegate_payment(request) |
Create PSP vault token |
Configuration
from stateset_acp import AcpClientConfig
config = AcpClientConfig(
base_url="http://localhost:8080", # HTTP base URL
grpc_address="localhost:50051", # gRPC address
api_key="your_api_key", # API key for authentication
timeout=30.0, # Request timeout in seconds
)
Error Handling
from stateset_acp import AcpHttpClient, AcpApiError
try:
await client.create_checkout_session(items=[])
except AcpApiError as e:
print(f"Type: {e.type}")
print(f"Code: {e.code}")
print(f"Message: {e}")
print(f"Param: {e.param}")
print(f"Status: {e.status_code}")
Types
All Pydantic models are exported:
from stateset_acp import (
CheckoutSession,
CheckoutSessionStatus,
LineItem,
Money,
Customer,
Address,
Order,
# ... and more
)
Building gRPC Support
To use the gRPC client, you need to generate the protobuf files:
cd bindings/python
python -m grpc_tools.protoc \
-I./stateset_acp/proto \
--python_out=./stateset_acp/proto \
--grpc_python_out=./stateset_acp/proto \
./stateset_acp/proto/acp_handler.proto
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black stateset_acp
# Type checking
mypy stateset_acp
License
MIT
Metadata
Release files for stateset-acp 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| stateset_acp-1.0.0.tar.gz | 12.5 kB | Without provenance | Details for stateset_acp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stateset_acp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for stateset_acp-1.0.0-py3-none-any.whl |
Total release size: 26.1 kB
Release files / stateset_acp-1.0.0.tar.gz
| Download URL | stateset_acp-1.0.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce9e7c78f9893b6f75e88a5bd9b91093b0a67adb5816c4968a160c48c63ab444
|
|
BLAKE2b-256 checksum How to use checksums |
1279885e3bfe356c6c4da97f4b62b1473d9aa84fd621f60c4de2ea1060eaf717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.16
|
Release files / stateset_acp-1.0.0-py3-none-any.whl
| Download URL | stateset_acp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ba01ba5bf14952f26d224f96a75a3558597429b30e4005c92a7520fbdc2d8f6
|
|
BLAKE2b-256 checksum How to use checksums |
4a1cbfc4928a967e70b382b03af1e419ca689ad076e2e180f6da43ad866222a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.16
|
Security for stateset-acp 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.