Recipe - Food - Nutrition

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

9.9 / 10

Latency

487ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Is this custom API endpoint possible?

Rapid account: Juji 555
juji555
8 years ago

I’m interested in bumping my plan up from the $27 a month Pro plan to the $99 a month Ultra plan. Before I switch, I’d like to find out if the on-demand endpoint I need would be doable, and how long it would take for you to complete.

Basically, what I need is to combine the results of a “Complex Recipe Search” and a “Get Recipe Information.” The reason I want to do this, is I want my users be able to find recipes by ingredient with amount/unit. So, if a user only have 2 cups apples, it wouldn’t show them “Grandma’s Apple Crisp” in the results, since that recipe requires 4 cups apples.

Right now, in order to do this, I have to first get do a Complex Recipe Search with fillIngredients=true based on the user’s query of 2 apples, then do a Get Recipe Information call for each of the found recipes. So if my initial search with one api call returns 100 results, I then have to make 100 more API calls to get the ingredient list with amounts for each recipe. This seems really inefficient/expensive — if the initial response just returned all the recipe info I need at one time, I wouldn’t need to do all the extra API calls.

I also want the user to be able to limit their results to recipes that are readyInMinutes 60 minutes or less and display how long each recipe takes to cook in the results list, and that data is not available in a Complex Recipe Search. However, it is in a Get Recipe Information, so that’s another reason I need the data from the two calls combined.

Example of a Complex Recipe Search with fillIngredients=true Response. Notice there are no quantities listed for each ingredient, nor is there a readyInMinutes:

{
  "results": [
    {
      "id": 645152,
      "usedIngredientCount": 1,
      "missedIngredientCount": 5,
      "likes": 0,
      "missedIngredients": [
        {
          "aisle": "Produce",
          "name": "lemon juice",
          "extendedName": "fresh lemon juice",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/lemon-juice.jpg"
        },
        {
          "aisle": "Gluten Free",
          "name": "gluten free all purpose flour",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/chickpea-flour-or-another-gluten-free-flour.jpg"
        },
        {
          "aisle": "Frozen",
          "name": "vanilla ice cream",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/vanilla-ice-cream.png"
        },
        {
          "aisle": "Milk, Eggs, Other Dairy",
          "name": "margarine",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/butter.png"
        },
        {
          "aisle": "Spices and Seasonings",
          "name": "ground cinnamon",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/cinnamon.jpg"
        }
      ],
      "usedIngredients": [
        {
          "aisle": "Produce",
          "name": "apples",
          "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/apple.jpg"
        }
      ],
      "title": "Grandma's Apple Crisp",
      "image": "https:\/\/spoonacular.com\/recipeImages\/Grandmas-Apple-Crisp-645152.jpg",
      "imageType": "jpg"
    }
  ],
  "baseUri": "https:\/\/spoonacular.com\/recipeImages\/",
  "offset": 0,
  "number": 10,
  "totalResults": 1,
  "processingTimeMs": 42
}

Example of a Get Recipe Information Response for the same recipe. I have all the information I need here, but I am not able to access this information by having the user search on extendedIngredient name filtering by readyInMinutes. The only way to get this information today is by already knowing the recipe ID:

