Assign nutritional information to products, recipes and dishes, and calculate it for recipes and dishes from their ingredients.
PUT /ingredient/{idComponent}/nutritional
PUT /recipe/{idComponent}/nutritional
PUT /dish/{idComponent}/nutritional
GET /recipe/{idComponent}/nutritional
GET /dish/{idComponent}/nutritionalFor products, information is expressed per 100 g. For recipes and dishes, per 100 g, for the whole recipe or dish, or for one of its quantities. You can calculate it or assign it directly; assigning it is recommended when the process (frying, baking…) changes the ingredients' values.
Before you start
Base URL: https://app.tspoonlab.com/recipes/api
Headers
rememberme· required — Session token returned by the login.
Login — Returns the token as plain text.
curl https://app.tspoonlab.com/recipes/api/login \
-d [email protected] \
-d password=XXXXXXX
Permissions — Every endpoint, including the read ones, requires permission to edit products, recipes or dishes, depending on the path.
Energy — energy is in kcal and energyKj in kJ. When calculating, by default kcal are obtained with the formula fat × 9 + carbohydrates × 4 + proteins × 4 + fiber × 2 and kJ from the kcal (1 kcal = 4.184 kJ). If automatic kcal or kJ calculation is turned off for the account, the ingredients' values are added up.
Responses may include fields other than the documented ones. Use only the documented fields.
Assign nutritional information
Replaces every stored value: fields not sent are left empty.
PUT /ingredient/{idComponent}/nutritional
PUT /recipe/{idComponent}/nutritional
PUT /dish/{idComponent}/nutritionalPath parameters
idComponentstring · required — Product, recipe or dish id. It must match the type in the path.
Body
energynumber · optional — Energy in kcal.energyKjnumber · optional — Energy in kJ.fatnumber · optional — Fat, in g.saturatednumber · optional — Saturated fat, in g.carbohydratesnumber · optional — Carbohydrates, in g.sugarnumber · optional — Sugars, in g.proteinsnumber · optional — Proteins, in g.saltnumber · optional — Salt, in g.fibernumber · optional — Fibre, in g.nutritionalPercentboolean · optional —true: values are per 100 g (always for products). If not sent, values are stored per 100 g for products and for the whole recipe or dish otherwise, andnutritionalUnitariis ignored.nutritionalUnitariboolean · optional —true(withnutritionalPercentset tofalse): values are for one quantity of the recipe or dish, the one inidComponentUnitNutritional. With bothfalse, values are for the whole recipe or dish.idComponentUnitNutritionalstring · optional —idof the recipe or dish quantity (fromlistComponentServicein Recipes and dishes).
Example
curl -X PUT https://app.tspoonlab.com/recipes/api/ingredient/3515834441676562996102040001/nutritional \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"energy": 18,
"energyKj": 75.3,
"fat": 0.2,
"saturated": 0.03,
"carbohydrates": 3.9,
"sugar": 2.6,
"proteins": 0.9,
"salt": 0.01,
"fiber": 1.2,
"nutritionalPercent": true
}'
Response — No content.
Calculate nutritional information
Calculates a recipe or dish's information from its ingredients. "Sufficient quantity" lines and tools are not counted.
GET /recipe/{idComponent}/nutritional
GET /dish/{idComponent}/nutritionalPath parameters
idComponentstring · required — Recipe or dish id.
Query parameters
percentboolean · optional —truecalculates per 100 g. Defaults totrue.unitariboolean · optional —true(withpercent=false) calculates for one quantity of the recipe or dish. With bothfalse, calculates for the whole. Defaults tofalse.idComponentUnitstring · optional —idof the recipe or dish quantity (fromlistComponentService) whenunitari=true. Defaults to the first one.
Example
curl "https://app.tspoonlab.com/recipes/api/dish/3515834441676562996102030010/nutritional?percent=false&unitari=true" \
-H "rememberme: $TOKEN"
Response
{
"energy": 412.6,
"energyKj": 1726.3,
"fat": 14.1,
"saturated": 6.2,
"carbohydrates": 55.3,
"sugar": 6.8,
"proteins": 16.4,
"salt": null,
"fiber": 3.1,
"nutritionalPercent": false,
"nutritionalUnitari": true,
"idComponentUnitNutritional": "3515834441676562996102030011",
"listIncomplete": [],
"listNoInfo": [],
"listNoInfoSalt": [
{
"id": "3515834441676562996102040010",
"descr": "Grated cheese",
"type": 0,
"color": 16766720
}
]
}energy,energyKj,fat,saturated,carbohydrates,sugar,proteins,salt,fibernumber — Calculated values.nullif any ingredient lacks that value.nutritionalPercentboolean — Whether it was calculated per 100 g.nutritionalUnitariboolean — Whether it was calculated for one quantity of the recipe or dish.idComponentUnitNutritionalstring — Quantity used in a per-quantity calculation.listIncompletearray — Ingredients whose quantity cannot be converted to weight. If there are any, no value is calculated.listNoInfoarray — Ingredients with no nutritional information at all.listNoInfoEnergy,listNoInfoEnergyKj,listNoInfoFat,listNoInfoSaturated,listNoInfoCarbohydrates,listNoInfoSugar,listNoInfoProteins,listNoInfoSalt,listNoInfoFiberarray — Ingredients missing that value.
Each ingredient in the lists:
idstring — Product, recipe or dish id.descrstring — Name.typeinteger —0product ·1recipe ·3dish.colorinteger — Colour (RGB) of its first category.
Need help? Message us from the support chat in the bottom-right corner.
