API Directory › 🍔 Food & Drink › Nutritionix
API KeyHTTPSCORS

Nutritionix API

Natural-language nutrition lookup and a large food database.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Nutritionix docs ↗

What it does

Nutritionix hosts the largest verified nutrition database (1M+ grocery items, restaurant menu items and common foods) and a natural-language endpoint: send “1 cup rice and 2 eggs” and get back per-item calories, macros and micros. It also parses exercise descriptions into calories burned.

Base URL

https://trackapi.nutritionix.com/v2

Authentication

Sign up for free credentials and send them as the x-app-id and x-app-key headers. Add x-remote-user-id (use 0 during development).

Code examples

curl (natural language nutrients)
curl -s -X POST https://trackapi.nutritionix.com/v2/natural/nutrients \
  -H "x-app-id: $NIX_ID" -H "x-app-key: $NIX_KEY" \
  -H "x-remote-user-id: 0" -H "Content-Type: application/json" \
  -d '{"query":"1 cup cooked rice and 2 large eggs"}'
Python
import requests

r = requests.post("https://trackapi.nutritionix.com/v2/natural/nutrients",
    headers={"x-app-id": NIX_ID, "x-app-key": NIX_KEY, "x-remote-user-id": "0"},
    json={"query": "big mac"}, timeout=10)
f = r.json()["foods"][0]
print(f["food_name"], f["nf_calories"], "kcal", f["nf_protein"], "g protein")

Rate limits & quotas

Free tier: about 200 requests/day to /natural/nutrients and a larger allowance for /search/instant (autocomplete). Over the daily cap returns HTTP 409/429. The /natural/* endpoints are POST with a JSON query string.

Key response fields

foods[].food_name / serving_qty / serving_unitParsed item and portion
foods[].nf_calories / nf_protein / nf_total_fat / nf_total_carbohydrateCore macros
foods[].full_nutrients[]Every USDA nutrient by attr_id
foods[].photo.thumbItem image
(instant search) common[] / branded[]Autocomplete suggestions by type

Common errors

401Missing/invalid x-app-id or x-app-key.
404 "We couldn't match any of your foods"The parser did not recognise the query — be more specific.
409 / 429Daily request limit reached.
400Empty or malformed JSON body.

When to use it (and alternatives)

The pick for calorie-tracking and food-logging apps — the natural-language parsing and restaurant coverage are its edge. For raw, citable government nutrient data use USDA FoodData Central; for recipe-centric work, Spoonacular.

FAQ

What is x-remote-user-id for?

It attributes API usage to your individual end users (for Nutritionix’s licensing). Use 0 while developing; in production send a stable per-user id.

Can it understand brand and restaurant items?

Yes — “grande caramel macchiato” or “chipotle chicken bowl” resolve to branded/restaurant entries. Ambiguous queries return the best guess; refine with quantities and brand names.

How accurate are the numbers?

Branded items come from label data; common foods from USDA. It is good for consumer tracking, not for clinical or regulatory use.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

JSON Formatter

Related Food & Drink APIs

← Back

More Food & Drink APIs · All 196 APIs