Recipe - Food - Nutrition

FREEMIUM
Verified
By David | Updated vor 9 Tagen | Food
Popularity

9.9 / 10

Latency

488ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Ingredient Amounts Search and Conversion

Rapid account: Juji 555
juji555
vor 7 Jahren
  1. I’d like to be able to search by ingredient including amount and unit. That way I if I have 2 tomatoes I can search for a recipe that requires 2 tomatoes (or less), and not be shown recipes in the results that require 4 tomatoes. Are there any plans to add amount and unit as a search parameter to the Complex Recipe Search endpoint?

  2. From what I can tell, in the current data, if you are dealing with an ingredient that is a whole piece of fruit or vegetable, the unit is left blank, like in the below example:

 "id": 11529,
          "amount": 2,
          "unit": "",
          "unitLong": "",
          "unitShort": "",
          "aisle": "Produce",
          "name": "tomatoes",
          "originalString": "2 medium tomatoes, thinly sliced",

That’s a problem for me, because I’m interested in converting whole pieces of fruit to other units of measure. For example, if a recipe calls for 1 cup chopped tomatoes, and I have 2 tomatoes, is that enough? I realize that produce varies in size, but an average medium-sized tomato weighs 5-6 ounces. You could probably make a general assumption about the weight of many common fruits and vegetables. I experimented with the Convert Amounts endpoint to see if this feature already existed, however, when I enter 2 tomatoes but leave the sourceUnit off in order to convert 2 whole tomatoes to ounces, I get an error message. Are there any plans to deal with whole (or half) pieces of produce in the Convert Amounts endpoint? Maybe there could be a generic “unit” unit of measure that you are estimating the size of behind the scenes.

Rapid account: Juji 555
juji555 Commented vor 7 Jahren

Awesome, I just sent an email to that address. Let me know if you do not get it.

Rapid account: Spoonacular
spoonacular Commented vor 7 Jahren

Hey Juji, I’d also much rather switch to email, you can reach me under my first name at spoonacular.com. My first name is David 😃

Best,
David

Rapid account: Juji 555
juji555 Commented vor 7 Jahren

Ah, I understand now. I originally thought that you updated the calls from your documentation site to be lowercase as well as the documentation text.

All of the bugs you fixed work great for me now. Thank you.

I actually want to talk with you about some of the specifics of my app and how I plan to be utilizing spoonacular in the future, however, I have an important question first. How do I email you privately to discuss specific projected usage numbers about my app? When I create a new ticket in mashape, there is a drop down with the lock option: “Private — this issue will be visible by you and the API provider.” I chose that for this ticket, for example. However, when I am looking through all the support tickets for your API, I see many with locks on them that I can click and read. So my confidence is low that my tickets with locks on them are private. Is this something I should take up directly with mashape?

Rapid account: Spoonacular
spoonacular Commented vor 7 Jahren

Hi Juji,

That you get 400er is due to the mashape bug I mentioned in my last comment: “Due to a mashape bug the parameters are now all lowercase instead of camelcase (ingredientname instead of ingredientName). I already told support, if you call the endpoint make sure to use camel case “targetUnit” not “targetunit” as it is currently written in the documentation.”

They are informed and should fix it soon.

Looking forward to seeing your app 😃

Best,
David

Rapid account: Juji 555
juji555 Commented vor 7 Jahren

I went to test these changes just now, but I get a 400 error for everything I do on this endpoint now through Mashape’s documentation site, including a regular old 2.5 cups of flour to grams conversion, which used to work previously:

 {
  "status": "failure",
  "code": 400,
  "message": "Ingredient name and target unit must be given."
}

Can you take a look? Thanks.

As far as my app, I’m close to having something demo-worthy. I will let you know when it’s ready for people to look at!

Rapid account: Spoonacular
spoonacular Commented vor 7 Jahren

Hi Juji,

