Recipe - Food - Nutrition

FREEMIUM
Verified
By David | Updated 14 days ago | Food
Popularity

9.9 / 10

Latency

487ms

Service Level

100%

Health Check

N/A

Back to All Discussions

fillIngredients doesn't include information about used ingredients

Rapid account: Juji 555
juji555
8 years ago

In the docs for Complex Recipe Search, it says <code>fillIngredients</code> should return “information about the used and missing ingredients in each recipe.” However, in the example given, when I change <code>fillIngredients</code> to true and then test endpoint, I see extra information about the missing ingredients, but not the used ingredients.

I would like to get a list of all the used ingredients in the recipe, just like the information supplied in <code>missedIngredients</code>. My end goal is if I enter a Complex Recipe Search for “onions, lettuce, tomato” and the recipes returned only use one of those ingredients, I want to be able to tell which ingredient I entered was the one that was used and which ingredients I entered that were not used. Is that possible?

Rapid account: Spoonacular
spoonacular Commented 8 years ago

Yes, that is only for computing nutrition. So if you say “salt” we assume 1 serving (couple of grams) to compute nutrition. For your use case that is irrelevant and you can leave it out safely.

Rapid account: Juji 555
juji555 Commented 8 years ago

Thanks for adding that! I noticed when I don’t provide <code>servings</code> it still works, even though it’ s marked as required. I don’t want to have to send servings though – is it safe to leave this out?

Rapid account: Spoonacular
spoonacular Commented 8 years ago

I see. I now added another method that can help you: https://market.mashape.com/spoonacular/recipe-food-nutrition#parse-ingredients

My suggestion would be to parse your input ingredients once “onions, lettuce, tomato” with the parse endpoint. That’ll give you ids for your input ingredients. You then do the same for the ingredients in usedIngredients and you get ids too. It does not matter whether your input says “strawberry” and usedIngredient calls it “strawberries” as you will get the same id back. This way - granted, not super convenient - you can match your input to the output.

Let me know whether that helps 😉

Best,
David

Rapid account: Juji 555
juji555 Commented 8 years ago

Wow, thanks for adding that so quickly! The problem I have with the way the <code>usedIngredients</code> are now, is that they don’t quite match the ingredients that were entered in the first place.

Using the “onions, lettuce, tomato” example again from the documentation, the <code>usedIngredients</code> that come back in the first recipe result are “iceberg lettuce, onions, and tomato.” I need/would expect the used ingredients to match the original ingredients, “lettuce, onions, and tomato.” Otherwise, how can I tell if the used ingredients is a match for what I entered in in the first place?

In the above example, I could look for a substring match of anything that had “lettuce” in the name, but I’ve noticed other cases like, “strawberry” in the entered ingredients coming back as “strawberries” in the used ingredients that would be almost impossible to compare programmatically, unless I have a lookup table for all possible ingredient synonyms.

Let me know if you need more information! My end goal is: I want to be able to tell which ingredients I entered were the ones that were used in the chosen recipe.

Rapid account: Spoonacular
spoonacular Commented 8 years ago

Hi, I added a more detailed usedIngredients array in the response. Let me know if that helps you 😃

Best,
David

Join in the discussion - add comment below:

Login / Signup to post new comments