REST API + MCP server · one key, one quota

Nutrition data for 1M+ foods, built for apps and AI agents

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"

Everything you need to ship a food feature

The endpoints developers ask us for first:

Lookup

Food by ID

Complete nutrition profile for any USDA FDC ID in one call — macros, vitamins, minerals, fatty acids and amino acids.

Search

Autocomplete & search

Prefix-boosted name search tuned for typeahead dropdowns — lightweight results with the IDs you pass straight to the lookup endpoint.

Barcode

Barcode / UPC

Scan a product barcode, get the food and its full nutrition. Built for grocery, pantry and label apps.

AI agents

MCP server

The same data as native tools for AI agents. One config block connects Claude, Cursor or ChatGPT to live nutrition data.

Batch

Batch & compare

Fetch up to 50 foods in one request for meal plans, comparisons and import pipelines.

Pricing

Start free. Upgrade when you outgrow it — REST + MCP share one quota.

Free Trial

$0
100 calls/mo
10 req/min
All endpoints + MCP
Get started free

Starter

$19/mo
10,000 calls/mo
60 req/min
All endpoints + MCP

Growth

$89/mo
100,000 calls/mo
300 req/min
All endpoints + MCP

Scale

Custom
1,000,000 calls/mo
1,200 req/min
All endpoints + MCP
Contact us

API reference

Base URL: https://api.myfooddata.com · All endpoints except /health and /v1/plans require a key.

Method & pathDescriptionReturns
GET /v1/foods/{fdc_id}Full nutrition by USDA FDC IDFood + all nutrient groups
GET /v1/foods?ids=173944,171077Batch lookup (max 50){ count, foods[] }
GET /v1/foods/upc/{code}Food by barcode / GTIN-UPCFood + all nutrient groups
GET /v1/search?q=chicken&limit=20Search / autocomplete by name (limit ≤ 50){ query, count, results[] }
GET /v1/nutrientsNutrient catalog (54 nutrients: slug, label, unit, %DV)Catalog by category
GET /v1/plansPublic plan catalog (no key needed)Quotas, rate limits, prices
POST /mcpMCP server (Streamable HTTP) — see belowJSON-RPC responses

Example response — 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" } }
  }
}

Authentication & errors

Send your key on every request (either header works):

Authorization: Bearer mfd_live_...
X-API-Key: mfd_live_...
HTTPCodeMeaning
401MISSING_API_KEY / INVALID_API_KEYNo key, or key not recognized
403API_KEY_INACTIVEKey revoked or suspended
404FOOD_NOT_FOUNDUnknown ID / UPC
429RATE_LIMITED / QUOTA_EXCEEDEDSlow 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.

Autocomplete & search

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.

Typeahead dropdown

Debounce ~200 ms, then:

GET /v1/search?q=chick&limit=5

Render name + brand_owner; on select, call /v1/foods/{fdc_id}.

Full search results

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.

Barcode scanning

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.

MCP — for AI agents

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" }
    }
  }
}
ToolWhat the agent can doREST equivalent
get_foodFull nutrition for one food by FDC IDGET /v1/foods/{id}
search_foodsFind foods by name, get IDs to look upGET /v1/search
get_nutrient_infoLabel, unit & daily value for a nutrientGET /v1/nutrients
compare_foodsSide-by-side nutrition for 2–10 foodsGET /v1/foods?ids=
get_food_by_upcRoadmapResolve a scanned barcode to a foodGET /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.

Quickstart

JavaScript

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();

Python

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"])

Your API keys

Loading…