Update: USDA Ingredients Endpoints & USDA Sync


#1

Our old USDA sync was getting a little out of date and since it was based originally on the bulk export we made to serve our Nutribu app, was also incomplete.

So we decided to overhaul the /ingredients endpoint and in particular, setup a new, frequent and complete database sync with the USDA.

It’s now live and you can give it a try.

Make a GET request to the Nuwe Nutrition endpoint for usda_ingredients like this:

# Application ID & Secret auth method
curl "https://api.nuapi.co/v3/usda_ingredients.json" \
  -H "Content-Type: application/json" \
  -H "Authorization: application_id 7050fa3cc27a056697263ec0221492a1a044ab, client_secret 1fdd7d268039eb5c0c622b3a382c80" \

And you’ll get a response, like this:

REMEMBER: Amounts are representative of 1g of the item - this may differ from USDA defaults (100g often).

{"usda_ingredients":
  [{
    "id":2047,
    "name":"CEREALS,FARINA,ENR,ASSORTED BRANDS,QUICK,CKD W/ H2O,WO/ SALT",
    "summary":
      {
        "protein": "0.0182",
        "carbs": "0.109044",
        "kcal": "0.55",
        "fibre": "0.008",
        "fat_s": "0.00066",
        "fat_u": "0.00164",
        "salt": "0.00044999999999999993",
        "sugar": "0.0076"
      },
    "detailed":
      {
        "proximates":
          {
            "water":"86.55",
            "energy":"55.0",
            "sugars":"0.76",
            "protein":"1.82",
            "total_lipid":"0.34",
            "total_dietary_fibre":"0.8",
            "carbohydrate_by_difference":"10.92"
          },
        "minerals":
          {
            "iron":"5.33",
            "zinc":"0.23",
            "sodium":"18.0",
            "calcium":"97.0",
            "magnesium":"7.0",
            "potassium":"23.0",
            "phosphorus":"37.0"
          },
        "vitamins":
          {
            "thiamin":"0.126",
            "vitamin_d":"",
            "vitamin_k":"0.0",
            "folate_dfe":"119.0",
            "riboflavin":"0.065",
            "vitamin_b6":"0.096",
            "vitamin_b12":"0.0",
            "vitamin_a_iu":"0.0",
            "vitamin_a_rae":"0.0",
            "vitamin_e_alpha_tocopheral":"0.04",
            "vitamin_c_total_ascorbic_acid":"0.0"
          },
        "lipids":
          {
            "cholesterol":"0.0",
            "fatty_acids_total_saturated":"0.066",
            "fatty_acids_total_monounsaturated":"0.038",
            "fatty_acids_total_polyunsaturated":"0.126"
          },
        "other":
          {
            "caffeine":""
          },
        "portions":
          {
            "1.0 cup":"240.0",
            "0.75 cup":"179.0",
            "1.0 tbsp":"14.9"
          }
      }
  }]
}

Previously, the endpoint returned a limited number of possible attributes, which were an opinionated summary of the USDA ingredients that Nuwe uses to serve our NUScore algorithm.

There’s some key differences between this data and the USDA raw data, I’ll explain those in a moment, but this new endpoint now contains both the summary: and the detailed: data straight from the USDA.

You are free to choose what you’d like. But so you can do so with the knowledge of how they differ, here’s a summary of how Nuwe, in conjunction with Nutritionists, modified the fields for the summary: data.

| Protein         | USDA Protein / 100                                      |
| Carbohydrates   | (USDA Carbohydrate by Difference - Sugar - Fibre) / 100 |
| Sugars          | USDA Sugar Total / 100                                  |
| Fat Unsaturated | (USDA Fatty Acids, total monounsaturated + USDA Fatty acids, total polyunsaturated) / 100 |
| Fat Saturated   | USDA Fatty Acids, total saturated / 100                 |
| Fibre           | USDA Fibre / 100                                        |
| Salt            | ((USDA Sodium / 1000) * 0.4) / 100)                     |
| Calories        | USDA Energy / 100                                       |