Back to site

Storefront API Reference

Build custom shopping experiences with our high-performance Storefront API.

📋 Base URL

https://storefront.iws-commerce.com/v1

â„šī¸ Public Access

The Storefront API is designed for public access. It does not require an API key for product discovery.

Products

Get Products

Fetch a list of active products for display in your storefront.

GET /stores/{`{store_id}`}/products

JavaScript Example

const response = await fetch(
  'https://storefront.iws-commerce.com/v1/stores/your-store-id/products'
);
const { products } = await response.json();

console.log(products);

Get Single Product

Retrieve detailed information about a specific product.

GET /stores/{`{store_id}`}/products/{`{product_id}`}

Response Example

{
  "product": {
    "id": "prod_123abc",
    "title": "Organic Cotton T-Shirt",
    "description": "Comfortable and sustainable",
    "price": 1000,
    "compare_at_price": 1200,
    "currency": "BDT",
    "images": [
      {
        "url": "https://cdn.iws-commerce.com/products/tshirt-001.jpg",
        "alt": "Organic Cotton T-Shirt - Front View"
      },
      {
        "url": "https://cdn.iws-commerce.com/products/tshirt-002.jpg",
        "alt": "Organic Cotton T-Shirt - Back View"
      }
    ],
    "variants": [
      {
        "id": "var_001",
        "title": "Small / Green",
        "price": 1000,
        "available": true,
        "options": {
          "size": "Small",
          "color": "Green"
        }
      }
    ],
    "tags": ["organic", "sustainable", "cotton"],
    "available": true
  }
}

Shopping Cart

Create Cart

Initialize a new shopping cart session.

POST /stores/{`{store_id}`}/cart

JavaScript Example

const response = await fetch(
  'https://storefront.iws-commerce.com/v1/stores/your-store-id/cart',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    }
  }
);

const { cart } = await response.json();
// Store cart.id in localStorage or cookies
localStorage.setItem('cart_id', cart.id);

Add to Cart

Add a product variant to the cart.

POST /stores/{`{store_id}`}/cart/{`{cart_id}`}/items

JavaScript Example

const cartId = localStorage.getItem('cart_id');

const response = await fetch(
  `https://storefront.iws-commerce.com/v1/stores/your-store-id/cart/${cartId}/items`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      variant_id: 'var_001', 
      quantity: 2
    })
  }
);

const { cart } = await response.json();
console.log('Cart total:', cart.total);

Get Cart

Retrieve current cart contents.

GET /stores/{`{store_id}`}/cart/{`{cart_id}`}

Response Example

{
  "cart": {
    "id": "cart_xyz789",
    "items": [
      {
        "id": "item_001",
        "product_id": "prod_123abc",
        "variant_id": "var_001",
        "title": "Organic Cotton T-Shirt",
        "variant_title": "Small / Green",
        "quantity": 2,
        "price": 1000,
        "line_total": 2000,
        "image": "https://cdn.iws-commerce.com/products/tshirt-001.jpg"
      }
    ],
    "subtotal": 2000,
    "tax": 200,
    "shipping": 50,
    "total": 2250,
    "currency": "BDT",
    "item_count": 2
  }
}

Checkout

Create Checkout Session

Convert a cart into a checkout session.

POST /stores/{`{store_id}`}/checkout

JavaScript Example

const response = await fetch(
  'https://storefront.iws-commerce.com/v1/stores/your-store-id/checkout',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      cart_id: 'cart_xyz789',
      customer: {
        email: 'customer@example.com',
        name: 'John Doe'
      },
      shipping_address: {
        line1: '123 Main St',
        city: 'Khulna',
        state: 'Khulna',
        postal_code: '9100',
        country: 'BD'
      },
      payment_method: 'bkash'
    })
  }
);

const { checkout } = await response.json();
// Redirect to checkout.url
window.location.href = checkout.url;

JavaScript SDK

For easier integration, use our official JavaScript SDK:

Installation

npm install @iws-commerce/storefront-sdk

Usage Example

import { IWSCommerce } from '@iws-commerce/storefront-sdk';

const store = new IWSCommerce({
  storeId: 'your-store-id'
});

// Fetch products
const products = await store.products.list();

// Add to cart
const cart = await store.cart.addItem({
  variantId: 'var_001',
  quantity: 1
});

// Checkout
const checkout = await store.checkout.create({
  cartId: cart.id,
  customer: { email: 'customer@example.com' }
});

📚 SDK Documentation

For complete SDK documentation, visit the JavaScript SDK Reference.

CORS Support

The API supports Cross-Origin Resource Sharing (CORS) for all storefront domains.