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.
application/json- body
Batch conversion request.
country_code?Country CodeMarket code (US), the same value market and a recipe's country take. Selects the ingredient data and conversion rules.
"US"items*array<>1 <= items <= 50allow_estimation?Allow EstimationWhen true, use estimation for items without a deterministic portion match.
falseSuccessful Response
application/json- response
[key: string]?anycurl -X POST 'https://api.bettermenu.live/us/conversions/compute' \ -H 'Content-Type: application/json' \ -d '{ "items": [ { "ingredient_id": "string", "quantity": "2", "unit": "cup" } ]}'{}