API Directory › 🍔 Food & Drink › USDA FoodData Central
API KeyHTTPSCORS

USDA FoodData Central API

US government database of detailed food and nutrient data.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open USDA FoodData Central docs ↗

What it does

USDA FoodData Central (FDC) is the US government’s authoritative food-composition database: Foundation Foods, SR Legacy, branded products (label data for 400k+ items) and the FNDDS survey database. Search foods and retrieve complete nutrient profiles with citable provenance.

Base URL

https://api.nal.usda.gov/fdc/v1

Authentication

Get a free api.data.gov key and pass it as ?api_key=YOUR_KEY. DEMO_KEY works for a quick test at a very low limit.

Code examples

curl
curl -s "https://api.nal.usda.gov/fdc/v1/foods/search?query=cheddar%20cheese&pageSize=3&api_key=$FDC_KEY"
Python
import requests

r = requests.get("https://api.nal.usda.gov/fdc/v1/foods/search",
    params={"query": "banana raw", "dataType": "Foundation,SR Legacy",
            "pageSize": 1, "api_key": KEY}, timeout=10)
food = r.json()["foods"][0]
for n in food["foodNutrients"]:
    if n["nutrientName"] in ("Energy", "Protein", "Potassium, K"):
        print(n["nutrientName"], n["value"], n["unitName"])

Rate limits & quotas

api.data.gov standard limit: 1,000 requests/hour per key (per IP for DEMO_KEY, which is far lower). Rate-limit headers (X-RateLimit-Remaining) are returned; over the limit is HTTP 429. Search pageSize max 200; use dataType to scope results.

Key response fields

foods[].fdcIdStable identifier — use with /food/{fdcId}
foods[].description / brandOwnerFood name and (branded) manufacturer
foods[].dataTypeFoundation, SR Legacy, Branded, Survey (FNDDS)
foods[].foodNutrients[].nutrientName / value / unitNameEach nutrient per 100 g
totalHits / currentPage / totalPagesPagination

Common errors

403 API_KEY_INVALID / OVER_RATE_LIMITBad key, or hourly cap hit (tiny for DEMO_KEY).
400Missing query, or an invalid dataType value.
404Unknown fdcId on the detail endpoint.

When to use it (and alternatives)

The reference source when you need trustworthy, citable nutrient data — nutrition science, labelling checks, public-health tools. For natural-language food logging, Nutritionix is friendlier; for recipes, Spoonacular.

FAQ

Which dataType should I search?

For whole foods and cooking, prefer Foundation and SR Legacy (lab-analysed, per 100 g). Branded is label-declared and huge but noisier. Survey (FNDDS) is for dietary intake studies.

Are nutrient values per serving or per 100 g?

Per 100 g / 100 mL in Foundation and SR Legacy. Branded items also include servingSize and label-serving nutrients. Convert explicitly.

Is DEMO_KEY enough?

Only for a first look — it is rate-limited to a handful of requests. A free api.data.gov key (1,000/hour) takes a minute to get.

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