In [3]:
#To Do List
#sign up for api
#define api and key
#create a while True statement for the loop to generate
#define user_input
#define what we want our user_input to return from the dataFrame (calories, sugars, fat, etc.)
#using dataFrame from nutritionix, take the user_input and return the id name for the input specific to the dataFrame
#food is needed before what we want the program to return because food is defined so that it returns the food id, which allows us to return specific things for each food such as 'calories'
#create code to access the data within the dict
#create if statement so that user can quit the loop when finished
#create code to take user to webbrowser when they quit the loop
#set time for when to have the website open (2 seconds)
#paste url for website
#make sure to break the loop
In [39]:
from nutritionix import Nutritionix
nix = Nutritionix(app_id="557650c9", api_key="b3c987d0bdb894c210751635b54c082d")
while True:
user_input = input("Enter a food or type 'quit': ")
r_var = nix.search(user_input, results="0:1").json()
food = nix.item(id=r_var['hits'][0]['_id']).json()
if user_input == 'quit':
print('Stick around to check out the food blog!💃🏻')
import webbrowser
import time
time.sleep(2)
webbrowser.open('http://www.sproutedkitchen.com/recipes/')
break
print("* Dietary Fiber: ", food['nf_dietary_fiber'])
print("* Calories: ", food['nf_calories'])
print("* Calories From Fat: ", food['nf_calories_from_fat'])
print("* Cholesterol: ", food['nf_cholesterol'])
print("* Sugars: ", food['nf_sugars'])
print("* Total Fat: ", food['nf_total_fat'])
print("* Total Carbohydrates: ", food['nf_total_carbohydrate'])
In [1]:
#What We Use
#strings (print statements)
#functions (print statements)
#list function
#while True loop function
#api
#retrieving info from Dict
#if statement
#opening webbrowser
In [11]:
In [ ]:
In [ ]:
In [ ]: