Python
These use requests (pip install requests) - the API itself
has no Python-specific requirements beyond a standard HTTP client.
A small client
Section titled “A small client”import osimport requests
BASE_URL = "https://dev-api.theprioryshop.co.uk"API_KEY = os.environ["EPOS_API_KEY"] # never hardcode this
class EposApiError(Exception): def __init__(self, code, request_id, status, message): super().__init__(f"{code}: {message} (request {request_id})") self.code = code self.request_id = request_id self.status = status
def epos_get(path, params=None): response = requests.get( f"{BASE_URL}{path}", headers={"Authorization": f"Bearer {API_KEY}"}, params=params, ) body = response.json() if not response.ok: error = body["error"] raise EposApiError(error["code"], error["requestId"], response.status_code, error["message"]) return bodyList products
Section titled “List products”products = epos_get("/v1/catalog/products", params={"pageSize": 20})print(products["total"], "products total,", len(products["rows"]), "on this page")Get a single product
Section titled “Get a single product”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", params={"storeId": "clx1store0000001"})Handle an error
Section titled “Handle an error”try: epos_get("/v1/catalog/products/does-not-exist")except EposApiError as err: if err.code == "not_found": print("No such product") elif err.code == "rate_limited": print("Back off and retry - see Rate Limits") else: print(f"EPOS API error {err.code} (request {err.request_id})")Paginate through every product
Section titled “Paginate through every product”def all_products(): page = 1 while True: result = epos_get("/v1/catalog/products", params={"pageSize": 100, "page": page}) yield from result["rows"] if page >= result["totalPages"]: break page += 1
for product in all_products(): ...Incremental sync with updatedSince
Section titled “Incremental sync with updatedSince”from datetime import datetime, timezone
since = last_synced_at.astimezone(timezone.utc).isoformat().replace("+00:00", "Z")changed = epos_get("/v1/catalog/products", params={"updatedSince": since})See Catalog Sync for the full pattern.