Free cash register

Kash.click, free online POS software since 2011

Follow Us

L’aide, à portée de main

Comment pouvons-nous vous aider ?

Un réglage, une question, un geste du quotidien. Trouvez le bon guide et avancez simplement.

API / Web services

API example · Download the catalogue

Download all items that have not been deleted from your shop into a JSON file with GET /api/partner/v1/products. This Partner API route takes the key in the Authorization: Bearer … header and the shop ID in the shop_id query parameter.

1. Set up access

Enable Web Services in your shop’s general settings. Under Configuration → Web Services → API keys, create a managed API key with this permission Catalogue and stock → Read (catalog.read). API key guide

Open a terminal in your working directory. Replace 12345 with the shopID shown when you created the key, then enter the full key when prompted. Run the script from that same terminal.

Windows · PowerShell 7.2+
$env:KASH_SHOP_ID = '12345'
$env:KASH_API_KEY = Read-Host 'API key' -MaskInput
macOS / Linux · Bash
export KASH_SHOP_ID=12345
read -rsp 'API key: ' KASH_API_KEY && printf '\n' && export KASH_API_KEY

2. Copy and run the script

Choose a language and save the code in the named file. Then run the command shown. The scripts run from a terminal and use only the standard library.

Node.js 22+ · catalogue.mjs

node catalogue.mjs

import { writeFile } from "node:fs/promises";

const { KASH_SHOP_ID: shopId, KASH_API_KEY: key } = process.env;
if (!shopId || !key) throw new Error("Set KASH_SHOP_ID and KASH_API_KEY.");

const url = new URL("https://kash.click/api/partner/v1/products");
url.search = new URLSearchParams({ shop_id: shopId, limit: "100" });
const products = [];
let cursor = null;

do {
  if (cursor !== null) url.searchParams.set("cursor", cursor);
  const response = await fetch(url, {
    headers: { Authorization: `Bearer ${key}`, Accept: "application/json" },
    redirect: "error",
    signal: AbortSignal.timeout(30000)
  });
  const page = await response.json().catch(() => null);
  cursor = page?.pagination?.next_cursor;
  if (!response.ok || !Array.isArray(page?.data) || !(cursor === null || typeof cursor === "string")) {
    throw new Error(`HTTP ${response.status}: ${page?.error?.code ?? "Unexpected response"}`);
  }
  products.push(...page.data);
} while (cursor !== null);

await writeFile("catalogue.json", JSON.stringify(products, null, 2) + "\n");
console.log(`${products.length} products → catalogue.json`);
Python 3.10+ · catalogue.py

python3 catalogue.py

On Windows, use py in place of python3.

import json
import os
import sys
from http.client import HTTPSConnection
from pathlib import Path
from urllib.parse import urlencode

shop_id = os.getenv("KASH_SHOP_ID")
key = os.getenv("KASH_API_KEY")
if not shop_id or not key:
    sys.exit("Set KASH_SHOP_ID and KASH_API_KEY.")

params = {"shop_id": shop_id, "limit": 100}
headers = {"Authorization": f"Bearer {key}", "Accept": "application/json"}
products = []
connection = HTTPSConnection("kash.click", timeout=30)

while True:
    connection.request("GET", "/api/partner/v1/products?" + urlencode(params), headers=headers)
    response = connection.getresponse()
    try:
        page = json.loads(response.read())
    except ValueError:
        sys.exit(f"HTTP {response.status}: Unexpected response")
    if response.status != 200:
        sys.exit(f"HTTP {response.status}: {page.get('error', {}).get('code', 'Unexpected response')}")
    products.extend(page["data"])
    cursor = page["pagination"]["next_cursor"]
    if cursor is None:
        break
    params["cursor"] = cursor

connection.close()
Path("catalogue.json").write_text(json.dumps(products, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"{len(products)} products → catalogue.json")

3. Open the catalogue

Open catalogue.json in the terminal’s working directory. The script retrieves up to 100 items per call in data and sends pagination.next_cursor as the cursor parameter until its value is null. The file is written after all pages arrive. A shop with no items returns [].

Each item includes id, name, price and currency. The price is a decimal string such as "4.50". Each export replaces the previous file. For all fields and filters, see the Partner API OpenAPI document.

This document is made available under the terms of the licence Creative Commons Attribution 4.0 International (CC BY 4.0).