Quickstart
From a key to products on screen in five minutes.
Get a publishable key
In Cashiar, open Settings › Developers and choose Create key. You need the Online store add-on, and the store must be open (Settings › Online store).
Your key looks like pk_live_Fd8sK2…. It is meant for browsers and apps: you can commit it to your frontend.
Make your first request
List the shop's products:
curl https://api.cashiar.app/v1/storefront/products?limit=3 \
-H "Authorization: Bearer pk_live_your_key"You get a page of products, each with its versions, prices and stock:
{
"items": [
{
"id": "dabe0026-3fbe-427e-afc3-7c509f68d462",
"name": "Amoxiclav",
"unitName": "Sachet",
"category": "Tablets",
"imageUrl": "https://api.cashiar.app/photos/orgs/…/products/….png",
"priceTypes": [{ "id": null, "name": "Retail" }],
"versions": [
{
"variantId": "1db29704-09ee-4aa3-95cc-c424173e6d5a",
"name": null,
"sellingPrice": 1200,
"inStock": true,
"sellingUnits": [
{ "id": "c22d51bf-…", "name": "Pack of 10", "sellingPrice": 12000, "prices": [] }
],
"prices": [{ "priceListId": null, "sellingPrice": 1200 }]
}
],
"addonGroups": [],
"soldOut": false
}
],
"nextCursor": "dabe0026-3fbe-427e-afc3-7c509f68d462"
}sellingPrice: 1200 is GH₵ 12.00: amounts are in pesewas.
Show them
A minimal product list in React:
import { useEffect, useState } from 'react';
const KEY = 'pk_live_your_key';
const money = (pesewas: number) =>
new Intl.NumberFormat('en-GH', { style: 'currency', currency: 'GHS' }).format(
pesewas / 100,
);
export function Products() {
const [products, setProducts] = useState([]);
useEffect(() => {
fetch('https://api.cashiar.app/v1/storefront/products', {
headers: { Authorization: `Bearer ${KEY}` },
})
.then((res) => res.json())
.then((page) => setProducts(page.items));
}, []);
return (
<ul>
{products.map((p) => (
<li key={p.id}>
{p.name}: {money(p.versions[0].sellingPrice)}
{p.soldOut && ' (sold out)'}
</li>
))}
</ul>
);
}Place an order
curl https://api.cashiar.app/v1/storefront/orders \
-H "Authorization: Bearer pk_live_your_key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c2a9e-order-1" \
-d '{
"customerName": "Kojo Mensah",
"customerPhone": "024 555 0199",
"fulfilment": "pickup",
"lines": [{ "variantId": "1db29704-09ee-4aa3-95cc-c424173e6d5a", "quantity": 2 }]
}'The order appears in the shop straight away. Read on in Cart and checkout.