BETTERMENU
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

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://api.bettermenu.live/us/conversions/compute" \  -H "Content-Type: application/json" \  -d '{    "items": [      {        "ingredient_id": "string",        "quantity": "2",        "unit": "cup"      }    ]  }'
{}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
BETTERMENU

FDA-compliant nutrition labels from a recipe, in minutes.

Visit bettermenu.live