API example · Download the customer list
Export your shop’s customer records with GET /api/partner/v1/customers. Send shop_id in the URL and the managed key in the Authorization: Bearer header. Work in a private directory as the file contains personal contact details.
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 Customers → Read (customers.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+ · clients.mjs
node clients.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 customers = [];
const url = new URL("https://kash.click/api/partner/v1/customers");
url.searchParams.set("shop_id", shopId);
let cursor = null;
do {
if (cursor !== null) url.searchParams.set("cursor", cursor);
const response = await fetch(url, {
headers: { Accept: "application/json", Authorization: `Bearer ${key}` },
redirect: "error",
signal: AbortSignal.timeout(120000),
});
const page = await response.json().catch(() => null);
const nextCursor = page?.pagination?.next_cursor;
if (!response.ok || !Array.isArray(page?.data) || (nextCursor !== null && typeof nextCursor !== "string")) {
throw new Error(`HTTP ${response.status}: ${page?.error?.message ?? "Unexpected response"}`);
}
customers.push(...page.data);
cursor = nextCursor;
} while (cursor !== null);
await writeFile("clients.json", JSON.stringify(customers, null, 2) + "\n", { mode: 0o600 });
console.log(`${customers.length} customers → clients.json`);
Python 3.10+ · clients.py
python3 clients.py
On Windows, use py in place of python3.
import json
import os
import sys
from http.client import HTTPSConnection
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.")
customers = []
params = {"shop_id": shop_id}
headers = {"Accept": "application/json", "Authorization": f"Bearer {key}"}
connection = HTTPSConnection("kash.click", timeout=120)
try:
while True:
connection.request("GET", f"/api/partner/v1/customers?{urlencode(params)}", headers=headers)
response = connection.getresponse()
try:
page = json.loads(response.read())
except ValueError:
sys.exit(f"HTTP {response.status}: Unexpected response")
data = page.get("data") if isinstance(page, dict) else None
pagination = page.get("pagination") if isinstance(page, dict) else None
if response.status != 200 or not isinstance(data, list) or not isinstance(pagination, dict) or "next_cursor" not in pagination:
sys.exit(f"HTTP {response.status}: Unexpected response")
customers.extend(data)
cursor = pagination["next_cursor"]
if cursor is None:
break
if not isinstance(cursor, str):
sys.exit("Invalid pagination cursor")
params["cursor"] = cursor
finally:
connection.close()
with open("clients.json", "w", encoding="utf-8", opener=lambda name, flags: os.open(name, flags, 0o600)) as file:
json.dump(customers, file, ensure_ascii=False, indent=2)
file.write("\n")
print(f"{len(customers)} customers → clients.json")
3. Open the customer list
The script prints the number of records and writes clients.json in the terminal’s working directory. The file contains an array of records with fields such as id, nom, prenom and email. A shop with no customers returns []. Each export replaces the previous file.
The script collects every result page using pagination.next_cursor. If the key is rejected, check the customers.read permission and the shop ID. For other resources, see the data export guide.