Skip to main content

REST API: Products and materials

How to create, update, and delete ingredients/products and materials/tools

List, create and delete products (ingredients) and tools (materials), and update their cost.

GET    /listIngredientsPaged
GET /listMaterialsPaged
POST /ingredient
POST /material
DELETE /ingredient/{idComponent}
DELETE /material/{idComponent}
PUT /ingredient/{idComponent}/cost
PUT /material/{idComponent}/cost

Before you start

Base URL: https://app.tspoonlab.com/recipes/api

Headers

  • rememberme · required — Session token returned by the login.

  • order · optional — Cost center id (Cost centers). Defaults to the user's active cost center. Codes, costs and stock levels are read from and saved to this cost center.

Login — Returns the token as plain text.

curl https://app.tspoonlab.com/recipes/api/login \
-d [email protected] \
-d password=XXXXXXX

Permissions — Listing requires permission to view products or tools; creating and deleting, permission to add or delete products or tools; updating the cost, permission to edit them.

Responses may include fields other than the documented ones. Use only the documented fields.


List products and tools

/listIngredientsPaged lists products and /listMaterialsPaged lists tools.

GET /listIngredientsPaged
GET /listMaterialsPaged

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 search in the name, alternative name or code. With withTypes=true, also in category names.

  • types array · optional — Category ids; repeat the parameter for each one. Products must have all of them.

  • marked boolean · optional — true returns only marked products. Defaults to false.

  • hidden boolean · optional — true returns only hidden products; false, only visible ones. Defaults to false.

  • used boolean · optional — true returns only products used in some recipe or dish.

  • notUsed boolean · optional — true returns only products not used in any recipe or dish.

  • withPrice boolean · optional — true returns only products with a cost in the cost center.

  • withNoPrice boolean · optional — true returns only products without a cost in the cost center.

  • withVendor boolean · optional — true returns only products with a supplier in the cost center.

  • withNoVendor boolean · optional — true returns only products without any supplier in the cost center.

  • withUnits boolean · optional — true includes the unit. Defaults to false.

  • withTypes boolean · optional — true includes the categories. Defaults to false.

  • withCost boolean · optional — true includes the cost. Defaults to false.

Example

curl "https://app.tspoonlab.com/recipes/api/listIngredientsPaged?start=0&rows=50&withUnits=true&withCost=true" \
-H "rememberme: $TOKEN"

Response

[
{
"id": "3515834441676562996102040001",
"descr": "Plum tomato",
"codi": "P-0102",
"color": 15158332,
"type": 0,
"hasData": true,
"tag": null,
"tagComment": null,
"idUnit": "3515834441676562996102040002",
"unit": "kg",
"cost": 1.35,
"listComponentTypes": null,
"listComponentTypesOthers": null
}
]
  • id string — Product id.

  • descr string — Name.

  • codi string — Code in the cost center.

  • color integer — Colour (RGB) of its first category. 0 if it has no categories.

  • type integer — 0 product · 2 tool.

  • hasData boolean — Whether it is used in some recipe or dish.

  • tag integer — Mark: 1 OK · 2 more info needed · 3 error. null if not marked.

  • tagComment string — Comment on the mark.

  • idUnit, unit string — Product unit. Only with withUnits.

  • cost number — Cost per unit in the cost center. Only with withCost.

  • listComponentTypes array — Basic categories, each with id and descr. Only with withTypes.

  • listComponentTypesOthers array — Property or cost categories, with the same fields. Only with withTypes.


Create a product or tool

/ingredient creates a product and /material a tool. Returns its id.

POST /ingredient
POST /material

Body

  • descr string · required — Name.

  • idUnit string · required — Product unit id.

  • listComponentTypes array · required — Categories, each with its id. Send [] if there are none.

  • listEquivalences array · required — Equivalences with other units, up to 4. Send [] if there are no equivalences.

  • altDescr string · optional — Alternative name, usually the commercial one.

  • codi string · optional — Code in the cost center.

  • barcode string · optional — Barcode in the cost center.

  • includeInOrder boolean · optional — true includes it in orders. Defaults to false.

  • averageCost boolean · optional — true: the cost is the average of last month's purchases.

  • fixedCost boolean · optional — true: the cost is fixed. If neither is sent, the last purchase cost is used.

  • cost number · optional — Cost per unit in the cost center. Ignored without permission to view costs.

  • minStock, maxStock number · optional — Minimum and maximum stock in the cost center.

  • caducity number · optional — Shelf life in days.

  • listStores array · optional — Stores in the cost center where it is kept, each with its id. Ignored without permission to edit stores.

Each equivalence:

  • idUnitFrom string · required — Id of the other unit.

  • quantityTo number · required — Equivalent quantity.

  • inverted boolean · optional — false: 1 idUnitFrom = quantityTo product units. true: 1 product unit = quantityTo idUnitFrom. Defaults to false.

Example

curl https://app.tspoonlab.com/recipes/api/ingredient \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"descr": "Plum tomato",
"idUnit": "3515834441676562996102040002",
"listComponentTypes": [ { "id": "3515834441676562996102040003" } ],
"listEquivalences": [ { "idUnitFrom": "3515834441676562996102040004", "quantityTo": 0.15 } ],
"codi": "P-0102",
"includeInOrder": true,
"cost": 1.35
}'

Response

{ "id": "3515834441676562996102040001" }

Delete a product or tool

Deletion is permanent.

DELETE /ingredient/{idComponent}
DELETE /material/{idComponent}

Path parameters

  • idComponent string · required — Product or tool id.

Example

curl -X DELETE https://app.tspoonlab.com/recipes/api/ingredient/3515834441676562996102040001 \
-H "rememberme: $TOKEN"

Response — No content.


Update the cost

Changes the cost in the cost center and, if it changed, recalculates the cost of the recipes, dishes, menus and events in that cost center that use it.

PUT /ingredient/{idComponent}/cost
PUT /material/{idComponent}/cost

Path parameters

  • idComponent string · required — Product or tool id.

Body

  • value number · required — New cost per unit. With null, or if omitted, the cost is removed.

Example

curl -X PUT https://app.tspoonlab.com/recipes/api/ingredient/3515834441676562996102040001/cost \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": 1.42}'

Response — No content.

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

Did this answer your question?