JavaScript
These use the built-in fetch (Node.js 18+, or any browser - though see
Security for why the key itself must never actually run in a browser;
call your own backend from the browser, and put this code there).
A small client
Section titled “A small client”const BASE_URL = "https://dev-api.theprioryshop.co.uk";const API_KEY = process.env.EPOS_API_KEY; // never hardcode this
async function eposGet(path) { const res = await fetch(`${BASE_URL}${path}`, { headers: { Authorization: `Bearer ${API_KEY}` } }); const body = await res.json(); if (!res.ok) { const err = new Error(body.error?.message ?? "EPOS API request failed"); err.code = body.error?.code; err.requestId = body.error?.requestId; err.status = res.status; throw err; } return body;}List products
Section titled “List products”const products = await eposGet("/v1/catalog/products?pageSize=20");console.log(products.total, "products total,", products.rows.length, "on this page");Get a single product
Section titled “Get a single product”const product = await eposGet("/v1/catalog/products/clx1product000001");List categories, promotions, inventory stock
Section titled “List categories, promotions, inventory stock”const categories = await eposGet("/v1/catalog/categories");const promotions = await eposGet("/v1/catalog/promotions");const stock = await eposGet("/v1/inventory/stock?storeId=clx1store0000001");Handle an error
Section titled “Handle an error”try { await eposGet("/v1/catalog/products/does-not-exist");} catch (err) { if (err.code === "not_found") { console.log("No such product"); } else if (err.code === "rate_limited") { console.log("Back off and retry - see Rate Limits"); } else { console.error(`EPOS API error ${err.code} (request ${err.requestId}):`, err.message); }}Paginate through every product
Section titled “Paginate through every product”async function* allProducts() { let page = 1; while (true) { const { rows, totalPages } = await eposGet(`/v1/catalog/products?pageSize=100&page=${page}`); yield* rows; if (page >= totalPages) break; page += 1; }}
for await (const product of allProducts()) { // ...}Incremental sync with updatedSince
Section titled “Incremental sync with updatedSince”const since = new URLSearchParams({ updatedSince: lastSyncedAt.toISOString() });const changed = await eposGet(`/v1/catalog/products?${since}`);See Catalog Sync for the full pattern.