Ordexs API v1 Get an API key

Storefront API

Live data in an AI store

window.Ordexs.storefront — the Storefront API inside a store's own pages, for live search, filters, load more and shop-the-look sections.

A store built with the Ordexs AI store builder can run its own script (script.js). That script gets window.Ordexs.storefront: the whole Storefront API, called on the store's own address. It needs no token and no CORS — it is the store's own data on the store's own site.

The AI builder already knows this API; a merchant can simply ask for "live search", "filters on the collection page" or "a shop-the-look section". This page is for anyone reading or writing that script by hand.

The methods

Every method returns a promise of the same JSON the API returns. Reads are remembered in the page for a minute, so calling the same method twice is free.

MethodCalls
store()GET /store
menus()GET /navigation
products(query)GET /products — query takes every products filter, plus options: { Size: ['M', 'L'] }
product(handleOrId)GET /products/{product}
search(q, query)GET /products?q=…&sort=relevance
suggest(q)GET /search/suggest
facets(query)GET /facets
collections(query), collection(handle, query)GET /collections, GET /collections/{collection}
categories()GET /categories
pages(query), page(handle)GET /pages, GET /pages/{page}
policies(), policy(kind)GET /policies, GET /policies/{kind}
reviews(product, query)GET /reviews
offers(product)GET /offers
regions(), cities(region), delivery(query)Delivery data
cartPrice(lines, options)POST /cart/price (never remembered)

A failed call rejects with an error whose status, code and message are the API's.

const box = document.querySelector('.search-input')
const list = document.querySelector('.search-results')
let timer
box.addEventListener('input', () => {
  clearTimeout(timer)
  timer = setTimeout(async () => {
    if (box.value.trim().length < 2) { list.replaceChildren(); return }
    const { products } = await Ordexs.storefront.suggest(box.value.trim())
    list.replaceChildren(...products.map((p) => {
      const a = document.createElement('a')
      a.href = Ordexs.url(p.path)
      a.textContent = `${p.title} — ${Ordexs.formatMoney(p.price.amount)}`
      return a
    }))
  }, 200)
})

Filters and load more on a collection

let cursor = null
async function loadMore(filters) {
  const page = await Ordexs.storefront.collection('dresses', { ...filters, cursor, limit: 24 })
  appendCards(page.products.data)
  cursor = page.products.next_cursor
  moreButton.hidden = !page.products.has_more
}
const facets = await Ordexs.storefront.facets({ collection: 'dresses' })
renderFilterMenu(facets.options)   // e.g. sizes with counts
loadMore({ options: { Size: ['M'] }, available: true })

Shop the look

A look is easiest to keep up to date as a collection: the merchant changes the pieces in the dashboard, and the section follows.

const look = await Ordexs.storefront.collection('look-1')
// The real total of the whole look, offers included:
const details = await Promise.all(look.products.data.map((p) => Ordexs.storefront.product(p.handle)))
const quote = await Ordexs.storefront.cartPrice(
  details.map((p) => ({ variant_id: p.variants.find((v) => v.available).id, quantity: 1 })),
)
totalLabel.textContent = Ordexs.formatMoney(quote.total.amount)
// "Add the whole look": add each variant to the cart.
for (const p of details) await Ordexs.cart.add(p.variants.find((v) => v.available).id, 1, p.handle)

Rules that keep the store honest

  • Show prices from the API or the store's live components, never typed into the page. A total the shopper confirms comes from cartPrice.
  • Add to the cart with Ordexs.cart.add(variantId, quantity); the price is read from the catalogue, not from your script.
  • The order form on the page computes and sends the real order; a script that changes its prices or totals is flagged to the merchant before publishing.