Cook Nutrition API

Getting started

The nutrition report extension is open-source glue that plugs the proprietary Cook nutrition service into cook report (cooklang-reports). It registers jinja functions — nutrition_for(), aggregate_nutrition(), compare(), the ck check macros, and more — so report templates can pull real nutrition data and assert dietitian-style checks.

See the function reference for the full list and the API reference for the underlying HTTP endpoints.

Prerequisites

Point the client at the service

export NUTRITION_API_URL=https://api.cooklang.org/nutrition/v1
export NUTRITION_API_KEY=sk_live_...        # if the service has auth enabled

Run a report

# single recipe
cook-nutrition-demo --client docs/examples/clients/sara-mendez.yaml \
  sara-recipe-report.md.jinja recipe.cook

# weekly meal plan
cook-nutrition-demo --base-path ./plan --client docs/examples/clients/sara-mendez.yaml \
  sara-week-report.md.jinja "Week of May 18.menu"

The example templates above (sara-recipe-report.md.jinja, sara-week-report.md.jinja) ship in the demo's examples-bin/cook-nutrition-demo/fixtures/ directory of the cooklang-reports-nutrition repo.

The exit code is 0 when every recorded check passed, 1 when any check failed, and 2 on usage errors — which lets a generator loop on a report until it passes.

Next steps