Skip to main content

REST API: Categories

How to retrieve, create, update, delete, and assign categories.

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), or all for 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

  • type integer · required — Category type: 0 ingredients / products · 1 recipes · 2 materials / tools · 3 dishes · 6 production. Production categories are always included.

  • 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 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
}
]
  • id string — Category id.

  • descr string — Name.

  • type integer — Category type (see type above).

  • color integer — Color, as an RGB integer.

  • codi string — Code.

  • costBinded boolean — true for a cost or revenue category. null or false otherwise.

  • propertyBinded boolean — true for a nutritional property category. null or false otherwise.


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

  • idFamily string · required — Category id.

  • numComponents integer · 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:

  • color string — 6-digit hexadecimal color, without #.

  • listComponent array — Products with this category.

Each product:

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

  • idComponent string — Product id.

  • descr string — Product name.

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

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

Path parameters

  • idFamily string · required — Category id.

Query parameters

  • start integer · optional — Position of the first row, starting at 0. Defaults to 0.

  • 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/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

  • descr string · required — Name.

  • color string · required — Hexadecimal color with #, for example #33A033. Required for every category type.

  • type integer · optional — Category type (see List categories). Defaults to 0.

  • codi string · optional — Code.

  • idParent string · optional — Parent category. Only applies if the account uses a category hierarchy.

  • costBinded boolean · optional — true for a cost or revenue category.

  • propertyBinded boolean · optional — true for 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

  • idFamily string · required — Category id.

Body

  • descr string · required — Name.

  • color string · required — Hexadecimal color with #, for example #33A033.

  • codi string · optional — Code.

  • costBinded boolean · optional — true for a cost or revenue category.

  • propertyBinded boolean · optional — true for 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

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

Path parameters

  • idFamily string · required — Category id.

Body

  • components array · required — Products to assign the category to. Up to 100 per call.

Each product:

  • idComponent string · 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/remove

Path parameters

  • idFamily string · required — Category id.

Body

  • components array · required — Assignments to remove. Up to 100 per call.

Each assignment:

  • id string · required — Assignment id (id in listComponent). 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.

Did this answer your question?