Skip to main content

REST API: Recipes and dishes 🍽️

How to access intermediate (recipes) and final (dishes) elaborations and their details

Rest API: Recipes and dishes

Recipes and dishes are the items you make yourself from the base products you buy. There are two types: Recipes (intermediate) — items you make in your kitchen and later use for your dishes; Dishes (final) — the ones you sell and serve to your clients.

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: List all recipes and dishes

There are two calls:

GET: 
https://app.tspoonlab.com/recipes/api/listRecipesPaged
o
https://app.tspoonlab.com/recipes/api/listDishesPaged

You can pass the following request parameters:

  • start (int), the first row to return. Required.

  • rows (int), the number of rows. Required.

  • filter (String), a string to filter the ingredients. Optional.

  • types (Array of String), an array with the ids of the categories to filter by (if you specify more than one, the product must have all of them). Optional.

  • marked (Boolean), returns only the marked ones. Optional.

  • hidden (Boolean), returns only the hidden ones. Optional.

  • withTypes (Boolean), returns the categories of each recipe or dish.

  • withDetail (Boolean), returns the detail of each recipe or dish.

It returns:

retorna una List<EntityBaseImages> 

EntityBaseImagess {
String id;
String descr;
String codi;
boolean hasData;
Short tag;
String tagComment;
String altDescr;
List<EntityBaseDescr> listComponentTypes;
List<ComponentDetail> listComponentDetail;

}

Where:

id is the product identifier.

descr the product name.

codi the product code.

hasData indicates that recipe or dish is used in another recipe or dish.

tag is null if the product has no mark otherwise:

Ok:1, MoreInfo:2, Error:3.

tagComment is the comment associated with the mark.

When you call with withTypes, it additionally returns the categories/types of the recipe or dish.

 una List<EntityBaseDescr>  en listComponentTypes

EntityBaseDescr {
String id;
String descr;
}

Where id is the category id and descr its description. When you call with withDetail, it additionally returns the recipe or dish detail in listComponentDetail of the ComponentDetail class shown in the next section.

Rest API: Access a recipe

To access a recipe:

GET: 
https://app.tspoonlab.com/recipes/api/recipe/{idRecipe}

idRecipe is the recipe identifier obtained from the previous call. It returns:

class ComponentCompond {
String id;
String descr;
String altDescr;
Double cost;
List<ComponentDetail> listComponentDetail;
List<ComponentService> listComponentService;
String process;

}

class ComponentService {
String id;
String idUnit;
Double quantity;
String unit;
}

class ComponentDetail {
String id;
String idComponent;
String codeComponent;
String descr;
String altDescr;
Double quantity;
Double quantityGross;
String unit;
String idUnit;
String use;
String comment;
Double cost;
int type;
}

id and descr are the recipe or dish identifier and description. It can have an alternative description in altDescr.

cost is the cost of producing the quantity expressed in listComponentService; if that is a list with more than one entry, the cost refers to the first entry.

process is the preparation process, where each step is separated by a line break ("\n").

listComponentService lists the quantity associated with each dish; there may be more than one, in which case the detail quantities let you produce each entry of listComponentService separately (all entries are equivalent).

listComponentDetail shows all the ingredients needed to make the recipe or dish.

id is the detail id, idComponent the id of the product/recipe used.

descr and altdescr refer to the product/recipe description and alternative description.

quantity is the amount of that component you use. If a cut or breakdown is applied, quantityGross gives the gross amount (it can be null).

use is the name of the cut/breakdown used.

comment is a comment about the use of that component and cost is that detail’s cost (if a gross amount is used, that cost is the gross cost).

idUnit and unit are the unit used for that ingredient, which may differ from the product’s unit — in which case you would need to check the unit equivalences if necessary.

codeComponent is the code of the ingredient or recipe shown in the detail.

type lets you tell whether it is an ingredient, a material, a recipe or even a dish:

Ingrediente(Producto): 0
Receta(ElaboraciĂłn intermedia): 1
Material(Herramienta): 2
Dish(ElaboraciĂłn final): 3

Rest API: Access a dish

To access a dish:

GET: 
https://app.tspoonlab.com/recipes/api/dish/{idDish}

idDish is the dish identifier obtained from the previous call.

It returns a ComponentCompound, the same as for recipes explained in the previous section, except it also includes the list of recipe centers it is associated with:

private List<EntityBaseData> listRecipeCenters;

class EntityBaseData {
String id;
String idAux;
String descr;
}

id is the id of the dish–recipe-center relationship.

idAux is the recipe center id.

