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

PHP

These use PHP’s built-in curl extension - no Composer dependencies required.

<?php
const BASE_URL = "https://dev-api.theprioryshop.co.uk";
$apiKey = getenv("EPOS_API_KEY"); // never hardcode this
class EposApiException extends Exception {
public string $code;
public string $requestId;
public function __construct(string $code, string $requestId, string $message) {
parent::__construct($message);
$this->code = $code;
$this->requestId = $requestId;
}
}
function epos_get(string $path, array $query = []): array {
global $apiKey;
$url = BASE_URL . $path . (count($query) ? "?" . http_build_query($query) : "");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $apiKey"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$body = json_decode($raw, true);
if ($status >= 400) {
$error = $body["error"];
throw new EposApiException($error["code"], $error["requestId"], $error["message"]);
}
return $body;
}
$products = epos_get("/v1/catalog/products", ["pageSize" => 20]);
echo $products["total"] . " products total, " . count($products["rows"]) . " on this page\n";
$product = epos_get("/v1/catalog/products/clx1product000001");

List categories, promotions, inventory stock

Section titled “List categories, promotions, inventory stock”
$categories = epos_get("/v1/catalog/categories");
$promotions = epos_get("/v1/catalog/promotions");
$stock = epos_get("/v1/inventory/stock", ["storeId" => "clx1store0000001"]);
try {
epos_get("/v1/catalog/products/does-not-exist");
} catch (EposApiException $err) {
if ($err->code === "not_found") {
echo "No such product\n";
} elseif ($err->code === "rate_limited") {
echo "Back off and retry - see Rate Limits\n";
} else {
echo "EPOS API error {$err->code} (request {$err->requestId})\n";
}
}
function all_products(): Generator {
$page = 1;
while (true) {
$result = epos_get("/v1/catalog/products", ["pageSize" => 100, "page" => $page]);
foreach ($result["rows"] as $row) {
yield $row;
}
if ($page >= $result["totalPages"]) {
break;
}
$page += 1;
}
}
foreach (all_products() as $product) {
// ...
}
$since = $lastSyncedAt->format("Y-m-d\TH:i:s.v\Z");
$changed = epos_get("/v1/catalog/products", ["updatedSince" => $since]);

See Catalog Sync for the full pattern.