Full nutrition — macros, vitamins, minerals, fatty acids and amino acids — by USDA FDC ID, name search, or barcode. Over REST for your app, and over MCP for Claude, ChatGPT and Cursor.
curl https://api.myfooddata.com/v1/foods/173944 \ -H "Authorization: Bearer mfd_live_YOUR_KEY"
The endpoints developers ask us for first:
Complete nutrition profile for any USDA FDC ID in one call — macros, vitamins, minerals, fatty acids and amino acids.
Prefix-boosted name search tuned for typeahead dropdowns — lightweight results with the IDs you pass straight to the lookup endpoint.
Scan a product barcode, get the food and its full nutrition. Built for grocery, pantry and label apps.
The same data as native tools for AI agents. One config block connects Claude, Cursor or ChatGPT to live nutrition data.
Fetch up to 50 foods in one request for meal plans, comparisons and import pipelines.
Start free. Upgrade when you outgrow it — REST + MCP share one quota.
Base URL: https://api.myfooddata.com · All endpoints except /health and /v1/plans require a key.
| Method & path | Description | Returns |
|---|---|---|
GET /v1/foods/{fdc_id} | Full nutrition by USDA FDC ID | Food + all nutrient groups |
GET /v1/foods?ids=173944,171077 | Batch lookup (max 50) | { count, foods[] } |
GET /v1/foods/upc/{code} | Food by barcode / GTIN-UPC | Food + all nutrient groups |
GET /v1/search?q=chicken&limit=20 | Search / autocomplete by name (limit ≤ 50) | { query, count, results[] } |
GET /v1/nutrients | Nutrient catalog (54 nutrients: slug, label, unit, %DV) | Catalog by category |
GET /v1/plans | Public plan catalog (no key needed) | Quotas, rate limits, prices |
POST /mcp | MCP server (Streamable HTTP) — see below | JSON-RPC responses |
GET /v1/foods/173944{
"fdc_id": 173944,
"name": "Bananas",
"brand_owner": null,
"data_source": "Standard Release (Common)",
"serving": { "description": "wt2", "weight_grams": 150 },
"nutrients": {
"macros": {
"calories": { "label": "Calories", "value": 89,
"unit": "calories", "dv_percent": 4 },
"protein": { "label": "Protein", "value": 1.1, "unit": "g" }
},
"vitamins": { "vitamin-c": { "label": "Vitamin C",
"value": 12.3, "unit": "mg" } },
"minerals": { "potassium": { "label": "Potassium",
"value": 537, "unit": "mg" } }
}
}
Send your key on every request (either header works):
Authorization: Bearer mfd_live_... X-API-Key: mfd_live_...
| HTTP | Code | Meaning |
|---|---|---|
| 401 | MISSING_API_KEY / INVALID_API_KEY | No key, or key not recognized |
| 403 | API_KEY_INACTIVE | Key revoked or suspended |
| 404 | FOOD_NOT_FOUND | Unknown ID / UPC |
| 429 | RATE_LIMITED / QUOTA_EXCEEDED | Slow down, or upgrade plan |
Every response carries X-API-Plan, X-API-Calls-Used and
X-API-Calls-Remaining so your app can warn before hitting a limit. Keys are
SHA-256 hashed at rest, shown once at creation, and revocable instantly.
One endpoint, two jobs. Results are ordered prefix-first (exact starts before mid-word matches, shorter names first) with a payload small enough for every keystroke.
Debounce ~200 ms, then:
GET /v1/search?q=chick&limit=5
Render name + brand_owner; on select, call /v1/foods/{fdc_id}.
GET /v1/search?q=chicken+breast&limit=20
Same endpoint with a larger limit (max 50) for a results page.
{ "query": "chick", "count": 2, "results": [
{ "fdc_id": 102109570, "name": "Chicken", "brand_owner": null,
"data_source": "Open Food Facts", "serving": { "weight_grams": 100 } } ] }
Note: matching is substring-based today — no typo tolerance or relevance ranking yet.
Point a scanner (or phone camera) at any packaged food:
GET /v1/foods/upc/3017620422003 → 200 { fdc_id, name, brand_owner, nutrients… }
GET /v1/foods/upc/000000000000 → 404 { "error": { "code": "FOOD_NOT_FOUND" } }
On a 404, fall back to /v1/search with the product name so the user can pick the
closest match. UPCs resolve via the curated barcode map first, then the food database’s own GTIN field.
The same key unlocks our remote MCP server. Add this to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"myfooddata": {
"url": "https://api.myfooddata.com/mcp",
"headers": { "Authorization": "Bearer mfd_live_YOUR_KEY" }
}
}
}
| Tool | What the agent can do | REST equivalent |
|---|---|---|
get_food | Full nutrition for one food by FDC ID | GET /v1/foods/{id} |
search_foods | Find foods by name, get IDs to look up | GET /v1/search |
get_nutrient_info | Label, unit & daily value for a nutrient | GET /v1/nutrients |
compare_foods | Side-by-side nutrition for 2–10 foods | GET /v1/foods?ids= |
get_food_by_upcRoadmap | Resolve a scanned barcode to a food | GET /v1/foods/upc/{code} |
Try it: ask your agent “Using MyFoodData, search for Greek yogurt and cottage cheese, then compare their protein.” MCP calls share your key’s monthly quota with REST.
const res = await fetch(
'https://api.myfooddata.com/v1/search?q=banana&limit=5',
{ headers: { Authorization: 'Bearer mfd_live_YOUR_KEY' } }
);
const data = await res.json();
const food = await (await fetch(
'https://api.myfooddata.com/v1/foods/' + data.results[0].fdc_id,
{ headers: { Authorization: 'Bearer mfd_live_YOUR_KEY' } }
)).json();import requests
H = {"Authorization": "Bearer mfd_live_YOUR_KEY"}
r = requests.get("https://api.myfooddata.com/v1/search",
params={"q": "banana", "limit": 5},
headers=H, timeout=30)
for f in r.json()["results"]:
print(f["fdc_id"], f["name"])Loading…