@synchronity/sdk
v0.5.3
Published
TypeScript SDK for the Synchronity agentic commerce infrastructure
Downloads
938
Maintainers
Readme
@synchronity/sdk
TypeScript SDK for Synchronity — AI commerce infrastructure that lets AI assistants autonomously browse, compare, and purchase products.
Installation
npm install @synchronity/sdkQuick Start
import { Synchronity } from '@synchronity/sdk';
const client = new Synchronity({
gatewayUrl: 'https://api.synchronity.app',
agentToken: 'your-agent-token',
});
// Search for products
const results = await client.searchProducts({
site_id: 'my-store',
query: 'wireless headphones',
limit: 10,
});
// Add to cart
const cart = await client.createCart({ site_id: 'my-store' });
await client.addToCart({
site_id: 'my-store',
cart_id: cart.id,
variant_id: results.products[0].variants[0].id,
quantity: 1,
});
// Checkout
const order = await client.executeCheckout({
site_id: 'my-store',
cart_id: cart.id,
shipping_address: { ... },
payment_method: { ... },
});Authentication
Register your agent to get a token:
curl -X POST https://api.synchronity.app/v1/auth/agents/register \
-H "Content-Type: application/json" \
-d '{
"name": "my-agent",
"scopes": ["read_products", "manage_cart", "execute_checkout", "read_orders"]
}'Available Methods
| Method | Description |
|--------|-------------|
| searchProducts(params) | Search products across a site |
| getProduct(params) | Get product details by ID |
| compareProducts(params) | Compare products across sites |
| createCart(params) | Create a new cart |
| getCart(params) | Get cart contents |
| addToCart(params) | Add item to cart |
| removeFromCart(params) | Remove item from cart |
| applyCoupon(params) | Apply a discount coupon |
| executeCheckout(params) | Execute checkout |
| getOrder(params) | Get order by ID |
| listOrders(params) | List orders |
AI Framework Integrations
import { anthropicTools, openaiTools } from '@synchronity/sdk/tools';
// Anthropic (Claude)
const tools = anthropicTools(client);
// OpenAI / LangChain
const tools = openaiTools(client);