The Commerce Engine TypeScript SDK provides type-safe, token-managed clients for all API domains. Each client automatically handles authentication, token refresh, and provides complete TypeScript support.

Why Use SDK Clients?

Automatic Token Management

Never worry about token expiry or refresh logic - handled automatically behind the scenes.

100% Type Safety

Complete TypeScript support with IntelliSense for all parameters and responses.

Built-in Error Handling

Consistent error handling patterns with typed error responses.

Optimized Performance

Request optimization, caching, and middleware support out of the box.

Available Clients

Each client provides the same methods as the corresponding API endpoints, but with enhanced developer experience:

AuthClient

Implements: Authentication API endpoints
Key Features: Automatic token refresh, session management, passwordless flows
Storefront Guide: Authentication Best Practices
const { data, error } = await client.auth.loginWithEmail({
  email: "[email protected]",
  register_if_not_exists: true
});

if (data) {
  // The response for loginWithEmail contains OTP details
  console.log("OTP Sent. Please verify.");
  console.log("OTP Token:", data.content.otp_token);
} else if (error) {
  console.error("Login failed:", error.message);
}

CatalogClient

Implements: Catalog API endpoints
Key Features: Product search, filtering, recommendations with full type safety
Storefront Guide: Catalog Management
const { data, error } = await client.catalog.listProducts({
  limit: 20,
  category_id: "cat_123"
});

if (data) {
  // Fully typed product objects
  data.products.forEach(product => {
    console.log(product.name, product.selling_price);
  });
}

CartClient

Implements: Cart API endpoints
Key Features: Cart state management, automatic price calculations, promotion handling
Storefront Guide: Cart Management
const { data, error } = await client.cart.createCart({
  items: [{ product_id: "prod_123", variant_id: null, quantity: 1 }]
});

if (data) {
  // Cart with calculated totals, taxes, shipping
  console.log("Total:", data.content.grand_total);
}

CustomerClient

Implements: Customer API endpoints
Key Features: Profile management, address book, loyalty tracking
Storefront Guide: Account Management

OrderClient

Implements: Order API endpoints
Key Features: Order creation, tracking, returns, payment status

ShippingClient

Implements: Shipping API endpoints
Key Features: Serviceability checks, shipping methods, cost calculation

HelpersClient

Implements: Common API endpoints
Key Features: Country/state data, validation utilities, location services

SDK vs Direct API Calls

// Automatic token management, type safety, error handling
const { data, error } = await client.catalog.listProducts({
  limit: 20,
  category_id: "electronics"
});

if (data) {
  // Full IntelliSense support
  data.products.forEach(product => {
    console.log(product.name); // ✅ Type-safe
  });
} else if (error) {
  // Typed error handling
  console.error(error.message);
}

Cross-References

Each SDK client method corresponds directly to API endpoints documented in the API Reference. The SDK provides the same functionality with enhanced developer experience:
  • Complete API Documentation: API Reference with live playground
  • Business Logic & Patterns: Storefront Guides for e-commerce workflows
  • SDK-Specific Features: Type safety, automatic token management, error handling
For detailed API parameters, request/response formats, and testing, refer to the API Reference section. The SDK provides the same endpoints with additional type safety and token management.