Natural Language for Exercise

Prev Next

Use this API to estimate calories burned for various exercises using natural language. Developer can optionally include user demographics like age, gender, weight to make a more accurate estimate for calories burned.

Resource Information

Add the resource information as follows:

Resource Information Value
Response Format JSON
Requires Authentication Yes
HTTP Method POST
Host Domain https://trackapi.nutritionix.com
Endpoint /v2/natural/exercise

Header

The header of the request contains parameters to authenticate the request. The request is authenticated only if the API authentication is enabled for you.

To authenticate the request, you must pass the “x-app-id” and “x-app-key”. For more information, see Understand Request Headers.

Parameters

Expand to see the parameters and description


NameRequiredDescriptionExample

query

string

YesQuery to be executed against.
“I ran 1 mile”

weight_kg

number

NoWeight55

height_cm

number

NoHeight167.64

age

number

NoAge in years60

Request

In the request, send the following details:


var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://trackapi.nutritionix.com/v2/natural/exercise',
  'headers': {
    'Content-Type': 'application/json',
    'x-app-id': ,
    'x-app-key': 
  },
  body: JSON.stringify({
    "query": "swam for 1 hour"
  })

};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

Response

Returns in JSON format.


{
    "exercises": [
        {
            "tag_id": 63,
            "user_input": "swam",
            "duration_min": 60,
            "met": 6,
            "nf_calories": 420,
            "photo": {
                "highres": "https://d2xdmhkmkbyw75.cloudfront.net/exercise//63_highres.jpg",
                "thumb": "https://d2xdmhkmkbyw75.cloudfront.net/exercise//63_thumb.jpg",
                "is_user_uploaded": false
            },
            "compendium_code": 18310,
            "name": "swimming",
            "description": null,
            "benefits": null
        }
    ]
}