Sign in | Sign up

/search/instant and /natural/nutrients do not match

Tagged:

Currently contains 6 posts

Avatar

January 11, 2020 03:26

rmelick-vida

We are trying to use the autocomplete /search/instant api, but finding that it does not match with the /natural/nutrients api used to get the full information.

As described in the documentation (https://docs.google.com/document/d/1_q-K-ObMTZvO0qUEAxROrN3bwMujwAN25sLHwJzliK0/edit#heading=h.h3vlpu5rgxy0), I first do a GET request to the search/instant api with the text query

curl -H ‘X-APP-ID:XXX’ -H ‘X-APP-KEY:XXX’ ‘https://trackapi.nutritionix.com/v2/search/instant?query=popcorn’

The first object returned in the “common” section has a serving_unit of “bag”

{
“food_name”: “popcorn”,
“serving_unit”: “bag”,
“tag_name”: “popcorn”,
“serving_qty”: 1,
“common_type”: 2,
“tag_id”: “10071”,
“photo”: {
“thumb”: “https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png”,
“highres”: null,
“is_user_uploaded”: false
},
“locale”: “en_US”
}

If I then make a request to the /natural/nutrients api, using the food_name

curl -H ‘X-APP-ID:XXX’ -H ‘X-APP-KEY:XXX’ -H ‘Content-Type: application/json’ ‘https://trackapi.nutritionix.com/v2/natural/nutrients’ -d ‘{"query": "popcorn"}’

the returned food has a different serving_unit, serving_qty, and photo.

{
“food_name”: “popcorn”,
“brand_name”: null,
“serving_qty”: 2,
“serving_unit”: “tbsp unpopped”,
“serving_weight_grams”: 26,
“nf_calories”: 130,
“nf_total_fat”: 8,
“nf_saturated_fat”: 4,
“nf_cholesterol”: 0,
“nf_sodium”: 270,
“nf_total_carbohydrate”: 13,
“nf_dietary_fiber”: 2,
“nf_sugars”: 0,
“nf_protein”: 2,
“nf_potassium”: null,
“nf_p”: null,
“full_nutrients”: [
{
“attr_id”: 203,
“value”: 2
},

],
“nix_brand_name”: “Pop-Secret”,
“nix_brand_id”: “51db37ef176fe9790a89a918”,
“nix_item_name”: “Premium Popcorn”,
“nix_item_id”: “582ea9978b386f702fb47cad”,
“upc”: null,
“consumed_at”: “2020-01-11T03:04:24+00:00”,
“metadata”: {
“is_raw_food”: false
},
“source”: 1,
“ndb_no”: 25014,
“tags”: {
“item”: “popcorn”,
“measure”: null,
“quantity”: “2.0”,
“food_group”: null,
“tag_id”: 10071
},
“alt_measures”: [
{
“serving_weight”: 7.9,
“measure”: “cup”,
“seq”: 1,
“qty”: 1
}
],
“lat”: null,
“lng”: null,
“meal_type”: 5,
“photo”: {
“thumb”: “https://d1r9wva3zcpswd.cloudfront.net/582ea9b779e2ac3c3aced7d6.jpeg”,
“is_user_uploaded”: false,
“highres”: null
},
“sub_recipe”: null
}

How can I make a query that gets me the full nutrient and other information, where the servings also match. Or at least, the original serving_unit was in the alt_measures of the object returned from /natural/nutrients

Avatar

January 14, 2020 19:59

julia

There seems to be a mapping issue with popcorn that we are looking into and it should be resolved within the next day. Please let me know if you have any other issues.

Avatar

January 14, 2020 20:29

Vida

Hi Julia, I think it applies to other items as well, not just popcorn. For example, eggback has the same problem. Is there a way for you to check all items?

Avatar

January 14, 2020 21:18

julia

I am going to notify the data quality team regarding these two examples.

Avatar

January 15, 2020 06:53

Vida

Thanks Julia. I think misspelled in the last post, it should have been “eggbake”. I also found another one this evening: “avocado”.

Avatar

January 21, 2020 18:28

Greg-Vida

Our testing discovered more common items that return branded items on /natural/nutrients. It seems like the API is ignoring the `branded` flag parameter on the query? The latest examples we’ve seen are “Coke” and “Sprite”; although I’m not sure why those have “common” entries to begin with.

Reply to thread