{
  "vegetarian": false,
  "vegan": false,
  "glutenFree": true,
  "dairyFree": true,
  "veryHealthy": false,
  "cheap": false,
  "veryPopular": false,
  "sustainable": false,
  "weightWatcherSmartPoints": 14,
  "gaps": "no",
  "lowFodmap": false,
  "ketogenic": false,
  "whole30": false,
  "servings": 6,
  "sourceUrl": "http:\/\/www.foodista.com\/recipe\/NT7TWL8W\/grandmas-apple-crisp",
  "spoonacularSourceUrl": "https:\/\/spoonacular.com\/grandmas-apple-crisp-645152",
  "aggregateLikes": 1,
  "creditText": "Foodista.com \u2013 The Cooking Encyclopedia Everyone Can Edit",
  "license": "CC BY 3.0",
  "sourceName": "Foodista",
  "extendedIngredients": [
    {
      "id": 9003,
      "aisle": "Produce",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/apple.jpg",
      "name": "apples",
      "amount": 4,
      "unit": "cups",
      "unitShort": "c",
      "unitLong": "cups",
      "originalString": "4 cups chopped apples (skins on)",
      "metaInformation": [
        "chopped",
        "(skins on)"
      ]
    },
    {
      "id": 93620,
      "aisle": "Gluten Free",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/chickpea-flour-or-another-gluten-free-flour.jpg",
      "name": "gluten free all purpose flour",
      "amount": 0.75,
      "unit": "cup",
      "unitShort": "c",
      "unitLong": "cups",
      "originalString": "3\/4 cup gluten free all purpose flour",
      "metaInformation": [
        "gluten free"
      ]
    },
    {
      "id": 2010,
      "aisle": "Spices and Seasonings",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/cinnamon.jpg",
      "name": "ground cinnamon",
      "amount": 5.5,
      "unit": "teaspoons",
      "unitShort": "t",
      "unitLong": "teaspoons",
      "originalString": "5 1\/2 teaspoons ground cinnamon",
      "metaInformation": [
        
      ]
    },
    {
      "id": 9152,
      "aisle": "Produce",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/lemon-juice.jpg",
      "name": "lemon juice",
      "amount": 1,
      "unit": "tablespoon",
      "unitShort": "T",
      "unitLong": "tablespoon",
      "originalString": "1 tablespoon fresh lemon juice",
      "metaInformation": [
        "fresh"
      ]
    },
    {
      "id": 4073,
      "aisle": "Milk, Eggs, Other Dairy",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/butter.png",
      "name": "margarine",
      "amount": 0.25,
      "unit": "cup",
      "unitShort": "c",
      "unitLong": "cups",
      "originalString": "1\/4 cup melted non-hydrogenated margarine",
      "metaInformation": [
        "melted"
      ]
    },
    {
      "id": 2047,
      "aisle": "Spices and Seasonings",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/salt.jpg",
      "name": "salt",
      "amount": 1,
      "unit": "pinch",
      "unitShort": "pinch",
      "unitLong": "pinch",
      "originalString": "Pinch of salt",
      "metaInformation": [
        
      ]
    },
    {
      "id": 19095,
      "aisle": "Frozen",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/vanilla-ice-cream.png",
      "name": "vanilla ice cream",
      "amount": 6,
      "unit": "scoops",
      "unitShort": "scoops",
      "unitLong": "scoops",
      "originalString": "6 scoops non dairy vanilla ice cream",
      "metaInformation": [
        
      ]
    },
    {
      "id": 14412,
      "aisle": "Beverages",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/water.jpg",
      "name": "water",
      "amount": 0.25,
      "unit": "cup",
      "unitShort": "c",
      "unitLong": "cups",
      "originalString": "1\/4 cup water",
      "metaInformation": [
        
      ]
    },
    {
      "id": 19335,
      "aisle": "Baking",
      "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/white-sugar.jpg",
      "name": "white sugar",
      "amount": 0.5,
      "unit": "cup",
      "unitShort": "c",
      "unitLong": "cups",
      "originalString": "1\/2 cup organic \u201cwhite\u201d sugar",
      "metaInformation": [
        "organic"
      ]
    }
  ],
  "id": 645152,
  "title": "Grandma's Apple Crisp",
  "readyInMinutes": 60,
  "image": "https:\/\/spoonacular.com\/recipeImages\/Grandmas-Apple-Crisp-645152.jpg",
  "instructions": "<ol><li>Preheat the oven to 350 F. If youre like me and dont have a microwave, this is a great time to put the margarine in the oven to melt (in a heat proof container).<\/li><li>Mix together the apples, cinnamon, salt, water, and lemon juice. Place this mixture in a lightly oiled 10 x 6-inch baking dish or a round pie pan. Next, mix the melted margarine with the flour, sugar, and salt until thoroughly combined. Crumble this evenly on top of the apples.<\/li><li>Bake for 45-50 minutes, or until the topping is nicely browned and crisp. This is best served warm with a scoop of vanilla ice cream (non dairy if desired.)<\/li><\/ol>"
}

Also, while I’m just one developer working on my app on nights and weekends right now, eventually when it’s finished I’d like to charge money for it. Do you have a Service Level Agreement for your higher paying customers on the Ultra or Mega plans? My biggest concern is the uptime of the API. I know it was down a couple months ago for a little bit, and while that was no big deal to me at the time, once I have paying customers accessing my app it will be.

