Recipe - Food - Nutrition

フリーミアム
Verified
よって David | 更新済み 22 days ago | Food
人気

9.9 / 10

レイテンシー

518ms

サービスレベル

100%

Health Check

N/A

すべてのディスカッションに戻る

How can we get the ID of an ingredient?

Rapid account: Scottnm
scottnm
7 years ago

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 5 years ago

Anyone have an update?

Rapid account: Kodiaksoul
kodiaksoul Commented 5 years ago

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

Rapid account: Scottnm
scottnm Commented 7 years ago

That looks like a good place to start! Thanks

Rapid account: Dmlcn 6
dmlcn6 Commented 7 years ago

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 7 years ago

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 7 years ago

<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.

ディスカッションに参加しましょう-以下にコメントを追加してください:

ログイン/サインアップして新しいコメントを投稿