List, retrieve, create, update and delete categories, and assign them to or remove them from products.
GET /listTypesPagedEx
GET /type/{idFamily}/num/{numComponents}
GET /type/{idFamily}/components/paged
POST /type
PUT /type/{idFamily}
DELETE /type/{idFamily}
POST /type/{idFamily}/components/add
POST /type/{idFamily}/components/remove
Categories classify products. There are separate categories for ingredients / products, recipes, materials / tools and dishes, plus production categories, which group productions by order or joint execution. A category can be flagged as a cost or revenue category (for example, food or drink) or as a nutritional property category (for example, vegan).
Before you start
Base URL: https://app.tspoonlab.com/recipes/api
Headers
rememberme· required — Session token returned by the login.recipe· optional — Final-dish book id (Recipe centers), orallfor every book. For dish categories, only the products in that book are returned. Defaults to the user's active book.
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 categories. Creating requires permission to add categories; updating, assigning and removing, permission to edit categories; deleting, permission to delete categories.
Responses may include fields other than the documented ones. Use only the documented fields.
List categories
If the account uses a category hierarchy, only top-level categories are returned.
GET /listTypesPagedEx
Query parameters
typeinteger · required — Category type:0ingredients / products ·1recipes ·2materials / tools ·3dishes ·6production. Production categories are always included.startinteger · required — Position of the first row, starting at 0.rowsinteger · required — Number of rows to return.filterstring · optional — Text to filter by name or code.
Example
curl "https://app.tspoonlab.com/recipes/api/listTypesPagedEx?type=0&start=0&rows=50" \
-H "rememberme: $TOKEN"
Response
[
{
"id": "3515834441676562996102020401",
"descr": "Vegetables",
"type": 0,
"color": 3381555,
"codi": "VEG",
"costBinded": null,
"propertyBinded": null
}
]
idstring — Category id.descrstring — Name.typeinteger — Category type (seetypeabove).colorinteger — Color, as an RGB integer.codistring — Code.costBindedboolean —truefor a cost or revenue category.nullorfalseotherwise.propertyBindedboolean —truefor a nutritional property category.nullorfalseotherwise.
Retrieve a category
Returns the category with the first products it is assigned to. If the category does not exist, the response is empty.
GET /type/{idFamily}/num/{numComponents}Path parameters
idFamilystring · required — Category id.numComponentsinteger · required — Maximum number of products to return.
Example
curl https://app.tspoonlab.com/recipes/api/type/3515834441676562996102020401/num/20 \
-H "rememberme: $TOKEN"
Response
{
"id": "3515834441676562996102020401",
"descr": "Vegetables",
"type": 0,
"color": "33a033",
"codi": "VEG",
"costBinded": null,
"propertyBinded": null,
"listComponent": [
{
"id": "3515834441676562996102020501",
"idComponent": "3515834441676562996102020301",
"descr": "Fresh celery",
"type": 0,
"color": 3381555
}
]
}Same fields as the list, except:
colorstring — 6-digit hexadecimal color, without#.listComponentarray — Products with this category.
Each product:
idstring — Id of the assignment of the category to the product. Use it to remove the category.idComponentstring — Product id.descrstring — Product name.typeinteger —0ingredient / product ·1recipe ·2material / tool ·3dish.colorinteger — Category color, as an RGB integer.
List the products of a category
Use it to get more products than Retrieve a category returns.
GET /type/{idFamily}/components/pagedPath parameters
idFamilystring · required — Category id.
Query parameters
startinteger · optional — Position of the first row, starting at 0. Defaults to 0.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/type/3515834441676562996102020401/components/paged?start=0&rows=20" \
-H "rememberme: $TOKEN"
Response — List of products, with the same fields as listComponent in Retrieve a category.
Create a category
Returns the id of the new category.
POST /type
Body
descrstring · required — Name.colorstring · required — Hexadecimal color with#, for example#33A033. Required for every category type.typeinteger · optional — Category type (see List categories). Defaults to0.codistring · optional — Code.idParentstring · optional — Parent category. Only applies if the account uses a category hierarchy.costBindedboolean · optional —truefor a cost or revenue category.propertyBindedboolean · optional —truefor a nutritional property category.
Example
curl https://app.tspoonlab.com/recipes/api/type \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"descr": "Vegetables", "type": 0, "color": "#33A033", "codi": "VEG"}'
Response
{ "id": "3515834441676562996102020401" }Update a category
Replaces the name, color, code and the cost and nutritional property flags: any you do not send is left empty. The type and the parent category cannot be changed.
PUT /type/{idFamily}Path parameters
idFamilystring · required — Category id.
Body
descrstring · required — Name.colorstring · required — Hexadecimal color with#, for example#33A033.codistring · optional — Code.costBindedboolean · optional —truefor a cost or revenue category.propertyBindedboolean · optional —truefor a nutritional property category.
Example
curl -X PUT https://app.tspoonlab.com/recipes/api/type/3515834441676562996102020401 \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"descr": "Fresh vegetables", "color": "#33A033", "codi": "VEG"}'
Response — No content.
Delete a category
The category is removed from every product that had it. If it has been used in an inventory, it cannot be deleted.
DELETE /type/{idFamily}Path parameters
idFamilystring · required — Category id.
Example
curl -X DELETE https://app.tspoonlab.com/recipes/api/type/3515834441676562996102020401 \
-H "rememberme: $TOKEN"
Response — No content.
Assign a category to products
If the account uses a category hierarchy, each product loses the categories it had and gets this category and its parent categories.
POST /type/{idFamily}/components/addPath parameters
idFamilystring · required — Category id.
Body
componentsarray · required — Products to assign the category to. Up to 100 per call.
Each product:
idComponentstring · required — Product id.
Example
curl https://app.tspoonlab.com/recipes/api/type/3515834441676562996102020401/components/add \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"components": [{"idComponent": "3515834441676562996102020301"}]}'
Response — Assignments created, with the same fields as listComponent in Retrieve a category.
[
{
"id": "3515834441676562996102020501",
"idComponent": "3515834441676562996102020301",
"descr": "Fresh celery",
"type": 0,
"color": 3381555
}
]
Remove a category from products
POST /type/{idFamily}/components/removePath parameters
idFamilystring · required — Category id.
Body
componentsarray · required — Assignments to remove. Up to 100 per call.
Each assignment:
idstring · required — Assignment id (idinlistComponent). Ids that do not exist are ignored.
Example
curl https://app.tspoonlab.com/recipes/api/type/3515834441676562996102020401/components/remove \
-H "rememberme: $TOKEN" \
-H "Content-Type: application/json" \
-d '{"components": [{"id": "3515834441676562996102020501"}]}'
Response — No content.
Need help? Message us from the support chat in the bottom-right corner.
