Record Reference Food View
Records that the calling member opened a food (action: open) or changed the portion of a food they opened (action: portion), and returns the food as stored after the change. Opening a food puts it at the top of the member's Recent list. Each call is kept in the member's own view history, including the search text for a food opened from search.
application/json- body
A food the member opened, or a portion change in an open food.
food_id*Food IdIdentifier of the food in the food database.
^[A-Za-z0-9][A-Za-z0-9_.:\-]*$1 <= length <= 128name*NameThe food's name as shown to the member.
1 <= length <= 200brand?|The brand as shown, for a branded food.
source*ReferenceFoodSourcegeneric for a general food, branded for a branded product.
"generic""branded"per_100g*The headline nutrients per 100 g, as shown to the member.
data_version*Data VersionVersion of the food data the member was shown.
^[A-Za-z0-9][A-Za-z0-9_.:+\-]*$1 <= length <= 64action*ReferenceFoodViewActionopen when the member opened the food. portion when they changed the portion of a food they already opened.
"open""portion"opened_from*ReferenceFoodOpenedFromThe tab the food was opened from: search, recent or saved.
"search""recent""saved"portion?|The portion shown. Required for portion. On open it becomes the food's last portion; when omitted the last portion is kept.
result_position?|Where the food appeared in the search results, starting at 1 (at most 10000). Only for open from search.
query?|The search text that found the food. Kept in the member's own view history only. Only for open from search.
Successful Response
application/json- response
A food the member opened, with its Saved and Recent state.
food_id*Food IdIdentifier of the food in the food database.
name*NameThe food's name as last shown.
brand*|The brand, for a branded food.
source*ReferenceFoodSourcegeneric for a general food, branded for a branded product.
"generic""branded"saved*SavedWhether the member saved this food.
saved_at*|When the member saved it; null while it is not saved.
first_viewed_at*First Viewed AtWhen the member first opened it.
date-timelast_viewed_at*Last Viewed AtWhen the member last opened it or changed its portion.
date-timeview_count*View CountHow many times the member opened it.
last_portion*|The portion the member last looked at, if any.
per_100g*The headline nutrients per 100 g, as last shown.
data_version*Data VersionVersion of the food data the member was last shown.
curl -X POST 'https://api.bettermenu.live/studio/reference/foods/views' \ -H 'Content-Type: application/json' \ -d '{ "food_id": "string", "name": "string", "source": "generic", "per_100g": {}, "data_version": "string", "action": "open", "opened_from": "search"}'{ "food_id": "string", "name": "string", "brand": "string", "source": "generic", "saved": true, "saved_at": "2019-08-24T14:15:22Z", "first_viewed_at": "2019-08-24T14:15:22Z", "last_viewed_at": "2019-08-24T14:15:22Z", "view_count": 0, "last_portion": { "label": "string", "grams": 0.001 }, "per_100g": { "calories": 0, "total_fat": 0, "total_carbohydrate": 0, "protein": 0 }, "data_version": "string"}