Skip to content
Skip to Content
Docs
Studio

Compute Nutrition Facts

Compute compliant-rounded nutrition facts for a serving.

Applies compliant rounding rules to produce per-serving and optionally per-container nutrition facts.

The top-level version_id identifies the new version created by this operation. Pass it back as If-Match on the next mutation.

409 scenarios and recovery — check steps_required in the response:

  • MISSING_DEPENDENCY: no nutrition -> call setRecipeIngredients first
  • STALE_DEPENDENCY: ingredients changed since nutrition was computed -> re-call setRecipeIngredients
  • MISSING_DEPENDENCY: no serving -> call addRecipeServing After completing steps_required, retry this call.

Available only on API versions declaring the recipe_versioning capability. Requests without this capability receive a 404.

Related endpoints:

  • getRecipePerServingNutritionFacts — retrieve the stored result
POST
/studio/recipes/{recipe_id}/servings/{serving_id}/nutrition-facts/compute

Path Parameters

recipe_id*Recipe Id
serving_id*Serving Id

Header Parameters

If-Match*string

The recipe's current version_id: the one the last change to this recipe returned, or the one reading the recipe returns (get_recipe). A stale value is refused with the current version_id; read the recipe again and retry.

Response Body

Successful Response

application/json
  1. response

Response for computeNutritionFacts (atomic step).

data*

Data payload for compute nutrition facts response (Step ⑥).

meta*

Response metadata.

version_id?|

Version committed for this mutation; pass on the next request as If-Match for optimistic concurrency. Present only on versions declaring the recipe_versioning capability.

Example Request
curl -X POST 'https://api.bettermenu.live/studio/recipes/string/servings/string/nutrition-facts/compute' \  -H 'If-Match: string'
Example Response
{  "data": {    "recipe_id": "string",    "serving_id": "string",    "per_serving": {      "calculated_at": "string",      "serving_id": "string",      "demographic": "string",      "reference_weight_grams": 0,      "nutrients": [        {          "bmid": "string",          "name": "string",          "amount": 0,          "unit": "string",          "display_text": "string",          "percent_daily_value": 0        }      ]    },    "per_container": {      "calculated_at": "string",      "serving_id": "string",      "demographic": "string",      "reference_weight_grams": 0,      "nutrients": [        {          "bmid": "string",          "name": "string",          "amount": 0,          "unit": "string",          "display_text": "string",          "percent_daily_value": 0        }      ]    }  },  "meta": {    "version": "string",    "request_id": "string",    "timestamp": "string"  },  "version_id": "string"}

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

Start freeNo card needed.