Skip to content
Skip to Content
Docs
ApiConversions

Compute gram weights for ingredients

Compute gram weights for ingredient items — convert quantities to grams using portion data and standard measurement tables.

② of 5 | Next: ④ setRecipeIngredients Stateless — no recipe needed yet.

Use this to answer: "how many grams is 2 cups of flour?", "convert 3 eggs to grams", "get gram weight for these ingredients", "what does 1 pinch of saffron weigh?"

① searchIngredients returns matches with no gram-weight detail — always follow with this step to resolve a picked ingredient's quantity to grams. Accepts a batch of (ingredient_id, quantity, unit) items and returns gram weights.

Pass portion_id (from getIngredient's portions[].id) instead of unit to resolve a specific portion directly, bypassing unit string matching. This is the only way to resolve a branded product's default serving, which has no unit name to match against.

When no portion match exists, returns resolve_options guiding the caller to either re-call with allow_estimation: true (system estimate) or ask the user for quantity_grams directly.

Every result carries gram_weight.conversion_source, so a caller can tell a deterministic gram weight (USDA_FOOD_PORTIONS, USDA_MEASUREMENT_TABLES, identity) from an estimated one (system_estimate), with the arithmetic in steps[].reasoning. Both channels read the same field; neither is offered a different answer for the same policy decision.

POST
/us/conversions/compute

Request Body

application/json
  1. body

Batch conversion request.

country_code?Country Code

Market code (US), the same value market and a recipe's country take. Selects the ingredient data and conversion rules.

Default"US"
items*array<>
Items1 <= items <= 50
allow_estimation?Allow Estimation

When true, use estimation for items without a deterministic portion match.

Defaultfalse

Response Body

Successful Response

application/json
  1. response
[key: string]?any
Example Request
curl -X POST 'https://api.bettermenu.live/us/conversions/compute' \  -H 'Content-Type: application/json' \  -d '{  "items": [    {      "ingredient_id": "string",      "quantity": "2",      "unit": "cup"    }  ]}'
Example Response
{}

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

Start freeNo card needed.