Skip to content
Skip to Content
Docs
Studio

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.

POST
/studio/reference/foods/views

Request Body

application/json
  1. body

A food the member opened, or a portion change in an open food.

food_id*Food Id

Identifier of the food in the food database.

Match^[A-Za-z0-9][A-Za-z0-9_.:\-]*$
Length1 <= length <= 128
name*Name

The food's name as shown to the member.

Length1 <= length <= 200
brand?|

The brand as shown, for a branded food.

source*ReferenceFoodSource

generic for a general food, branded for a branded product.

Value in"generic""branded"
per_100g*

The headline nutrients per 100 g, as shown to the member.

data_version*Data Version

Version of the food data the member was shown.

Match^[A-Za-z0-9][A-Za-z0-9_.:+\-]*$
Length1 <= length <= 64
action*ReferenceFoodViewAction

open when the member opened the food. portion when they changed the portion of a food they already opened.

Value in"open""portion"
opened_from*ReferenceFoodOpenedFrom

The tab the food was opened from: search, recent or saved.

Value in"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.

Response Body

Successful Response

application/json
  1. response

A food the member opened, with its Saved and Recent state.

food_id*Food Id

Identifier of the food in the food database.

name*Name

The food's name as last shown.

brand*|

The brand, for a branded food.

source*ReferenceFoodSource

generic for a general food, branded for a branded product.

Value in"generic""branded"
saved*Saved

Whether the member saved this food.

saved_at*|

When the member saved it; null while it is not saved.

first_viewed_at*First Viewed At

When the member first opened it.

Formatdate-time
last_viewed_at*Last Viewed At

When the member last opened it or changed its portion.

Formatdate-time
view_count*View Count

How 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 Version

Version of the food data the member was last shown.

Example Request
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"}'
Example Response
{  "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"}

Recipe in, FDA-format Nutrition Facts out, with every version kept.

Start freeNo card needed.