headers:
- x-app-id
- x-app-key
- Content-Type: application/json
POST request body:
{
"query":"ran 3 miles",
"gender":"female",
"weight_kg":72.5,
"height_cm":167.64,
"age":30
}
See comment below for sample API response.
Original documentation: https://docs.google.com/document/d/1_q-K-ObMTZvO0qUEAxROrN3bwMujwAN25sLHwJzliK0/edit#
import requests
APP_ID = "438a9c40"
APP_KEY = "7215eb448ce325acba56b4ee224fe917"
headers = {
"x-app-id": APP_ID,
"x-app_key": APP_KEY,
}
GENDER = "male"
WEIGHT = 70.6
HEIGHT = 176.5
AGE = 20
exercise_endpoint = "https://trackapi.nutritionix.com/v2/natural/exercise"
exercise_json = {
"query": input("Tell me which exercise you did. "),
"gender": GENDER,
"weight_kg": WEIGHT,
"height_cm": HEIGHT,
"age": AGE,
}
response = requests.post(url=exercise_endpoint, json=exercise_json, headers=headers)
result = response.json()
print(result)
output:
Tell me which exercise you did. Ran 5km
{'message': 'unauthorized', 'id': 'f54bca63-be81-4859-812d-00944f9fa4f3'}
Hihi, I am facing the same error. Please advice!