Open micimize opened 3 years ago
one way to test this would be to run a strict json schema validator like ajv
against every endpoint for a handful of criterion
@micimize Thanks for bringing this to our attention. I confirmed the issue and have posted it to the team. Hopefully it will be fixed in our upcoming October update.
This is a huge issue; I also noticed this as I was getting "undefined" randomly with our integration when referencing foodPortions[i].amount
property. The data inconsistencies can be found using the specific examples below.
dataType and foodClass do not depict any indication of harmonious response in the data schematic returned.
foodPortions
property AND no servingSize
/ servingSizeUnit
[https://api.nal.usda.gov/fdc/v1/food/169814?api_key=KEY](https://api.nal.usda.gov/fdc/v1/food/169814?api_key=KEY)
{ dataType: 'SR Legacy', foodClass: 'finalFood' }
foodPortions
property BUT no servingSize
/ servingSizeUnit
[https://api.nal.usda.gov/fdc/v1/food/171353?api_key=KEY](https://api.nal.usda.gov/fdc/v1/food/171353?api_key=KEY)
{ dataType: 'SR Legacy', foodClass: 'finalFood' }
foodPortions
property BUT has servingSize
/ servingSizeUnit
[https://api.nal.usda.gov/fdc/v1/food/1497403?api_key=KEY](https://api.nal.usda.gov/fdc/v1/food/1497403?api_key=KEY)
{ dataType: 'Branded', foodClass: 'Branded' }
Without having the weight that the nutrients represents, the foodNutrients
data is useless as it cannot be converted / applied to our own Unit of Measure for our meals and recipes.
Moreover, I would prefer the /foods/search endpoint to return the serving size and serving size unit of measure. Otherwise, all of the nutrient data that comes back in the search response is useless because you don't know what weight/portion-size of the ingredient is being measured.
Either (A) take the nutrient data off the search response to save overhead of useless data, or (B) include the 2 critical points of data bringing the nutrient data into some sort of applicable context. Even if it worked as expected, developers would have to make an additional API call for each search result (👎 ).
I'm going to have to investigate other nutrition providers like Eamons and Fat Secret to see if I can get more reliable datasets.
The results of
/v1/foods/search
's nutrients havenutrient*
prefixes for some fields andvalue
instead ofamount
. I haven't found inconsistencies elsewhere, but have not looked thoroughly (although/v1/foods/list
looks alright)