This endpoint requires an app ID and app key from https://developer.nutritionix.com/admin/access_details
POST
https://trackapi.nutritionix.com/v2/natural/nutrients
HEADERS
Content-Type:application/json, x-app-id:NutritionixAppID, x-app-key:NutritionixAppKey
BODY:
{
"query":"for breakfast i ate 2 eggs, bacon, and french toast",
"timezone": "US/Eastern"
}
Notes:
- The end user's timezone parameter is optional, but it should be provided to ensure accuracy in time derivations. For example, if the user says "for breakfast" it will assume 8AM in that user's time zone.
- All consumed_at timetamps are reported back from the API in UTC
Simple code:
import http.client
conn = http.client.HTTPSConnection("trackapi.nutritionix.com")
headers = {
'x-app-id': "",
'x-app-key': "",
'x-remote-user-id': "0"
}
#the app-id and app-key are hidden
conn.request(
"POST", "/v2/natural/nutrients?query=lamb++kebabs", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Why am I getting this error?
{"message":"child "query" fails because ["query" is required]","id":"858dd283-6025-4e8d-a2c5-312057bb4f6e"}