I know fixed the following:

  • you can convert back to pieces by putting “piece” as targetUnit, e.g. 4.34 ounces tomato to pieces is 1 piece (1 tomato)
  • “Whole items to cups does not work properly, the result is much less targetAmount than it should be.” => fixed
  • “Answer sometimes says “pb” instead of the ingredientName entered. When I try to convert 2 tomatoes to cups, I see “2 pb cups” in the answer area, which is strange” => fixed
  • “Servings appears to be treated the same as a whole/blank unit.” => that is fixed too. For some ingredients we do not know the weight per piece and serving yet. If you run into those, please let me know and I’ll look into improving our db on those occasions.

Due to a mashape bug the parameters are now all lowercase instead of camelcase (ingredientname instead of ingredientName). I already told support, if you call the endpoint make sure to use camel case “targetUnit” not “targetunit” as it is currently written in the documentation.

Also, i’d be curious to see what you’re working on. If you have something public, just let me know and we can feature your app/site in our newsletter to over 500 people!

Best,
David

Rapid account: Juji 555
juji555 Commented vor 7 Jahren

That sounds great, thanks so much for taking a look at it!

As for the other items, those aren’t feature requests, just bugs that I noticed in the current conversion endpoint. Sorry, if they came across as a bunch more feature requests, I don’t mean to overwhelm you. I think the conversion endpoint is going to be immensely helpful, I just want it to be as accurate as possible for my app!

Thanks again for all your hard work 😃

Rapid account: Spoonacular
spoonacular Commented vor 7 Jahren

Hi Juji, I’m currently working on another feature and your request list just got longer. I guess ETA would be end of the week / Sunday. I keep you posted.

Rapid account: Juji 555
juji555 Commented vor 7 Jahren

Great — do you have an ETA for when that would be available? Being able to convert from a specific unit of measurement back to whole is very important for my app.

As I play around with the conversions, I’m noticing some other issues as well.

#1 Whole items to cups does not work properly, the result is much less targetAmount than it should be.
Here is one example using a tomato, but I am seeing it for all ingredients:

{
  "sourceAmount": 1,
  "sourceUnit": "",
  "targetAmount": 0.006711409395973154,
  "targetUnit": "cups",
  "answer": "1 tomato are 0.01 cups.",
  "type": "CONVERSION"
}

#2 Answer sometimes says “pb” instead of the ingredientName entered.
When I try to convert 2 tomatoes to cups, I see “2 pb cups” in the answer area, which is strange:

{
  "sourceAmount": 2,
  "sourceUnit": "",
  "targetAmount": 0.044444444444444446,
  "targetUnit": "cups",
  "answer": "2 pb cups translates to 0.04 cups.",
  "type": "CONVERSION"
}

#3 Servings appears to be treated the same as a whole/blank unit.
Here’s an example of that:

{
  "sourceAmount": 1,
  "sourceUnit": "",
  "targetAmount": 158.73282891309026,
  "targetUnit": "ounces",
  "answer": "1 watermelon translates to 158.73 ounces.",
  "type": "CONVERSION"
}

I typed the following in the Convert Amounts endpoint documentation to get this result:
ingredientName: watermelon
sourceAmount: 1
sourceUnit: servings
targetUnit: ounces

But in the results, it changed sourceUnit from “servings” to blank. So the result, based on the data I entered, is saying a serving is 158.73 ounces, but that is actually the amount of one whole watermelon. This seems to suggest you don’t support “serving” as a unit of measure. However, the reason I have the unit of “servings” to begin with, is because it was returned from the API using the Parse Ingredients endpoint.

If I enter into the Parse Ingredients endpoint:
ingredientList: pork shoulder
servings: 2

Here’s what I get back:

{
    "id": 10072,
    "original": "pork shoulder",
    "name": "pork shoulder",
    "amount": 2,
    "unitShort": "servings",
    "unitLong": "servings",
    "aisle": "Meat",
    "image": "https://spoonacular.com/cdn/ingredients_100x100/pork-shoulder.jpg",
    "meta": []
  }

Since servings is returned as a unit in other parts of the API, I would expect that it is a unit type that can also be converted.

Rapid account: Spoonacular
spoonacular Commented vor 7 Jahren

Hey Juji,

Sorry for the late response. I see your use case, this is currently not possible but I will work on that soon and update you!

Join in the discussion - add comment below:

Login / Signup to post new comments