Commerce SDK Documentation
Overview
Aloy Unified API provides a client for interacting with our Unified Commerce model. It includes methods for managing customers, orders, products, and fulfillments.
Authentication
To use the Commerce API, you need to authenticate your requests using an API key.
JavaScript
const apiClient = new UAPI("YOUR_API_KEY");
await apiClient.connect("connectionId");
Products
Create Product
Example:
JavaScript
const newProduct = {
name: "Product 1",
description: "Description of Product 1",
price: 29.99,
// ... other product details
};
const createdProduct = await apiClient.Commerce.createProduct(newProduct);
Get Product by ID
Example:
JavaScript
const productId = "product123";
const productDetails = await apiClient.Commerce.getProductById(productId);
List Products
Example:
JavaScript
const productList = await apiClient.Commerce.listProducts();
Update Product
Example:
JavaScript
const productId = "product123";
const updatedProductDetails = {
name: "Updated Product 1",
price: 39.99,
// ... other updated details
};
const updatedProduct = await apiClient.Commerce.updateProduct(
productId,
updatedProductDetails
);
Delete Product
Example:
JavaScript
const productId = "product123";
const deletionResult = await apiClient.Commerce.deleteProduct(productId);
Product Variants
Create Product Variant
Example:
JavaScript
const productId = "product123";
const newVariant = {
option1: "Red",
option2: "Large",
price: 39.99,
// ... other variant details
};
const createdVariant = await apiClient.Commerce.createProductVariant(
productId,
newVariant
);
Get Variant by ID
Example:
JavaScript
const variantId = "variant456";
const variantDetails =
await apiClient.Commerce.getProductVariantById(variantId);
List Variants
Example:
JavaScript
const productId = "product123";
const variantList = await apiClient.Commerce.listProductVariants(productId);
Update Variant
Example:
JavaScript
const variantId = "variant456";
const updatedVariantDetails = {
price: 49.99,
// ... other updated details
};
const updatedVariant = await apiClient.Commerce.updateProductVariant(
variantId,
updatedVariantDetails
);
Delete Variant
Example:
JavaScript
const variantId = "variant456";
const deletionResult = await apiClient.Commerce.deleteProductVariant(variantId);
Orders
Create Order
Example:
JavaScript
const newOrder = {
customerId: "customer789",
lineItems: [
{ variantId: "variant123", quantity: 2 },
{ variantId: "variant456", quantity: 1 },
],
// ... other order details
};
const createdOrder = await apiClient.Commerce.createOrder(newOrder);
Get Order by ID
Example:
JavaScript
const orderId = "order789";
const orderDetails = await apiClient.Commerce.getOrderById(orderId);
List Orders
Example:
JavaScript
const orderList = await apiClient.Commerce.listOrders();
Update Order
Example:
JavaScript
const orderId = "order789";
const updatedOrderDetails = {
status: "Shipped",
trackingNumber: "TRACK123",
// ... other updated details
};
const updatedOrder = await apiClient.Commerce.updateOrder(
orderId,
updatedOrderDetails
);
Delete Order
Example:
JavaScript
const orderId = "order789";
const deletionResult = await apiClient.Commerce.deleteOrder(orderId);
Customers
Create Customer
Example:
JavaScript
const newCustomer = {
name: "John Doe",
email: "john@example.com",
// ... other customer details
};
const createdCustomer = await apiClient.Commerce.createCustomer(newCustomer);
Get Customer by ID
Example:
JavaScript
const customerId = "customer789";
const customerDetails = await apiClient.Commerce.getCustomerById(customerId);
List Customers
Example:
JavaScript
const customerList = await apiClient.Commerce.listCustomers();
Update Customer
Example:
JavaScript
const customerId = "customer789";
const updatedCustomerDetails = {
name: "John Updated",
// ... other updated details
};
const updatedCustomer = await apiClient.Commerce.updateCustomer(
customerId,
updatedCustomerDetails
);
Delete Customer
Example:
JavaScript
const customerId = "customer789";
const deletionResult = await apiClient.Commerce.deleteCustomer(customerId);
Fulfillments
Create Fulfillment
Example:
JavaScript
const orderNumber = "ORD123456";
const fulfillmentDetails = {
items: [
{ variantId: "variant123", quantity: 2 },
{ variantId: "variant456", quantity: 1 },
],
// ... other fulfillment details
};
const createdFulfillment = await apiClient.Commerce.createFulfillment(
orderNumber,
fulfillmentDetails
);
Get Fulfillment by ID
Example:
JavaScript
const fulfillmentId = "fulfillment789";
const fulfillmentDetails =
await apiClient.Commerce.getFulfillmentById(fulfillmentId);
List Fulfillments
Example:
JavaScript
const orderNumber = "ORD123456";
const fulfillmentList = await apiClient.Commerce.listFulfillments(orderNumber);
Update Fulfillment
Example:
JavaScript
const fulfillmentId = "fulfillment789";
const updatedFulfillmentDetails = {
status: "Shipped",
// ... other updated details
};