Nutritionix API
Natural-language nutrition lookup and a large food database.
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
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 -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"}'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_unit | Parsed item and portion |
| foods[].nf_calories / nf_protein / nf_total_fat / nf_total_carbohydrate | Core macros |
| foods[].full_nutrients[] | Every USDA nutrient by attr_id |
| foods[].photo.thumb | Item image |
| (instant search) common[] / branded[] | Autocomplete suggestions by type |
Common errors
| 401 | Missing/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 / 429 | Daily request limit reached. |
| 400 | Empty 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.