Choosing a Nutrition Database for Your App: USDA, Open Food Facts, and the Problems None of Them Solve

By the TastyAPI team · November 24, 2026 · 12 min read

You have a food name: from a search box, a barcode, a photo, or a line in a recipe. Now you need calories, macros, maybe micronutrients and allergens. It looks like a lookup table. It isn't.

Nutrition data comes from different databases built for different purposes. They report in different units under different national rules, and they treat missing values in different ways. This guide covers the problems teams hit most often, why each one is hard, and what to do about it. It points to free public resources wherever they're the right answer.

1 · Sources

Choosing a nutrition database: USDA, Open Food Facts, or a commercial API

Why it's hard. There is no single "nutrition database". Every source is a trade-off between coverage, accuracy and licensing.

  • USDA FoodData Central (the "USDA food database", formerly the National Nutrient Database) is the reference most people start with. It's free and public domain, with an API key from api.data.gov. It isn't one database but several with different purposes: Foundation Foods (lab-analysed, few items, very detailed), SR Legacy (the classic reference set, no longer updated), FNDDS (foods as Americans report eating them, built for dietary surveys), and Branded Foods (manufacturer label data, huge, only as good as the label).
  • Open Food Facts is a crowd-sourced, open database of packaged products from many countries, searchable by barcode. Coverage outside the US is excellent; quality varies by entry. The data is under the ODbL licence, which has share-alike terms you should read before shipping.
  • Commercial databases (Nutritionix, Edamam, FatSecret and others) add restaurant menus, curated branded data, natural-language parsing and support, under paid licences with usage terms.
  • National databases (UK CoFID, Canada's CNF, Australia's AUSNUT and others) matter if your users eat local foods that US data doesn't cover well.

What to do. Decide what your users actually log. Mostly packaged goods: barcode plus a branded database. Mostly home cooking: a reference database like FDC Foundation/SR Legacy plus a recipe calculator. Mostly restaurants or mixed plates: you need either a menu database or an estimation layer, and this is where APIs like ours (or the commercial ones above) earn their cost. Many production apps use two or three sources with a clear priority order.

2 · Matching

"Chicken breast" returns 200 results

Why it's hard. Raw, roasted, grilled, skin-on, skinless, breaded, branded, and "chicken breast, rotisserie, store-bought": a text search returns dozens of entries, with calories that differ by 50% or more. Users pick the first one. The worst mix-up is between raw and cooked entries: dry pasta is about 370 kcal per 100 g, cooked pasta about 150. Pick the wrong one and your result is off by a factor of two to three.

What to do

  • Rank results by state (cooked vs raw) and by how people usually log the food, not only by how well the text matches.
  • Show the preparation state in the search result. "Rice, white, cooked" and "Rice, white, raw" should never look alike.
  • Store the source ID of the entry the user picked, so you can audit and fix bad matches later.
3 · Units

"1 cup" is not a weight

Why it's hard. Databases store nutrients per 100 g. People log in cups, slices, pieces, handfuls, "a bowl". Converting needs a density or a standard portion weight for each food. A cup of flour is about 120 g spooned and 150 g packed. A cup of chopped kale weighs a fraction of a cup of cooked kale. "1 medium banana" depends on whose definition of medium.

What to do

  • Use the portion tables that come with reference databases. FoodData Central includes gram weights for common household measures per food. Never use one generic cup-to-gram factor.
  • Keep the user's original unit and the grams you converted to. If you change a conversion later, you can recompute history.
  • For liquids, don't assume 1 ml = 1 g for everything: oils, syrups and milk all differ.
4 · Labels

Are nutrition labels accurate? Rounding, tolerances, and why calories from macros never match

Why it's hard. Developers often add a check that calculates calories from macros with the Atwater factors (protein × 4 + carbs × 4 + fat × 9) and expects the result to equal the label. They're surprised when real labels fail it. They're supposed to. In the US, label values follow FDA rounding rules (21 CFR 101.9). Calories under 5 are declared as 0, up to 50 are rounded to the nearest 5, and above 50 to the nearest 10. Fat under 0.5 g can be listed as 0 g. Manufacturers may also use any of several approved methods to calculate calories, including ones that subtract insoluble fibre.

Labels also have legal tolerances. For nutrients like calories, sugars, fat and sodium, the real value can be up to 20% above the label before it's out of compliance. For protein, fibre, vitamins and minerals, it must be at least 80% of what's declared. A label is a legal declaration within a tolerance, not a lab measurement.

What to do

  • Never "fix" a printed label by recomputing it from macros. Store what's printed, and compute derived values separately if you need them.
  • Use the Atwater sum as a sanity check with a tolerance (roughly ±15–20%) to catch bad data, not as a validator that demands an exact match.
  • Remember that "0 g trans fat" can mean up to 0.49 g per serving. If a user eats five servings, that adds up. Show this if your app tracks trans fat.

If you need to produce a compliant panel rather than read one, our free nutrition label generator applies these rounding rules for you.

5 · Alcohol

Calories in alcohol: 7 per gram, and the macro everyone forgets

Why it's hard. Alcohol (ethanol) has about 7 kcal per gram and isn't protein, carbohydrate or fat. A calorie calculation using only 4/4/9 gives a 150 ml glass of wine about 16 kcal. The real figure is around 120 kcal, nearly all of it from roughly 14 g of ethanol.

What to do. Track alcohol in grams as its own nutrient and include it in energy as 7 kcal/g. If you're adding it to an existing API response, make the field conditional (present only when greater than zero). That way responses for every other food keep their current shape and existing clients don't break.

6 · Regions

