# import inside your projectfromnutritionix.nutritioniximportNutritionixClientnutritionix=NutritionixClient(
application_id='YOUR_APP_ID',
api_key='YOUR_API_KEY',
# debug=True, # defaults to False
)
Usage
Standard Search
"""This will perform a search. The object passed into this functioncan contain all the perameters the API accepts in the `POST /v2/search` endpoint"""nutritionix.search(q='salad', limit=10, offset=0, search_nutrient='calories')
Brand Search
"""This will perform a search. The object passed into this functioncan contain all the perameters the API accepts in the `GET /v2/search/brands` endpointtype: (1:restaurant, 2:cpg, 3:usda/nutritionix) defaults to undefined"""nutritionix.brand_search(q='just salad', limit=10, offset=0, type=1)
Get Brand By id
# this will locate a brand by its idnutritionix.brand(id='bV')
Get Item By id or search resource_id
# this will locate an item by its id or by a search `resource_id`nutritionix.item(id='zgcjnYV')
Natural
"""The natural endpoint allows you to translate plane text into a full spectrum analysis.gram_weight: An {Integer} that will be used as a multiplier when calculating `total.nutrients`"""ingredients="""1 tbsp sugar16 fl oz water1/2 lemon"""nutritionix.natural(q=ingredients, gram_weight=20)
Autocomplete
#allow users the convenience of "as you type" suggestions.nutritionix.autocomplete(q='greek y')
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.