from foodfoodfood import FoodData # Create a new instance of the FoodData class and pass in the API key fdb = FoodData(api_key=MY_API_KEY) # Get nutrient data for a specific food by providing the food ID food_data = fdb.get_nutrient_data(food_id=12345) # Print the nutrient data for the food print(food_data)
from foodfoodfood import FoodData # Create a new instance of the FoodData class and pass in the API key fdb = FoodData(api_key=MY_API_KEY) # Search for foods containing "chicken" in the name or description results = fdb.search_foods(keyword="chicken") # Print the results of the search for food in results: print(food["name"])
from foodfoodfood import FoodData, Recipe # Create a new instance of the FoodData class and pass in the API key fdb = FoodData(api_key=MY_API_KEY) # Create a new recipe and add ingredients recipe = Recipe() recipe.add_ingredient(name="chicken breast", quantity=2) recipe.add_ingredient(name="broccoli", quantity=1) # Get the nutrient data for each ingredient for ingredient in recipe.ingredients: nutrient_data = fdb.get_nutrient_data_by_name(ingredient["name"]) ingredient["nutrients"] = nutrient_data["nutrients"] # Print the nutrient data for the recipe print(recipe.nutrient_data)Package library: `foodfoodfood`