List, retrieve, create, update and delete allergens, and assign them to or remove them from products.
GET /listAllergiesPaged
GET /allergy/{idAllergy}/components/num/{numComponents}
GET /allergy/{idAllergy}/base/{isBase}/components/paged
POST /allergy
PUT /allergy/{idAllergy}
DELETE /allergy/{idAllergy}
POST /allergy/{idAllergy}/components/add
POST /allergy/{idAllergy}/components/remove
Every account starts with the 14 official European Union allergens; you can create others. Allergens are assigned to products, either as an allergen or as a trace. Recipes and dishes calculate their allergens from their ingredients; if an allergen arrives both as a trace and as an allergen, it is kept as an allergen.
Before you start
Base URL: https://app.tspoonlab.com/recipes/api
Headers
rememberme· required — Session token returned by the login.
Allergens belong to the whole account: they do not depend on the cost center.
Login — Returns the token as plain text.
curl https://app.tspoonlab.com/recipes/api/login \
-d [email protected] \
-d password=XXXXXXX
Permissions — Reading requires permission to view allergens. Creating, updating, deleting, assigning and removing require permission to edit allergens.
Responses may include fields other than the documented ones. Use only the documented fields.
List allergens
GET /listAllergiesPaged
Query parameters
startinteger · required — Position of the first row, starting at 0.rowsinteger · required — Number of rows to return.filterstring · optional — Text to filter by name.
Example
curl "https://app.tspoonlab.com/recipes/api/listAllergiesPaged?start=0&rows=50" \
-H "rememberme: $TOKEN"
Response
[
{ "id": "3515834441676562996102020101", "descr": "Lupin" },
{ "id": "3515834441676562996102020102", "descr": "Celery" }
]
idstring — Allergen id.descrstring — Name.
Retrieve an allergen
Returns the allergen with the first products that have it.
GET /allergy/{idAllergy}/components/num/{numComponents}Path parameters
idAllergystring · required — Allergen id.numComponentsinteger · required — Maximum number of products to return in each list.
Example
curl https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020102/components/num/20 \
-H "rememberme: $TOKEN"
Response
{
"id": "3515834441676562996102020102",
"descr": "Celery",
"comment": null,
"listComponentBase": [
{
"id": "3515834441676562996102020201",
"idComponent": "3515834441676562996102020301",
"descr": "Fresh celery",
"traces": false,
"type": 0,
"color": 3381555
}
],
"listComponentComplex": [
{
"id": "3515834441676562996102020202",
"idComponent": "3515834441676562996102020302",
"descr": "Vegetable stock",
"traces": false,
"type": 1,
"color": 16750848
}
]
}idstring — Allergen id.descrstring — Name.commentstring — Comment.listComponentBasearray — Products the allergen has been assigned to directly.listComponentComplexarray — Products that have the allergen calculated from their ingredients.
Each product:
idstring — Id of the assignment of the allergen to the product. Use it to remove the allergen.idComponentstring — Product id.descrstring — Product name.tracesboolean —trueif it is a trace;falseif it is an allergen.typeinteger —0ingredient / product ·1recipe ·2material / tool ·3dish.colorinteger — Color of the product's first family, as an RGB integer.
List the products of an allergen
Use it to get more products than Retrieve an allergen returns.
GET /allergy/{idAllergy}/base/{isBase}/components/pagedPath parameters
idAllergystring · required — Allergen id.isBaseboolean · required —truereturns the products with the allergen assigned directly (listComponentBase);false, those that have it calculated (listComponentComplex).
Query parameters
startinteger · optional — Position of the first row, starting at 0. Required if you sendrows.rowsinteger · optional — Number of rows to return. If omitted, all rows are returned.filterstring · optional — Text to filter by product name.
Example
curl "https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020102/base/true/components/paged?start=0&rows=20" \
-H "rememberme: $TOKEN"
Response — List of products, with the same fields as in Retrieve an allergen.
Create an allergen
Returns the id of the new allergen.
POST /allergy
Body
descrstring · required — Name.commentstring · optional — Comment.
Example
curl https://app.tspoonlab.com/recipes/api/allergy \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"descr": "Kiwi", "comment": "Account-specific allergen"}'
Response
{ "id": "3515834441676562996102020103" }Update an allergen
Replaces the allergen's data: any field you do not send is left empty.
PUT /allergy/{idAllergy}Path parameters
idAllergystring · required — Allergen id.
Body
descrstring · required — Name.commentstring · optional — Comment.
Example
curl -X PUT https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020103 \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"descr": "Kiwi", "comment": "Includes golden kiwi"}'
Response — No content.
Delete an allergen
The allergen is removed from every product that had it, assigned or calculated.
DELETE /allergy/{idAllergy}Path parameters
idAllergystring · required — Allergen id.
Example
curl -X DELETE https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020103 \
-H "rememberme: $TOKEN"
Response — No content.
Assign an allergen to products
Assigns the allergen to each product and recalculates the allergens of the recipes and dishes that use them.
POST /allergy/{idAllergy}/components/addPath parameters
idAllergystring · required — Allergen id.
Body
componentsarray · required — Products to assign the allergen to.
Each product:
idComponentstring · required — Product id.tracesboolean · optional —trueto assign it as a trace. Defaults tofalse.
Example
curl https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020102/components/add \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"components": [{"idComponent": "3515834441676562996102020301", "traces": false}]}'
Response
{
"listComponentBase": [
{ "id": "3515834441676562996102020201", "idComponent": "3515834441676562996102020301", "descr": "Fresh celery", "traces": false, "type": 0, "color": 3381555 }
],
"listComponentComplex": [
{ "id": "3515834441676562996102020202", "idComponent": "3515834441676562996102020302", "descr": "Vegetable stock", "traces": false, "type": 1, "color": 16750848 }
]
}listComponentBasearray — Assignments created.listComponentComplexarray — Recipes and dishes that have the allergen calculated after the change.
Each item has the same fields as in Retrieve an allergen.
Remove an allergen from products
Removes the given direct assignments and recalculates the allergens of the recipes and dishes that use those products. Calculated allergens cannot be removed.
POST /allergy/{idAllergy}/components/removePath parameters
idAllergystring · required — Allergen id.
Body
componentsarray · required — Assignments to remove.
Each assignment:
idstring · required — Assignment id (idinlistComponentBase).idComponentstring · required — Product id.
Example
curl https://app.tspoonlab.com/recipes/api/allergy/3515834441676562996102020102/components/remove \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"components": [{"id": "3515834441676562996102020201", "idComponent": "3515834441676562996102020301"}]}'
Response — Products, recipes and dishes that no longer have the allergen.
[
{ "id": "3515834441676562996102020301", "descr": "Fresh celery", "type": 0, "color": 3381555 },
{ "id": "3515834441676562996102020302", "descr": "Vegetable stock", "type": 1, "color": 16750848 }
]
idstring — Product id.descrstring — Product name.typeinteger — Product type (see Retrieve an allergen).colorinteger — Color of the product's first family, as an RGB integer.
Need help? Message us from the support chat in the bottom-right corner.
