Adding number of servings to our data

We need number servings (and any other important info) from individual recipe detail and putting in table to merge later on. Testing this process on two temporary files, pesto.txt and guac.txt.

I couldn't figure out how to do the recipe-detail API call with parameters like before, so below uses a different method. Works though!


In [1]:
import requests
import json
import pandas as pd
import numpy as np

In [3]:
# create base url variable
get_recipe_url = 'http://api.yummly.com/v1/api/recipe/'

# create id and key variable
mike_id_and_key = '_app_id=e2b9bebc&_app_key=4193215272970d956cfd5384a08580a9'
bruk_id_and_key = '_app_id=79663a75&_app_key=02b233108f476f3110e0f65437c4d6dd'

In [4]:
# example API pull with one ID

toy_id = 'French-Onion-Soup-1332461'

response = requests.get(get_recipe_url + toy_id + '?' + bruk_id_and_key)

In [5]:
# check status code
print response.status_code


200

In [7]:
# view output
data = response.json()
print data.keys()
print "ID: ", data['id']
print data['numberOfServings']


[u'totalTime', u'ingredientLines', u'attribution', u'name', u'rating', u'numberOfServings', u'yield', u'nutritionEstimates', u'source', u'flavors', u'images', u'attributes', u'id', u'totalTimeInSeconds']
ID:  French-Onion-Soup-1332461
6

In [ ]: