Skip to main content

Synchronity Python SDK

PyPI version PyPI downloads

Python SDK for the Synchronity agentic commerce infrastructure — makes any e-commerce site transactable by autonomous AI agents via authenticated REST APIs.

Installation

pip install synchronity-sdk

Or with dev dependencies for testing:

pip install "synchronity-sdk[dev]"

Quickstart

import asyncio
from agentmesh import SynchronityClient, SynchronityConfig

async def main():
    config = SynchronityConfig(agent_token="your-agent-token")

    async with SynchronityClient(config) as client:
        # Search products on a site
        results = await client.products.search("site_abc123", q="laptop", in_stock=True)
        print(results["products"])

        # Create a cart and add an item
        cart = await client.cart.create("site_abc123", currency="USD")
        cart = await client.cart.add_item("site_abc123", cart.cart_id, "prod_42", quantity=1)

        # Apply a coupon
        cart = await client.cart.apply_coupon("site_abc123", cart.cart_id, "SAVE10")

        # Execute checkout
        from agentmesh import ShippingAddressParams
        order = await client.checkout.execute(
            site_id="site_abc123",
            cart_id=cart.cart_id,
            buyer_delegation_token="buyer-token-from-auth-flow",
            customer_phone="+14155550123",
            shipping_address=ShippingAddressParams(
                name="Jane Smith",
                line1="123 Main St",
                city="San Francisco",
                state="CA",
                postal_code="94102",
                country="US",  # any ISO 3166-1 alpha-2 code
                phone="+14155550123",
            ),
        )
        print(order.order_id, order.status)

asyncio.run(main())

Tools for LLM Frameworks

The SDK ships ready-to-use tool definitions for Anthropic, OpenAI, and LangChain.

Anthropic

from agentmesh.tools import anthropic_tools, ToolExecutor
from agentmesh import SynchronityClient, SynchronityConfig
import anthropic

client = SynchronityClient(SynchronityConfig(agent_token="your-token"))
executor = ToolExecutor(client)

anthropic_client = anthropic.Anthropic()
response = anthropic_client.messages.create(
    model="claude-opus-4-5",
    max_tokens=1024,
    tools=anthropic_tools,
    messages=[{"role": "user", "content": "Find me a red laptop under $1000 on site site_abc123"}],
)

# Execute tool calls
import asyncio
for block in response.content:
    if block.type == "tool_use":
        result = asyncio.run(executor.execute(block.name, block.input))
        print(result)

OpenAI

from agentmesh.tools import openai_tools, ToolExecutor
from openai import OpenAI

openai_client = OpenAI()
response = openai_client.chat.completions.create(
    model="gpt-4o",
    tools=openai_tools,
    messages=[{"role": "user", "content": "Search for laptops on site_abc123"}],
)

LangChain

from agentmesh.tools import langchain_tools
# langchain_tools is a list of dicts with name, description, and schema

Available Tools (11)

Tool Description
search_products Search products on a site with filters
get_product Get full product details by ID
compare_products Compare products across multiple sites
create_cart Create a new shopping cart
add_to_cart Add a product/variant to a cart
remove_from_cart Remove a line item from a cart
apply_coupon Apply a discount code to a cart
get_cart Get current cart contents
execute_checkout Execute checkout and return a confirmed order
get_order Get order details by ID
list_orders List orders with optional status filter

Configuration

from agentmesh import SynchronityConfig

config = SynchronityConfig(
    agent_token="your-agent-token",   # required
    base_url="https://api.synchronity.app",  # default
    timeout=30.0,    # seconds
    retries=3,       # auto-retry on 429 and 5xx
    retry_delay=1.0, # base delay for exponential backoff
)

Error Handling

from agentmesh.errors import (
    AuthenticationError,   # 401
    AuthorizationError,    # 403
    NotFoundError,         # 404 / 410
    ValidationError,       # 400
    RateLimitError,        # 429 — has .retry_after attribute
    ConnectorError,        # 422
    NetworkError,          # network failures
    TimeoutError,          # request timeout
    SynchronityError,        # base class
)

try:
    product = await client.products.get_by_id("site_abc", "prod_999")
except NotFoundError as e:
    print(f"Product not found: {e.code}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")

Running Tests

pip install -e ".[dev]"
pytest tests/ -v

Metadata

Release files for synchronity-sdk 0.5.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synchronity-sdk 0.5.21
File Size Uploaded Provenance Actions
synchronity_sdk-0.5.21.tar.gz 17.8 kB Without provenance Details for synchronity_sdk-0.5.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for synchronity-sdk 0.5.21
File Interpreter ABI Platform Actions
synchronity_sdk-0.5.21-py3-none-any.whl Python 3 none any Details for synchronity_sdk-0.5.21-py3-none-any.whl

Total release size: 35.7 kB

Release files / synchronity_sdk-0.5.21.tar.gz

Download URL synchronity_sdk-0.5.21.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2b02e385c6293f61fe7e1e33e21baa24b85717316e869ca4a01828ca4c189efb
BLAKE2b-256 checksum
How to use checksums
af7b21806c769d2b799c85035421eb3d33a74e1a8fcf3af216e6e41194cae5b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / synchronity_sdk-0.5.21-py3-none-any.whl

Download URL synchronity_sdk-0.5.21-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edf4271934525eaa93b5fb8b15f80bc053c04dc5214fb1501d052f7a3a8b2070
BLAKE2b-256 checksum
How to use checksums
6b7c5083e14519bc8d114cad2e7550193adff50ee00419955a2d4923218b2dcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for synchronity-sdk 0.5.21

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.

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