Skip to main content

REST API: Allergens 🥜

How to Retrieve, Create, Update and Delete Allergens

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

  • start integer · required — Position of the first row, starting at 0.

  • rows integer · required — Number of rows to return.

  • filter string · 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" }
]
  • id string — Allergen id.

  • descr string — Name.


Retrieve an allergen

Returns the allergen with the first products that have it.

GET /allergy/{idAllergy}/components/num/{numComponents}

Path parameters

  • idAllergy string · required — Allergen id.

  • numComponents integer · 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
}
]
}
  • id string — Allergen id.

  • descr string — Name.

  • comment string — Comment.

  • listComponentBase array — Products the allergen has been assigned to directly.

  • listComponentComplex array — Products that have the allergen calculated from their ingredients.

Each product:

  • id string — Id of the assignment of the allergen to the product. Use it to remove the allergen.

  • idComponent string — Product id.

  • descr string — Product name.

  • traces boolean — true if it is a trace; false if it is an allergen.

  • type integer — 0 ingredient / product · 1 recipe · 2 material / tool · 3 dish.

  • color integer — 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/paged

Path parameters

  • idAllergy string · required — Allergen id.

  • isBase boolean · required — true returns the products with the allergen assigned directly (listComponentBase); false, those that have it calculated (listComponentComplex).

Query parameters

  • start integer · optional — Position of the first row, starting at 0. Required if you send rows.

  • rows integer · optional — Number of rows to return. If omitted, all rows are returned.

  • filter string · 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

  • descr string · required — Name.

  • comment string · 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

  • idAllergy string · required — Allergen id.

Body

  • descr string · required — Name.

  • comment string · 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

  • idAllergy string · 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/add

Path parameters

  • idAllergy string · required — Allergen id.

Body

  • components array · required — Products to assign the allergen to.

Each product:

  • idComponent string · required — Product id.

  • traces boolean · optional — true to assign it as a trace. Defaults to false.

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 }
]
}
  • listComponentBase array — Assignments created.

  • listComponentComplex array — 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/remove

Path parameters

  • idAllergy string · required — Allergen id.

Body

  • components array · required — Assignments to remove.

Each assignment:

  • id string · required — Assignment id (id in listComponentBase).

  • idComponent string · 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 }
]
  • id string — Product id.

  • descr string — Product name.

  • type integer — Product type (see Retrieve an allergen).

  • color integer — Color of the product's first family, as an RGB integer.

Need help? Message us from the support chat in the bottom-right corner.

Did this answer your question?