Package: yummly
Python library forYummly APINOTE:This library and its author are not affliated with Yummly.Installationpip install yummlyDependenciesrequests >= 1.1.0UsageUseyummly.Clientto create a client object to interact with the Yummly API.The client acceptsapi_id,api_key, andtimeoutas init parameters:fromyummlyimportClient# default option valuesTIMEOUT=5.0RETRIES=0client=Client(api_id=YOUR_API_ID,api_key=YOUR_API_KEY,timeout=TIMEOUT,retries=RETRIES)search=client.search('green eggs and ham')match=search.matches[0]recipe=client.recipe(match.id)Search RecipesAPI endpoint:api.yummly.com/v1/api/recipes?<params>Search for recipes meeting certain criteria:results=yummly.search('bacon')print('Total Matches:',results.totalMatchCount)formatchinresults.matches:print('Recipe ID:',match.id)print('Recipe:',match.recipeName)print('Rating:',match.rating)print('Total Time (mins):',match.totalTimeInSeconds/60.0)print('----------------------------------------------------')Limit your results to a maximum:# return the first 10 resultsresults=yummly.search('chicken marsala',maxResults=10)Offset the results for pagination:# return 2nd page of resultsresults=yummly.search('pulled pork',maxResults=10,start=10)Provide search parameters:params={'q':'pork chops','start':0,'maxResult':40,'requirePicutres':True,'allowedIngredient[]':['salt','pepper'],'excludedIngredient[]':['cumin','paprika'],'maxTotalTimeInSeconds':3600,'facetField[]':['ingredient','diet'],'flavor.meaty.min':0.5,'flavor.meaty.max':1,'flavor.sweet.min':0,'flavor.sweet.max':0.5,'nutrition.FAT.min':0,'nutrition.FAT.max':15}results=yummly.search(**params)For a full list of supported search parameters, see sectionThe Search Recipes Calllocated at:https://developer.yummly.com/introExample search response:https://developer.yummly.com/wiki/search-recipes-response-sampleGet RecipeAPI endpoint:api.yummly.com/v1/api/recipe/<recipe_id>Fetch a recipe by its recipe ID:recipe=yummly.recipe(recipe_id)print('Recipe ID:',recipe.id)print('Recipe:',recipe.name)print('Rating:',recipe.rating)print('Total Time:',recipe.totalTime)print('Yields:',recipe.yields)print('Ingredients:')foringredinrecipe.ingredientLines:print(ingred)Example recipe response:https://developer.yummly.com/wiki/get-recipe-response-sampleNOTE:Yummly’s Get-Recipe response includesyieldas a field name. However,yieldis a keyword in Python so this has been renamed toyields.Search metadataAPI endpoint:api.yummly.com/v1/api/metadata/<metadata_key>Yummly provides a metadata endpoint that returns the possible values for allowed/excluded ingredient, diet, allergy, and other search parameters:METADATA_KEYS=['ingredient','holiday','diet','allergy','technique','cuisine','course','source','brand','restriction']ingredients=client.metadata('ingredient')diets=client.metadata('diet')sources=client.metadata('source')NOTE:Yummly’s raw API returns this data as a JSONP response whichyummly.pyparses off and then converts to alistcontaining instances of the corresponding metadata class.API Model ClassesAll underlying API model classes are inyummly/models.py. The base class used for all models is a modifieddictclass with attribute-style access (i.e. bothobj.fooandobj['foo']are valid accessor methods).A deriveddictclass was chosen to accommodate painless conversion to JSON which is a fairly common requirement when usingyummly.pyas an API proxy to feed your applications (e.g. a web app withyummly.pyrunning on your server instead of directly using the Yummly API on the frontend).TestingTests are located intests/. They can be executed usingpytestfrom the root directory usingmakefileorpytest.# using makefile
make test

# using pytest directly
py.test yummlyNOTE:Running the test suite will use real API calls which will count against your call limit. Currently, 22 API calls are made when running the tests.Test Config FileA test config file is required to run the tests. Createtests/config.jsonwith the following properties:{"api_id":"YOUR_API_ID","api_key":"YOUR_API_KEY"}This file will be loaded automatically when the tests are run.LicenseThis software is licensed under the MIT License.TODOProvide helpers for complex search parameters like nutrition, flavors, and metadata