Sign in | Sign up

difficult with v2/natural/nutrients

Tagged:

Currently contains 1 post

Avatar

19 Jun, 2017 08:03AM

thesilverbail

Hi,

1.
I tried using the following python code to hit the v2 endpoint. I get “child \”query\" fails because [\“query\” is required]". What am I doing wrong?

import requests
import json

url = ‘https://trackapi.nutritionix.com/v2/natural/nutrients’
headers={ “x-app-id”: “<my id>”,
“x-app-key”: “<my key>”
}
params={ “query”: “grilled cheese” }
response = requests.post(url, headers=headers, params=params)
print response.text

2. I then tried the following code to hit the search/instant endpoint, it gave me results but there were no “common” foods, only “branded” foods. Again, what am i doing wrong?

import requests
import json

url = ‘https://trackapi.nutritionix.com/v2/search/instant?query=grilled%20cheese’
headers={ “x-app-id”: “<my id>”,
“x-app-key”: “<my key>”}
response = requests.get(url, headers=headers)

Thanks
Deepak

Reply to thread