Recipe - Food - Nutrition

FREEMIUM
Verified
By David | Updated לפני 22 ימים | Food
Popularity

9.9 / 10

Latency

518ms

Service Level

100%

Health Check

N/A

Back to All Discussions

How can we get the ID of an ingredient?

Rapid account: Scottnm
scottnm
vor 7 Jahren

To get data on an ingredient we need the ID, but I can’t see anyway to get the ID from an ingredient’s title

Rapid account: Reesebearden
reesebearden Commented vor 5 Jahren

Anyone have an update?

Rapid account: Kodiaksoul
kodiaksoul Commented vor 5 Jahren

This still has not been answered. What endpoint will give the food id?

Rapid account: Scottnm
scottnm Commented vor 7 Jahren

That looks like a good place to start! Thanks

Rapid account: Dmlcn 6
dmlcn6 Commented vor 7 Jahren

To do this you could search an ingredient name using the Autocomplete Ingredient Search endpoint. Check it out here @ <a href =“https://market.mashape.com/spoonacular/recipe-food-nutrition#autocomplete-ingredient-search”> https://market.mashape.com/spoonacular/recipe-food-nutrition#autocomplete-ingredient-search </a>

<b>For a Query Example:</b>
<a href=#>“https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/food/ingredients/autocomplete?metaInformation=true&number=2&query=beans”</a>

<b>Would return results:</b> <p></p>
<code>[<p></p>
{<p></p>
“name”: “beansprouts”,<p></p>
“image”: “bean-sprouts.jpg”,<p></p>
“id”: 11043,<p></p>
“aisle”: “Ethnic Foods”<p></p>
}, <p></p>
{<p></p>
“name”: “soybeans”,<p></p>
“image”: “soy-beans.jpg”,<p></p>
“id”: 16409,<p></p>
“aisle”: “Canned and Jarred”<p></p>
}<p></p>
] </code>

<p></p>
<p></p>
<p></p>

<b>UPDATE: </b><p></p>
Once you have an id name, make a request for nutritional values:
<a href=#>“https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/food/ingredients/16409/information?amount=100&unit=gram’”</a>

<b>Would Return Results: </b><p></p>
<code>{<p></p>
“id”: 16409,<p></p>
“name”: “soy beans”,<p></p>
“aisle”: “Canned and Jarred”,<p></p>
“image”: “soy-beans.jpg”,<p></p>
“amount”: 100,<p></p>
“unit”: “gram”,<p></p>
“nutrition”: {<p></p>
“nutrients”: [<p></p>
{<p></p>
“title”: “Calories”,<p></p>
“amount”: 173,<p></p>
“unit”: “cal”,<p></p>
“percentOfDailyNeeds”: 8.65<p></p>
},<p></p>
{<p></p>
“title”: “Fat”,<p></p>
“amount”: 8.97,<p></p>
“unit”: “g”,<p></p>
“percentOfDailyNeeds”: 13.8<p></p>
},<p></p>
{<p></p>
“title”: “Saturated Fat”,<p></p>
“amount”: 1.3,<p></p>
“unit”: “g”,<p></p>
“percentOfDailyNeeds”: 8.11<p></p>
},<p></p>
{<p></p>
“title”: “Carbohydrates”,<p></p>
“amount”: 9.93,<p></p>
“unit”: “g”,<p></p>
“percentOfDailyNeeds”: 3.31<p></p>
},… </code>

Rapid account: Scottnm
scottnm Commented vor 7 Jahren

I’m not using a specific endpoint right now. I’m looking for an endpoint so that I can get an ingredient id from an ingredient name and then use that is to get nutrition info about the ingredient

Rapid account: Dmlcn 6
dmlcn6 Commented vor 7 Jahren

<b>What data endpoint are you using?</b> Usually the ingredient Id is sent along with the name and image, and many other attributes. Depending on your language, should be as easy as grabbing the key from the data. Like so, <b><i>data[“extendedIngredients”]</i><b> and then parse each ingredient in the list.

Join in the discussion - add comment below:

Login / Signup to post new comments