Finally, I just want to say it’s been a pleasure working with your API so far. I appreciate how responsive you are to the support tickets. I did some research on recipe APIs before settling on spoonacular. I like how you have inexpensive introductory plans. Your competitors like Yummly start at $500(!) a month — definitely cost prohibitive for someone trying to bootstrap their own app without any income coming in for months.

Rapid account: Adananddevkar 7875
adananddevkar7875 Commented 6 months ago

https://spoonacular.com/cdn/ingredients_100x100/ this link not working in my app in android studio can you fix this link or another solution for that

Rapid account: Juji 555
juji555 Commented 8 years ago

Awesome, thanks!

Rapid account: Spoonacular
spoonacular Commented 8 years ago

whooops, typo fixed and information added 😉

Rapid account: Juji 555
juji555 Commented 8 years ago

One more thing – even when using the new addRecipeInformation=true combined with fillIngredients=true in complex recipe search, the information I get back about each ingredient isn’t as complete as when using get recipe information. Specifically, I need the aisle and the originalString too. I apologize for not listing that out specifically in my original request.

Here is an example of how the information looks for used and missed ingredients using the new endpoints in complex recipe search:

"missedIngredients": [
          {
            "amout": 8,
            "unit": "ounces",
            "unitLong": "ounces",
            "aisle": "Refrigerated",
            "name": "crescent roll dough",
            "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/crescent-rolls.jpg"
          }

and

"usedIngredients": [
          {
            "amout": 0.5,
            "unit": "teaspoon",
            "unitLong": "teaspoons",
            "aisle": "Spices and Seasonings",
            "name": "cinnamon",
            "image": "https:\/\/spoonacular.com\/cdn\/ingredients_100x100\/cinnamon.jpg"
          }
        ]

Whereas in the get recipe information call, the ingredient information looks like this:

 "extendedIngredients": [
    {
      "id": 1022009,
      "aisle": "Ethnic Foods",
      "image": "https://spoonacular.com/cdn/ingredients_100x100/chili-powder.jpg",
      "name": "ancho chile powder",
      "amount": 1.5,
      "unit": "teaspoons",
      "unitShort": "t",
      "unitLong": "teaspoons",
      "originalString": "1 1/2 teaspoons chipotle chile powder or ancho chile powder",
      "metaInformation": []
    }

Would it be a lot of trouble for you to provide all of the same ingredient information in complex recipe search when using addRecipeInformation=true?

Rapid account: Juji 555
juji555 Commented 8 years ago

There is a typo now in the complex recipe search results – under both missedIngredient and UsedIngredients amount is spelled wrong, like this: "amout": 1,

Rapid account: Spoonacular
spoonacular Commented 8 years ago

Cool thanks 😃

Rapid account: Juji 555
juji555 Commented 8 years ago

Thank you! I will send you a link when it is done 😃

Rapid account: Spoonacular
spoonacular Commented 8 years ago

Hi Juji,

The endpoint of your desire is now available: https://market.mashape.com/spoonacular/recipe-food-nutrition#complex-recipe-search, just set addRecipeInformation to true. You do not need to change your plan. Just do that when you feel that you need to. I’m curious to see what you’re building. Let me know if you need anything else 😃

Best,
David

Rapid account: Juji 555
juji555 Commented 8 years ago

Yes, that makes sense. When will this new endpoint be available? Do I need to switch to the Ultra Plan in able to use it? At this time, I don’t need the Ultra Plan since I have no users (yet), but I if I need to switch to get access to this new endpoint I can. Let me know.

Rapid account: Spoonacular
spoonacular Commented 8 years ago

Hi Juji,

So I can make that endpoint possible. I will add another parameter that allows you to merge complex search results with recipe information. However, since that is computationally more expensive half a request per recipe is counted as a request. So if you call complex recipe search with number=4 the number of requests counted will be 3+4/2 = 5. That is better than calling complex recipe search and then calling recipe information for each recipe which would be 3 + 4 calls of recipe information = 7. Does that make sense?

Join in the discussion - add comment below:

Login / Signup to post new comments