DEV Community

Cover image for I Tested 8 Nutrition APIs With the Same Query. Only 2 Returned Correct Data.
Raviteja Nekkalapu
Raviteja Nekkalapu

Posted on

I Tested 8 Nutrition APIs With the Same Query. Only 2 Returned Correct Data.

Last week, I ran a simple experiment.

I sent the exact same query to 8 different nutrition APIs:

"100g skinless chicken breast"
Enter fullscreen mode Exit fullscreen mode

Then I compared their responses to the USDA FoodData Central database - the gold standard for nutrition data in the US.

The results were... concerning.

The Test Setup

Query: "100g skinless chicken breast"
Reference: USDA FoodData Central (ID: 331960)

Expected Values (USDA Benchmark)

Nutrient USDA Value
Energy 165 kcal
Protein 31.02 g
Total Fat 3.57 g
Saturated Fat 1.01 g
Cholesterol 85 mg

The Results

API Calories Protein Fat Accuracy
API A 165 31g 3.6g
API B 239 27.3g 13.6g
API C 165 31g 3.6g
API D 195 29.5g 7.7g
API E 172 26g 6.8g
API F 148 31.5g 1.2g
API G 165 30.9g 3.8g ⚠️
Nutrition Tracker API 165 31.02g 3.57g

Only 3 out of 8 APIs returned accurate data. And one of those (API G) had slight rounding discrepancies.

Where Did the Wrong Data Come From?

I investigated further. The inaccurate APIs fell into three categories:

1. Using Community-Contributed Data

Several APIs rely on user-submitted data that's never validated. Someone enters "chicken breast" with skin, bones, or cooked with oil - and that becomes the "chicken breast" entry.

2. Outdated USDA Data

One API was still using 2015 USDA data. The USDA updates their database regularly. Old data means old values.

3. Mixing Food Variants

"Chicken breast" can mean:

  • Raw vs cooked
  • With skin vs skinless
  • Bone-in vs boneless
  • Grilled vs fried vs baked

Some APIs return the wrong variant entirely.

Why Data Accuracy Actually Matters

You might think "what's 50 calories among friends?"

But consider:

For a diet tracking app:

  • User tracks 4 meals/day
  • Each meal is off by 50 kcal
  • That's 200 kcal/day error
  • 1,400 kcal/week - almost half a pound difference

For a medical nutrition app:

  • Patient needs exactly 1.2g protein/kg body weight
  • API says 27g when it's actually 31g
  • Doctor's recommendations are now wrong
  • Potential health consequences

For food manufacturers:

  • Nutrition labels have legal requirements
  • Wrong data = FDA compliance issues
  • Legal liability

This isn't pedantry. It's professional responsibility.

How Nutrition Tracker API Gets It Right

1. USDA as Single Source of Truth

Every food item traces directly to USDA FoodData Central. No ambiguity.

{
  "data": {
    "fdcId": 331960,
    "description": "Chicken, breast, meat only, raw"
  }
}
Enter fullscreen mode Exit fullscreen mode

2. Specific Food Matching

When you search "chicken breast," I don't guess. The NLP parser identifies:

  • Base food (chicken breast)
  • Cooking method (if specified)
  • Portion/quantity (100g, 1 cup, etc.)

And returns the exact USDA match.

3. Fat Breakdown That Actually Adds Up

Remember the fat problem from my previous post?

{
  "Fat": {
    "value": 3.57,
    "unit": "g",
    "breakdown": {
      "saturated": { "value": 1.01, "unit": "g" },
      "monounsaturated": { "value": 1.24, "unit": "g" },
      "polyunsaturated": { "value": 0.77, "unit": "g" },
      "trans": { "value": 0.02, "unit": "g" },
      "other": { "value": 0.53, "unit": "g", "note": "Includes phospholipids and minor fatty acids" }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

1.01 + 1.24 + 0.77 + 0.02 + 0.53 = 3.57 ✓

The math works.

4. Transparent Data Lineage

Every response includes the USDA FDC ID. You can verify against the source yourself. No black boxes.

Run Your Own Test

Don't take my word for it. Try this:

  1. Pick a food you know well
  2. Send the same query to multiple APIs
  3. Compare to USDA FoodData Central
  4. Count discrepancies

I'll bet you find the same patterns I did.

The Accuracy Guarantee

Here's what I promise:

  • ✅ Every nutrient value traces to USDA FoodData Central
  • ✅ Fat breakdowns sum to total (not close - exactly)
  • ✅ Regular syncs with latest USDA data
  • ✅ FDC IDs included for verification

If you find a discrepancy, open an issue. I'll fix it or explain why the USDA value differs from expectations.

Quick Comparison

# Test it yourself
curl -X POST "https://nutrition-tracker-api.p.rapidapi.com/v1/calculate/natural" \
  -H "X-RapidAPI-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "100g chicken breast"}'
Enter fullscreen mode Exit fullscreen mode

Compare the response to USDA FDC. Every. Single. Value.


Links:

Found a data discrepancy in your current nutrition API? I'd love to hear about it in the comments.


This is part of a series about building the Nutrition Tracker API with a focus on data accuracy and developer experience.

Top comments (0)