Open manijcgvak opened 4 years ago
@manijcgvak There is not a way to directly filter/search based on nutrients in the FDC API. You can request only specific nutrients when getting food details from the "food" (https://fdc.nal.usda.gov/api-spec/fdc_api.html#/FDC/getFood) or "foods" (https://fdc.nal.usda.gov/api-spec/fdc_api.html#/FDC/getFoods) endpoint. The workaround I would suggest is to use the "list" endpoint to get foods and then use the "foods" endpoint to filter for the nutrients you want. We will discuss with FDC program about possibly adding a nutrient search.
Is there any possibility for search by nutrient?
In old API
http://api.nal.usda.gov/ndb/nutrients?offset=0&max=50&nutrients=208
{ "report": { "sr": "1", "groups": "All groups", "subset": "All foods", "end": 1, "start": 0, "total": 7524, "foods": [ { "ndbno": "09427", "name": "Abiyuch, raw", "weight": 114, "measure": "0.5 cup", "nutrients": [ { "nutrient_id": "208", "nutrient": "Energy", "unit": "kcal", "value": "79", "gm": 69 } ] } ] } }
what is the alternative API to search ingredient based on nutrients?
And one more need, In case if the nutrient number is wrong in old API we get as
{ "errors": { "error": [ { "status": 400, "parameter": "nutrients", "message": "Invalid nutrient values. Please insure all nutrient parameters are valid nutrient numbers" } ] } }
But now we get the ingredients based on fdcId in Food Details endpoint, Is it possible to filter based on the nutrient in search end point and what is the alternative solution to get the ingredient only if the specified nutrient is available as used in the old API?