descr is the recipe center description.

Rest API: Data structure to create/delete recipes and dishes

This is the structure used to create/delete recipes:

public class NewComponentComplex  {

String descr;
String altDescr;
List<NewComponentUnit> listComponentUnits;

Double minStock;
// Expressed as a per-unit fraction relative to NewComponentUnit
Double maxStock;
// Expressed as a per-unit fraction relative to NewComponentUnit
Double minProduction;
// Expressed as a per-unit fraction relative to NewComponentUnit
Double multProduction;
// Expressed as a per-unit fraction relative to NewComponentUnit

List<NewComponentType> listComponentTypes;
List<NewComponentStore> listStores;

String codi;

boolean includeInOrder; // Whether it is included in orders by default
boolean averageCost; // The price is calculated as an average of the purchases
boolean fixedCost;
boolean fromVendor;

String origen; // Where this recipe comes from
Double caducity; // Expressed in days
String idPartida; // Station id
Boolean inLabel; // Whether it is included on the label
Boolean inPlanning;
Short typeConservation;
Double storageTemperature;
Double storageTemperatureAux;
Short typeTemperature;
Double iva;
String barcode;
}

public class NewComponentUnit {

double quantity; // Recipe quantity
String idUnit; // Recipe unit
Integer position; // Position. There can be more than one and position indicates the order
}

public class NewComponentType {

String id; // Component type (category) id
}

public class NewComponentStore {
String id; // Store id
}

typeConservation can take these values:

public static short TypeConservationNevera = 0;
public static short TypeConservationCongelador = 1;
public static short TypeConservationSeco = 2;
public static short TypeConservationCaliente = 3;

typeTemperature can take these values:

public static short TypeTemperatureEquals = 0;
public static short TypeTemperatureLessThan = 1;
public static short TypeTemperatureGreaterThan = 2;
public static short TypeTemperatureBetween = 3;

Rest API: Create a recipe

To create a recipe:

POST: 
https://app.tspoonlab.com/recipes/api/recipe

In the request body you pass NewComponentComplex.

Rest API: Create a dish

To create a dish:

POST: 
https://app.tspoonlab.com/recipes/api/dish

In the request body you pass NewComponentComplex, adding this new field:

 List<NewRecipeCenter> listRecipeCenters;

public class NewRecipeCenter {

String id;
String idRecipeCenter;
}

id must be null and idRecipeCenter is the recipe center id.

Rest API: Delete a recipe

To delete a recipe:

DELETE: 
https://app.tspoonlab.com/recipes/api/recipe/{idRecipe}

Rest API: Delete a dish

To delete a dish:

DELETE: 
https://app.tspoonlab.com/recipes/api/dish/{idDish}

Rest API: Retrieve a recipe or dish’s detail

To retrieve the detail of a dish or recipe:

GET: 
https://app.tspoonlab.com/recipes/api/dish/{idDish}
https://app.tspoonlab.com/recipes/api/recipe/{idRecipe}

It returns:

public class ComponentDetail  {

String id; // Detail id
String idComponent;
// Component id (product or recipe)
String descr; // Component description
String altDescr; // Component alternative name description
Double quantity; // Net quantity or quantity
Double quantityGross; // Gross quantity
String idUnit; // Unit id
String unit; // Unit description
String idUse; // Cut or breakdown id
String use; // Cut or breakdown description
String comment; // Comment
Double cost; // Cost
String codeComponent; // Product code
String date; // Date of the last cost change
List<ComponentAllergy> listAllergies;
}

public class ComponentAllergy extends EntityBaseDescr {

String id; // componentAllergy id
String descr; // Allergen description
String idAllergy; // Allergen id
String codi; // Allergen code
boolean calculated; // Whether this allergen is calculated from the ingredients that make up idComponent
boolean traces; // Whether it is a trace

Rest API: Modify a recipe or dish’s detail

To modify the detail of a recipe or dish:

PUT: 
https://app.tspoonlab.com/recipes/api/dish/{idDish}
https://app.tspoonlab.com/recipes/api/recipe/{idRecipe}

Where you pass:

public class NewComponentDetailsWrapper {
List<NewComponentDetail> components;
}

public class NewComponentDetail {

private String id; // Null when adding
private String idComponent; // Component id
private String idUnit; // Unit id
private String idUse; // Cut or breakdown id
private Double quantity; // Quantity used in the recipe or dish
private boolean qs; // Whether it is 'enough' quantity. In this case neither idUnit, idUse nor quantity is specified
private String comment;
private int position;
}

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?