Open Food Log

Development draft, v0. The format may change; every change is in the changelog.

Open Food Log v0

Three documents. Nutrients are per 100 g on a food and as eaten on a meal item, each key in the unit it names. Every value a server did not get from the person or a source is listed in estimates. The rules are in the specification.

Open Food Log v0: meal

One meal or snack: what the person said they ate, the food each item was matched to, how much, what it held, and where the record came from. Draft; may change until v1. Schema: https://openfoodlog.org/schema/v0/meal.json.

FieldTypeMeaning
$schemathe constant https://openfoodlog.org/schema/v0/meal.json
datestring (date)The person's local day, for a meal logged without a time. With eaten_at as well, it must be eaten_at's day in the person's time zone.
eaten_atstring (date-time)When it was eaten, with an offset.
estimatesarray of stringJSON pointers (RFC 6901) to values that were inferred or assumed rather than given: a size the person didn't say, a weight read from a photo, a food's numbers a model guessed.
idstringAssigned by the server that stores the meal.
items requiredarray of item
meal_typeone of breakfast, lunch, dinner, snack
notesstring
source requiredsource
titlestring
updated_atstring (date-time)When the stored record last changed, by the server's clock. For mirroring; absent from a document that was never stored.

amount

How much, in the measure the person used.

FieldTypeMeaning
portionstringWith unit portion: the id of one of the food's portions.
unit requiredone of g, kg, oz, lb, ml, l, fl_oz, portion
value requirednumber

food

The food an item was matched to. catalogue and custom are confirmed; close and unmatched need the person to confirm; none means there is nothing to match, because the person gave the numbers themselves ('about 600 calories').

FieldTypeMeaning
id requiredstring or nullA food ID (ofc:, gtin:, usr: or another namespace); null when nothing matched.
match requiredone of catalogue, close, custom, unmatched, none
name requiredstring

item

One thing eaten.

FieldTypeMeaning
amountamount
foodfood
gramsnumberThe amount as a weight, worked out from amount and the food's portions or density (section 6 of the spec).
idstringAssigned by the server; used to edit the item.
notesstring
nutrientsnutrientsWhat this item held, as counted when it was logged. It does not change when the food's record later does. A key left out is unknown, never zero.
text requiredstringWhat the person called it, in their words.

source

Provenance: where the record came from. The same shape as an Open Workout Schema workout's.

FieldTypeMeaning
clientstringThe client or app, e.g. claude, myfitnesspal, cronometer.
external_idstring or nullThe meal's ID in the app it came from.
kind requiredone of app, mcp, api, import

Open Food Log v0: food

One food: what it is, what 100 g of it holds, and the portions people measure it in. Draft; may change until v1. Schema: https://openfoodlog.org/schema/v0/food.json.

FieldTypeMeaning
$schemathe constant https://openfoodlog.org/schema/v0/food.json
aliasesarray of object
brandstring
density_g_per_mlnumberGrams per millilitre, so an amount in ml or fl oz can be weighed. Leave it out when it isn't known.
gtinarray of stringBarcodes the product is sold under, as 14 digits (shorter codes zero-padded on the left).
id requiredstringnamespace:slug. ofc: is the Open Food Catalogue; gtin: is a packaged product by its GTIN as 14 digits; usr: is one person's own food, meaningful only where it was made.
identifiersobjectThe food's IDs in other databases.
kind requiredone of generic, branded, restaurant, customgeneric: a food as such (a raw egg). branded: a packaged product. restaurant: a dish as one restaurant serves it. custom: a person's own food.
name requiredstringThe canonical name, in English for the catalogue.
nutrients_per_100g requirednutrientsWhat 100 g of the food holds, as eaten in the state the name says (raw, cooked, dry). A nutrient left out is unknown, never zero.
portionsarray of portionNamed measures with their weight: '1 large' egg is 50 g, '1 cup' of oats 81 g. Cups and spoons are portions, because what they weigh depends on the food.
previous_idsarray of string
provenanceprovenance
replaced_bystring
statusone of active, deprecated, replaced

nutrients

Amounts keyed by nutrient, each in the unit its key names (nutrients.json). A key left out is unknown, never zero. x- keys are a producer's own.

FieldTypeMeaning
added_sugars_gnumber
alcohol_gnumber
caffeine_mgnumber
calcium_mgnumber
carbohydrate_gnumber
cholesterol_mgnumber
energy_kcalnumber
fat_gnumber
fiber_gnumber
iron_mgnumber
magnesium_mgnumber
monounsaturated_fat_gnumber
polyunsaturated_fat_gnumber
potassium_mgnumber
protein_gnumber
saturated_fat_gnumber
sodium_mgnumber
sugars_gnumber
trans_fat_gnumber
vitamin_a_rae_ugnumber
vitamin_c_mgnumber
vitamin_d_ugnumber
water_gnumber
zinc_mgnumber

portion

FieldTypeMeaning
grams requirednumber
id requiredstringUnique within the food; a meal item names it.
is_defaultbooleanThe portion to assume when a person names the food without a size. At most one per food.
label requiredstringWhat one of it is called: '1 large', '1 cup, sliced'.

provenance

FieldTypeMeaning
generatedarray of stringJSON pointers to values a model produced rather than a source or a person.
licensestringThe record's own licence, as an SPDX identifier.
reviewone of unreviewed, reviewed
sourcesarray of object

Open Food Log v0: log

A person's whole food log as one file: what an export holds and an import can read. A server may add more of the person's record beside these keys; readers ignore keys they don't know. Draft; may change until v1. Schema: https://openfoodlog.org/schema/v0/log.json.

FieldTypeMeaning
$schemathe constant https://openfoodlog.org/schema/v0/log.json
deleted_mealsarray of objectMeals the person deleted, newest first, for a server that keeps them until the account is deleted.
exported_at requiredstring (date-time)
foodsarray of food.jsonThe person's own foods (usr:) that the meals name, so a reader elsewhere can resolve them. Catalogue and gtin: foods may be included too.
meals requiredarray of meal.jsonEvery meal in the log, newest first.