Microproduct data guideintermediate

USDA FoodData Central

USDA analytical and branded-food nutrient records for building nutrition comparisons, ingredient research, and food-search products.

At a glance

Difficulty
Intermediate — some data preparation helps
Size
Small · ≤0.1 GB
Formats
JSON, CSV, XLSX
Access
API or Download
API key
Required
Provider
U.S. Department of Agriculture Agricultural Research Service
Updates
Monthly
Data terms
Creative Commons CC0 1.0 Universal

From source to product signal

Test a product idea in four steps

FoodData Central combines USDA analytical food records with other data types, including manufacturer-supplied branded records. Start with a bounded search of Foundation and SR Legacy foods and one nutrient reported per 100 grams. Normalize units and keep each record's data type visible before comparing values.

1

Check the setup

  • Python 3.10 or newer
  • A notebook environment such as Jupyter or Google Colab
  • A data.gov API key saved in the FDC_API_KEY environment variable
2

Access the data

  1. 1.Request a data.gov API key and save it in the FDC_API_KEY environment variable.
  2. 2.Read the FoodData Central data-type documentation and choose analytical or branded records intentionally.
  3. 3.Search a bounded page and verify the nutrient name, unit, basis, and data type before comparison.
Open official source
3

Run the Python example

Install the packages, then run the notebook cell.

python -m pip install pandas requests

import os
import pandas as pd
import requests

response = requests.post(
    "https://api.nal.usda.gov/fdc/v1/foods/search",
    params={"api_key": os.environ["FDC_API_KEY"]},
    json={
        "query": "lentils",
        "dataType": ["Foundation", "SR Legacy"],
        "pageSize": 25,
        "pageNumber": 1,
    },
    timeout=30,
)
response.raise_for_status()
rows = []
for food in response.json()["foods"]:
    for nutrient in food.get("foodNutrients", []):
        if nutrient.get("nutrientName") == "Protein":
            rows.append({
                "fdcId": food["fdcId"],
                "description": food["description"],
                "dataType": food["dataType"],
                "protein_per_100g": nutrient.get("value"),
                "unit": nutrient.get("unitName"),
            })
protein = pd.DataFrame(rows)
protein["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(protein.sort_values("protein_per_100g", ascending=False).head(20))
4

Test a useful signal

Compare protein across lentil records

Compare protein per 100 grams across a bounded set of USDA analytical lentil search results.

  1. 01Retain FDC ID and data type and confirm that each selected protein value uses the same per-100-gram basis and unit.
  2. 02Remove duplicate or incomparable descriptions and rank the remaining Foundation and SR Legacy records.
  3. 03Explain how preparation state, moisture, analytical method, search matching, and manufacturer-supplied branded records can make nutrient comparisons misleading.

Dataset details

U.S. Department of Agriculture Agricultural Research Service is a government source. Last verified 2026-08-11. Temporal coverage: current releases with historical reference datasets.

Domains

NutritionFood Science

Data types

Reference DataTabular

Tasks

Nutrient ComparisonProduct ResearchSearch

Geography

United States

Formats

JSONCSVXLSX

Provider

U.S. Department of Agriculture Agricultural Research Service

Data terms

Creative Commons CC0 1.0 Universal