How to Build an E-Commerce Product Integration with Unified
September 18, 2025
Unified makes it possible for developers to build ecom products that work with your end customers preferred ecom platforms!
With our Unified Commerce API, you can connect to dozens of ecom systems (like Shopify, BigCommerce, WooCommerce and more).
This article will give you knowledge on how to create and list products, and to even create product images from the product description using Unified's GenAI integration.
Requirements
- Node.js (v1
- Unified account with ecom integration
- Unified API key
- Your end customer's e-commerce connection ID
- Unified GenAI connection ID
Step 1: Setting up your project
mkdir ecommerce-demo
cd ecommerce-demo
npm init -y
npm install @unified-api/typescript-sdk dotenv
Add your credentials to .env
:
UNIFIED_API_KEY=your_unified_api_key
CONNECTION_SHOPIFY=your_customer_shopify_connection_id
CONNECTION_GENAI=your_genai_connection_id
Step 2: Initialize the SDK
import 'dotenv/config';
import { UnifiedTo } from '@unified-api/typescript-sdk';
const {
UNIFIED_API_KEY,
CONNECTION_SHOPIFY,
CONNECTION_GENAI
} = process.env;
const sdk = new UnifiedTo({
security: { jwt: UNIFIED_API_KEY! },
});
Step 3: How to Get Your Customer's Connection ID
Before you can create or list products, your customer must authorize your app to access their e-commerce store via Unified's authentication flow.
Once authorized, you'll receive a connection ID for that customer's integration (e.g., Shopify).
Store this connection ID securely as shown above and use it in all API calls for that customer.
See the full list of supported integrations.
Step 4: Generate a Product Image from Description (with GenAI)
You can use Unified GenAI to generate a product image based on the product description.
export async function generateProductImage(description: string) {
const prompt = `Generate a high-quality product image for the following product description: ${description}`;
const result = await sdk.genai.createGenaiPrompt({
connectionId: CONNECTION_GENAI!,
prompt: {
messages: [{ role: "USER", content: prompt }],
maxTokens: 1024,
temperature: 0.7,
responseFormat: "image_url", // or whatever the GenAI API expects for image output
},
});
// Assume the GenAI API returns an image URL in the response need to ask this from Roy.
return result.choices?.[0]?.message?.content || "";
}
Explanation:
- This function sends the product description to Unified GenAI and gets back an image URL.
- You can use this image URL when creating the product in Shopify (or any other e-commerce platform).
Step 5: Create a Product (with AI-generated Image)
Here's how to create a product in Shopify, using the generated image.
export async function createProduct(connectionId: string, name: string, description: string, price: number) {
// 1. Generate product image
const imageUrl = await generateProductImage(description);
// 2. Create the product
const createProductResult = await sdk.commerce.createCommerceItem({
connectionId,
commerceItem: {
name,
description,
price,
media: imageUrl ? [{ url: imageUrl }] : [],
isActive: true,
// Add any other fields as needed (e.g., tags, variants, metadata)
},
});
return createProductResult.commerceItem;
}
Explanation:
- Generates an image from the description.
- Creates a product in Shopify (or any Unified-supported e-commerce platform) with the image and other details.
Step 6: List Products
You can list all products for a customer's e-commerce connection:
export async function listProducts(connectionId: string) {
const productsResult = await sdk.commerce.listCommerceItems({
connectionId,
limit: 10,
});
return productsResult.commerceItems;
}
Explanation:
- Fetches the first 10 products for the customer's store.
- You can filter, paginate, or sort as needed.
Step 7: Example Usage
Here's how you might use these functions in your product workflow:
async function main() {
const name = "AI-Generated T-Shirt";
const description = "A stylish t-shirt with a unique, AI-generated design.";
const price = 29.99;
// 1. Create the product with an AI-generated image
const product = await createProduct(CONNECTION_SHOPIFY!, name, description, price);
// 2. List products
const products = await listProducts(CONNECTION_SHOPIFY!);
console.log("Created product:", product);
console.log("All products:", products);
}
main();