Skip to content
DEV preview — API version 1.0.0 — not the public production site — Development API: dev-api.theprioryshop.co.uk

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).

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;
}
const products = await eposGet("/v1/catalog/products?pageSize=20");
console.log(products.total, "products total,", products.rows.length, "on this page");
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");
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);
}
}
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()) {
// ...
}
const since = new URLSearchParams({ updatedSince: lastSyncedAt.toISOString() });
const changed = await eposGet(`/v1/catalog/products?${since}`);

See Catalog Sync for the full pattern.