Skip to main content

REST API: Waste đŸ«—â€‹

How to list and retrieve daily waste and sale types via API

Rest API: How waste works

Users can record the waste produced in their restaurant, both of products (vegetables, meats or fish) and of recipes and dishes. Waste is recorded each day and valued at the cost of the product or recipe costing.

System login

To make calls to our APIs, the first thing you need is to authenticate through a login call. That call returns a token that you must then attach to every subsequent call.

This shell script shows how to authenticate using curl:

[email protected]
password=XXXXXXX

url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password

echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt

On later calls, add the token received from the login call to your headers:

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

Rest API: Select a cost center/restaurant

The requests described in the following sections refer to a cost center, which in most cases corresponds to a restaurant. To retrieve the list of cost centers and their identifiers, see the "REST API: Cost centers" article. The cost center identifier corresponds to the idOrderCenter field of the UserOrderCenter class. Once you have the identifier, add it to the headers so it is used on subsequent calls:

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

So in your request headers you must specify both the token returned by login and the cost center identifier:

rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX
order:351583444167656299610202XXXXXXXXXXXX

Rest API: Retrieve waste

To retrieve daily waste:

https://app.tspoonlab.com/recipes/api/listThrownPaged?filter=&rows=50&start=0

filter lets you filter by description; start and rows handle pagination. It returns a list of daily waste:

retorna un List<ThrownEntry>

class ThrownEntry {

private String id;
private String descr;
private String codi;
private String date;

}

It returns the id and description (id, descr), the code codi and the date in display format date.

Rest API: Retrieve a daily waste entry

To retrieve a daily waste entry:

GET https://app.tspoonlab.com/recipes/api/thrown/{id}

id is the identifier of the daily waste group. It returns:

public class ThrownData  {
private String id;
private String descr
private String codi;
private String dateFormatted;
private String comment;
private Date dateGenerated;
private String currency;
private Double cost;


private List<ThrownComponentData> listThrownComponents;
}


class ThrownComponentData {

String id;
String descr;
String idComponent;
String idThrown;
short type;
Long color;

Double quantity;
String unit;
String idUnit;
Double cost;
String currency;

String idUse;
String use;

String idComponentType;
String componentType;

String idThrownType;
String thrownType;
String thrownTypeCodi;

}

In ThrownData:

id is the identifier of the daily waste group.

descr is the name given to it.

codi is the code.

dateGenerated is the date.

cost is the cost of that day’s waste.

currency is the currency symbol.

The list of discarded products is detailed in listThrownComponents.

In ThrownComponentData:

id is the waste identifier.

descr is the name of the discarded product.

idComponent its identifier.

idThrown is the identifier of the daily waste group.

type is the product type (product, material, recipe or dish).

color for a product the color of its main category.

quantity is the amount discarded.

idUnit/unit is the identifier and description of the discarded unit.

cost is the unit cost (multiply it by quantity to get the waste cost).

currency is the currency symbol.

idUse/use: if the product was not wasted whole but with a cut or breakdown, they identify the cut or breakdown (for example, you don’t discard onion but julienned onion).

idThrownType identifies the waste type.

thrownType is its name, thrownTypeCodi its code.

idComponentType is the id of the product’s main category and componentType its description. More information in the article Rest API: Categories.

Rest API: List waste types

To retrieve waste types:

https://app.tspoonlab.com/recipes/api/listThrownTypesPaged?filter=&rows=50&start=0

filter lets you filter by description; start and rows handle pagination. It returns a list of waste types:

retorna un List<ThrownTypeEntry>

class ThrownTypeEntry {

private String id;
private String descr;
private String codi;

}

It returns the id and description (id, descr) and the waste type code codi.

Did you find this article helpful?

If you need further assistance, contact support by clicking the built-in Support Chat in the bottom-right corner of your screen.


Did this answer your question?