Skip to main content

REST API: Customers

List customers and retrieve customer information

Gustavo Vera avatar
Written by Gustavo Vera
Updated over 3 weeks ago

1. Customers

Each cost center has an associated list of customers used for sales. This guide explains how to:

  • List all customers

  • List customer types

  • Retrieve a customer’s full details

  • Retrieve items for sale to a customer (products and menus)


1.1 REST API: Login

Authenticate first; the login call returns a token you must include in every request.

Example (cURL)

[email protected] password=XXXXXXX  url=https://www.tspoonlab.com/recipes/api authenticate="username=$username&password=$password"  echo -n 'rememberme:' > rememberme.txt curl -v --data "$authenticate" "$url/login" >> rememberme.txt

Use the token in subsequent calls:

curl -X PUT -v -H "$(cat rememberme.txt)" "$url/integration/call"

1.2 Select a Cost Center / Restaurant

Requests below refer to a cost center (usually a restaurant).
To get cost centers and IDs, see: REST API: Get a list of cost centers.

Add the idOrderCenter to your headers:

echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt

Headers example

rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX order:351583444167656299610202XXXXXXXXXXXX

1.3 List all customers

Endpoint

GET https://www.tspoonlab.com/recipes/api/listCustomersPaged

Query params

  • start (int, required) – first row index

  • rows (int, required) – number of rows

  • filter (string, optional) – text filter

  • hidden (boolean, optional) – only hidden customers

Response

class TypeEntry {   String id;   String descr;   String codi;   boolean defecte;   String descrType;   String idType; }

Fields

  • id: customer ID

  • descr: customer name

  • codi: customer code

  • defecte: true if it’s the default customer

  • idType, descrType: customer type classification


1.4 List customer types

Endpoint

GET https://www.tspoonlab.com/recipes/api/listCustomerTypesPaged

Query params

  • start (int, required)

  • rows (int, required)

  • filter (string, optional)

Response

class EntityBaseBoolCodi {   String id;   String descr;   String codi; }

1.5 Get a customer (details)

Endpoint

GET https://www.tspoonlab.com/recipes/api/customer/{idCustomer}

Response (simplified)

class Customer {   String id;   String descr;   Boolean defecte;   String nif;   String comment;   String web;   String mailcc;   String codi;   String address;   String city;   String cp;   String idCustomerType;   List<CustomerContact> listContact;   List<CustomerMail> listMail;   List<CustomerComponentGroup> listGroups; }  class CustomerContact {   String id;   String descr;   // contact name   String phone; }  class CustomerMail {   String id;   String descr;   // email address }  class CustomerComponentGroup {   String id;   String idCustomerGroup;   String customerGroup;   String codiCustomerGroup;   String comment; }

Notes

  • defecte: marks default customer

  • nif: customer tax ID

  • mailcc: CC email for purchase/sales notifications

  • listGroups: product groups defined for this customer


1.6 Get items for sale (products & menus)

Products for sale to the customer may be grouped or not grouped. You can also have menus (grouped offerings) available for sale.

Endpoint

GET https://www.tspoonlab.com/recipes/api/customer/{idCustomer}/components/paged

Query params

  • start (int, required)

  • rows (int, required)

  • filter (string, optional)

  • idGroup (string, optional) – to fetch items of a specific customer group; use null to fetch items not linked to any group

Response

class CustomerComponent {   String id;            // sale item ID   Double cost;          // sale price (tax included)   Double costComponent; // product cost   Double percentCost;   // food cost %   String plu;           // POS code   Double iva;           // tax rate   String currency;    Double quantity;  // sale quantity   String unit;      // sale unit name   String idUnit;    // sale unit ID    // Product-based sale   String idComponent;   // product ID   String component;     // product name    // Menu-based sale   String idMenu;        // menu ID   String menu;          // menu name }

Notes

  • All endpoints require:

    • rememberme (token)

    • order (cost center)

  • Use HTTPS for all requests.

  • Use pagination for scalable queries (start, rows).

Did this answer your question?