Skip to content

Save a food

Saves a food or recipe to your foods, or changes one you saved.

POSThttps://app.splot.health/v1/foods

Needs the Read and write permission. The food is saved to the mine library, where only you see it.

FieldTypeDescription
namestringRequired. The food's name. Up to 200 characters.
dataobjectRequired. Nutrition, portions and recipe details.
brandstring or nullThe brand, for a packaged product. Up to 200 characters.
barcodestring or nullThe barcode: 8 to 14 digits.
copyFromobjectThe food this one was changed from, as { "library", "key" }, so where it came from is kept.
idstringTo change a food you saved before, its key. Leave out to save a new one.

Nutrition and measures need a base unit. A recipe’s ingredients are existing foods (food) or new ones (newFood), each with a portion such as { "amount": 200, "unit": "g" }. Splot adds up its nutrition per serving, and a recipe is always logged in servings.

If a new food’s barcode is already in the catalogue, the request answers 409 with food_in_catalog and the existing food. Log that one instead, or send copyFrom to save your own changed copy.

201 with the saved food.

Terminal window
curl https://app.splot.health/v1/foods \
-H "Authorization: Bearer $SPLOT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Overnight oats",
"data": {
"base": "serving",
"recipe": { "servings": 2, "steps": ["Stir everything together.", "Leave in the fridge overnight."] },
"ingredients": [
{ "food": { "library": "composition", "key": "c3f1a2b4-5d6e-4f70-8a91-b2c3d4e5f607" }, "portion": { "amount": 80, "unit": "g" } },
{ "newFood": { "name": "Oat milk", "data": { "base": "ml", "nutrition": { "basisAmount": 100, "values": { "kcal": 46, "carbs": 6.7, "fat": 1.5, "protein": 0.3 } } } }, "portion": { "amount": 250, "unit": "ml" } }
]
}
}'

Last updated