Migration Guide (v1 -> v2)
High-level overview
Section titled “High-level overview”Compared to v1, v2 introduces three main changes:
- Serving sizes are returned directly in food and search responses.
- Labels are included in multiple places (especially nutrient values and search variants).
- FoodDTO includes additional nutrient fields (see full list below).
Important for existing integrations:
/api/*without explicit version still points to v1 (legacy behavior).- v2 is available only under
/api/v2/*.
1) Route: GET /api/v2/food/{id}
Section titled “1) Route: GET /api/v2/food/{id}”Object: food_service.FoodDTO
What is new in v2 vs v1:
serving_sizesis included (v1 does not return this field).serving_sizes[].typeuses these values:packageportionpinchtablespoonteaspoonsmall_wholemedium_wholelarge_wholesmall_piecemedium_piecelarge_piecesmall_slicemedium_slicelarge_slicesmall_bottlemedium_bottlelarge_bottlesmall_glassmedium_glasslarge_glasssmall_cupmedium_cuplarge_cupsmall_bowlmedium_bowllarge_bowlsmall_toemedium_toelarge_toe
- Legacy v1 fields are no longer part of the v2 contract:
quantity_valuequantity_unit
- Nutrients are represented as
Quantityobjects with labels:- Structure:
{ "label": string, "amount": number, "unit": string }
- Structure:
Additional nutrient fields in v2 (vs v1):
vaccenic_acidgondoic_acidrumenic_acidgamma_linolenic_aciddihomo_gamma_linolenic_acidnitrogenchromiummolybdenumretinol_activity_equivalentfolatefolate_naturalergocalciferolcholecalciferolbeta_tocopheroldelta_tocopherolgamma_tocopherolalpha_tocotrienolvitamin_Kmenaquinoneacetic_acidcitric_acidlactic_acidmalic_acidtartaric_acidoligosaccharidesfiber_high_molecular_weightfiber_insoluble_high_molecular_weightfiber_soluble_high_molecular_weightfiber_low_molecular_weightfatty_acids_othercarotenoids_ex_beta_carotene
2) Route: GET /api/v2/search
Section titled “2) Route: GET /api/v2/search”Object: ApiFoodSearchResponse with data[] as SearchFoodData
What is new in v2 vs v1:
serving_sizesis included for each result.serving_sizes[].typeuses the same serving key set as above.quantity_value/quantity_unit(v1 legacy fields) are not part of v2.processed_variants[]now includes:label(human-readable processing label)
processed_variants[].big7quantities include labels:- e.g.
energy.label,protein.label, etc.
- e.g.
3) Route: GET /api/v2/search/gtin
Section titled “3) Route: GET /api/v2/search/gtin”Object: ApiGtinSearchResponse with data as SearchFoodData
What is new in v2 vs v1:
- Same structural updates as
GET /api/v2/search:serving_sizesincludedserving_sizes[].typeuses the same serving key set as aboveprocessed_variants[].labelincluded- labels in
processed_variants[].big7.*.label - no
quantity_value/quantity_unit
4) Route: POST /api/v2/evaluate/nutrition-summary
Section titled “4) Route: POST /api/v2/evaluate/nutrition-summary”Object: Nutrition Summary
What is new in v2 vs v1:
- All quantity fields include labels (
label,amount,unit).
5) Route: POST /api/v2/evaluate/macro-distribution
Section titled “5) Route: POST /api/v2/evaluate/macro-distribution”Object: Macro Distribution
What is new in v2 vs v1:
breakdown[]now includes an additionallabelfield per macro component.
6) Route: POST /api/v2/evaluate/healthy-eating-index
Section titled “6) Route: POST /api/v2/evaluate/healthy-eating-index”Object: HEI Report
What is new in v2 vs v1:
components[]now includes an additionallabelfield.componentis constrained to a fixed set of values (enum behavior).
Current component values:
total_fruitswhole_fruitstotal_vegetablesgreens_and_beanswhole_grainsdairytotal_protein_foodsseafood_and_plant_proteinsrefined_grainsadded_sugarssaturated_fatsfatty_acidssodium
7) Route: POST /api/v2/evaluate/energy-density
Section titled “7) Route: POST /api/v2/evaluate/energy-density”Object: Energy Density Report
What is new in v2 vs v1:
sum_energy_liquidsnow includes an additionallabelfield.energy_density[]now includes an additionallabelfield per entry.
Integration notes
Section titled “Integration notes”- If you currently use
quantity_value/quantity_unitfrom v1, migrate in v2 to:serving_sizes[]for package/portion sizes,Quantityobjects (label,amount,unit) for nutrients.
- Expect additional fields in v2 responses (especially nutrients).
- If your deserialization is strict, update DTOs to handle additive fields.