US and EU labels measure different things under the same names

Why it's hard. If your app serves more than one market, identical field names hide different definitions:

United StatesEuropean Union / UK
Energykcal ("Calories")kJ and kcal
"Carbohydrate"Total carbohydrate, includes fibreExcludes fibre
Fibre energyVaries by calculation method2 kcal/g
SodiumDeclared as sodium (mg)Declared as salt (g) ≈ sodium × 2.5
Reference basisPer serving (with "servings per container")Per 100 g / 100 ml mandatory; per portion optional
Major allergens9, sesame added in 202314 (EU Regulation 1169/2011)

Mix a US and an EU entry in one daily total and the carbohydrate number is wrong in a way no user will notice, which is especially bad for anyone counting carbs for diabetes.

What to do. Store values in one canonical internal format (for example: grams per 100 g, total carbohydrate including fibre, sodium in mg). Record which region each source comes from, and convert on the way in, not on display. "Net carbs" has no FDA definition, so if you show it, define your formula on screen.

7 · Missing data

Missing is not zero

Why it's hard. Branded and label-derived data contain only what the label must show. Since the 2020 US label update, that's vitamin D, calcium, iron and potassium, plus the macros. Vitamin C, magnesium and zinc are usually just absent. If your code treats absent as 0, a user eating oranges all day will see a vitamin C deficiency.

What to do

  • Use null for "unknown" and 0 for "measured as zero" throughout your schema, API and UI.
  • When adding up a day's nutrients, track how much of the total is backed by real data. Show "vitamin C: at least 45 mg (data available for 60% of foods logged)", not a false deficit.
  • Fill micronutrient gaps from a reference entry for the same generic food when you can, and label the value as estimated.
8 · Allergens

Allergens and dietary flags carry the most liability

Why it's hard. Allergen lists differ by country (see the table above). "May contain" warnings are voluntary in most markets, so their absence tells you nothing. A dish name never fully reveals its ingredients: pesto can contain nuts, and a curry may be thickened with wheat. A photo or name based system can only infer allergens, and a false "nut-free" is far worse than a false "contains nuts".

What to do

  • Treat any allergen output from estimation (photo, dish name, model) as a warning, never as a guarantee, and say so in the UI.
  • Make the logic asymmetric: when unsure, flag the allergen.
  • Check consistency: if the ingredient list contains butter, the allergens must include milk and the dietary flags can't say vegan. Contradictions like these are cheap to detect automatically, and they tell you an answer is unreliable.
9 · Regulation

When a nutrition app becomes a medical app

Why it's hard. The same calorie estimate means different things in different products. In a fitness tracker it's a wellness feature. In software that recommends an insulin dose from a meal's carbohydrates, it's input to a medical decision, and dose calculators are regulated as medical devices in the US and EU. At a typical insulin-to-carb ratio of 1:10, a 20 g carb error is 2 units of insulin. That's why clinical products carry a much heavier regulatory burden.

Privacy rules change too. In the US, HIPAA applies when you work with or on behalf of healthcare providers and insurers. A direct-to-consumer diet app usually falls under the FTC's Health Breach Notification Rule instead, which the FTC updated in 2024 to cover health apps explicitly. In the EU, health data is a "special category" under GDPR Article 9 and needs an explicit legal basis. Food photos and meal logs can count as health data when they're linked to a condition.

What to do (general orientation, not legal advice)

  • Decide early whether you're a wellness product or a clinical one, and design to that line. FDA guidance on general wellness products and on clinical decision support software are the right starting points in the US.
  • Keep estimated values visibly separate from measured ones, especially carbohydrate.
  • When you choose a data or AI vendor, ask for their data processing agreement, retention terms and subprocessor list before you integrate, not after.
Checklist

Putting it together

  1. One canonical internal schema: grams per 100 g, explicit region, explicit raw/cooked state.
  2. null for unknown, 0 for zero, everywhere.
  3. Printed label values are stored as printed and never recomputed.
  4. Alcohol tracked as its own nutrient.
  5. Atwater consistency check with a tolerance as a data-quality alarm.
  6. Allergen logic that flags when unsure.
  7. Source ID and database version stored for every logged item.
  8. A written decision on whether you're wellness or clinical.

You can build all of this on free public data. USDA FoodData Central and Open Food Facts are excellent foundations, and for packaged food in particular you may not need anything else. An API like our nutrition API earns its place when users log meals rather than products: restaurant plates, home cooking, photos and free text. Then the hard part is turning something unstructured into numbers you can defend.

Frequently asked

Are nutrition labels accurate?

Labels are legal declarations within a tolerance, not lab measurements. Under US FDA rules, calories, sugars, fat and sodium can be up to 20% above the declared value, and protein, fibre, vitamins and minerals must be at least 80% of it. Values are also rounded, so calories calculated from the printed macros rarely match exactly.

How many calories are in a gram of alcohol?

About 7 kcal per gram of ethanol. Alcohol is not protein, carbohydrate or fat, so a calorie calculation that only uses 4/4/9 badly undercounts drinks: a 150 ml glass of wine is around 120 kcal, nearly all of it from roughly 14 g of ethanol.

What is the best free nutrition database for developers?

For generic foods, USDA FoodData Central is free, public domain and lab-referenced. For packaged products worldwide, Open Food Facts is free and searchable by barcode under the ODbL licence. Many production apps combine both, plus a commercial or estimation API for restaurant meals and photos.

Food photo or text in, structured nutrition out

If you'd rather not build the estimation layer yourself, TastyAPI returns calories, macros, vitamins, allergens and dietary flags in about a second. 7-day free trial on every plan.

Get an API key