# Nutritionix

> Look up nutrition in Nutritionix's food database: turn a meal or a workout described in plain words into calories and nutrients, search foods, read a product's label by barcode, and find restaurants nearby.

App · 8 actions. Web page: https://docs.lodol.com/docs/integrations/nutritionix

## Actions

### Estimate calories burned

Turn plain words such as 'ran 3 miles' or '30 minutes yoga' into each exercise's duration and calories burned. Gender, weight, height and age make the estimate closer.

**Inputs**

- What was done (`query`, text, required): The exercise in plain words, with how long or how far, such as 'ran 3 miles' or '30 minutes yoga'.
- Gender (`gender`, text): The person's gender, for a closer estimate. One of: `female`, `male`.
- Weight (kg) (`weight_kg`, number): The person's weight in kilograms, for a closer estimate. From 1 to 500.
- Height (cm) (`height_cm`, number): The person's height in centimetres, for a closer estimate. From 30 to 300.
- Age (`age`, number): The person's age in years, for a closer estimate. From 1 to 130.

**Outputs**

- `count` (number): How many exercises were recognised
- `exercises` (list): Each exercise recognised
- `matched` (true/false): False when Nutritionix recognised nothing in the words
- `total_calories` (number): Calories burned by everything recognised
- `total_duration_min` (number): Minutes of everything recognised

**Example output**

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

### Find restaurant locations

List the restaurant locations Nutritionix knows nearest a point, with each one's brand, address and distance.

**Inputs**

- Latitude (`latitude`, number, required): The point's latitude, such as 38.8981. From -90 to 90.
- Longitude (`longitude`, number, required): The point's longitude, such as -77.0294. From -180 to 180.
- How many (`limit`, number): The most locations to return, 1 to 50. From 1 to 50.

**Outputs**

- `count` (number): How many
- `locations` (list): The nearest locations

**Example output**

```json
{
  "count": 1,
  "locations": [
    {
      "address": "1301 Pennsylvania Ave NW",
      "address2": null,
      "brand_id": "513fbc1283aa2dc80c00001f",
      "city": "Washington",
      "country": "US",
      "distance_km": 0.25,
      "id": 1157461,
      "lat": 38.8964,
      "lng": -77.0306,
      "name": "Starbucks",
      "phone": "+12026381320",
      "state": "DC",
      "website": "https://www.starbucks.com",
      "zip": "20004"
    }
  ]
}
```

### Get branded food

Get a restaurant item's or grocery product's full nutrition label by its Nutritionix item id, as 'Search foods' returns it.

**Inputs**

- Item ID (`nix_item_id`, text, required): The food's Nutritionix item id (nix_item_id), from 'Search foods' or an earlier step.
- Include servings per container (`servings_per_container`, true/false): Also return how many servings the package holds.

**Outputs**

- `food` (object): The food's nutrition label
- `foods` (list): Every food Nutritionix returned

**Example output**

```json
{
  "food": {
    "alt_measures": null,
    "brand_name": "Coke",
    "brick_code": null,
    "class_code": null,
    "food_name": "Diet Cola",
    "full_nutrients": [
      {
        "attr_id": 203,
        "value": 0
      },
      {
        "attr_id": 204,
        "value": 0
      },
      {
        "attr_id": 205,
        "value": 0
      },
      {
        "attr_id": 208,
        "value": 0
      },
      {
        "attr_id": 307,
        "value": 70
      }
    ],
    "lat": null,
    "lng": null,
    "metadata": {},
    "ndb_no": null,
    "nf_calories": 0,
    "nf_cholesterol": null,
    "nf_dietary_fiber": null,
    "nf_ingredient_statement": "Carbonated Water, Caramel Color, Aspartame, Phosphoric Acid, Potassium Benzoate (to Protect Taste), Natural Flavors, Citric Acid, Caffeine.",
    "nf_metric_qty": 591,
    "nf_metric_uom": "ml",
    "nf_p": null,
    "nf_potassium": null,
    "nf_protein": 0,
    "nf_saturated_fat": null,
    "nf_sodium": 70,
    "nf_sugars": null,
    "nf_total_carbohydrate": 0,
    "nf_total_fat": 0,
    "nix_brand_id": "51db3801176fe9790a89ae0b",
    "nix_brand_name": "Coke",
    "nix_item_id": "51d2fae7cc9bff111580d8d8",
    "nix_item_name": "Diet Cola",
    "note": null,
    "photo": {
      "highres": null,
      "is_user_uploaded": false,
      "thumb": "https://nutritionix-api.s3.amazonaws.com/5b5c17c429f162275dc922b0.jpeg"
    },
    "serving_qty": 1,
    "serving_unit": "bottle",
    "serving_weight_grams": 226,
    "source": 8,
    "tag_id": null,
    "tags": null,
    "updated_at": "2022-06-22T03:14:26+00:00"
  },
  "foods": [
    {
      "alt_measures": null,
      "brand_name": "Coke",
      "brick_code": null,
      "class_code": null,
      "food_name": "Diet Cola",
      "full_nutrients": [
        {
          "attr_id": 203,
          "value": 0
        },
        {
          "attr_id": 204,
          "value": 0
        },
        {
          "attr_id": 205,
          "value": 0
        },
        {
          "attr_id": 208,
          "value": 0
        },
        {
          "attr_id": 307,
          "value": 70
        }
      ],
      "lat": null,
      "lng": null,
      "metadata": {},
      "ndb_no": null,
      "nf_calories": 0,
      "nf_cholesterol": null,
      "nf_dietary_fiber": null,
      "nf_ingredient_statement": "Carbonated Water, Caramel Color, Aspartame, Phosphoric Acid, Potassium Benzoate (to Protect Taste), Natural Flavors, Citric Acid, Caffeine.",
      "nf_metric_qty": 591,
      "nf_metric_uom": "ml",
      "nf_p": null,
      "nf_potassium": null,
      "nf_protein": 0,
      "nf_saturated_fat": null,
      "nf_sodium": 70,
      "nf_sugars": null,
      "nf_total_carbohydrate": 0,
      "nf_total_fat": 0,
      "nix_brand_id": "51db3801176fe9790a89ae0b",
      "nix_brand_name": "Coke",
      "nix_item_id": "51d2fae7cc9bff111580d8d8",
      "nix_item_name": "Diet Cola",
      "note": null,
      "photo": {
        "highres": null,
        "is_user_uploaded": false,
        "thumb": "https://nutritionix-api.s3.amazonaws.com/5b5c17c429f162275dc922b0.jpeg"
      },
      "serving_qty": 1,
      "serving_unit": "bottle",
      "serving_weight_grams": 226,
      "source": 8,
      "tag_id": null,
      "tags": null,
      "updated_at": "2022-06-22T03:14:26+00:00"
    }
  ]
}
```

### Get nutrition from a description

Turn plain words such as '2 eggs and a slice of toast' into each food's calories and nutrients, with the meal's totals.

**Inputs**

- What was eaten (`query`, text, required): The foods in plain words, with amounts if known, such as '1 cup oatmeal and 2 boiled eggs' or 'a Big Mac'.
- Servings it makes (`num_servings`, number): For a recipe: how many servings the foods make. Each food's nutrients are divided by it. Leave empty for 1. At least 1.
- When eaten (`consumed_at`, date and time): When the food was eaten. Leave empty to let Nutritionix work it out from the words (such as 'for breakfast') or use now.
- Time zone (`timezone`, text): The eater's time zone, used to read words like 'yesterday' or 'for lunch', such as US/Pacific or Europe/London. Defaults to US/Eastern.
- One food per line (`line_delimited`, true/false): Read each line as exactly one food.
- Allow raw foods (`use_raw_foods`, true/false): Match uncooked versions of foods, such as raw chicken.
- Allow brand names (`use_branded_foods`, true/false): Recognise branded foods named in the words, such as a Big Mac.
- Include recipe ingredients (`include_subrecipe`, true/false): For a dish with a known recipe, also return its ingredients.
- Include ingredient list (`ingredient_statement`, true/false): Also return each food's ingredient statement where Nutritionix has one.

**Outputs**

- `count` (number): How many foods were recognised
- `foods` (list): Each food recognised, with its nutrients
- `matched` (true/false): False when Nutritionix recognised nothing in the words
- `total_calories` (number): Calories of everything recognised
- `total_carbohydrate_g` (number): Carbohydrate of everything recognised, in grams
- `total_fat_g` (number): Fat of everything recognised, in grams
- `total_protein_g` (number): Protein of everything recognised, in grams
- `total_sodium_mg` (number): Sodium of everything recognised, in milligrams
- `total_sugars_g` (number): Sugars of everything recognised, in grams

**Example output**

```json
{
  "count": 1,
  "foods": [
    {
      "alt_measures": [
        {
          "measure": "cup",
          "qty": 1,
          "seq": 1,
          "serving_weight": 151
        },
        {
          "measure": "grapes",
          "qty": 10,
          "seq": 2,
          "serving_weight": 49
        }
      ],
      "brand_name": null,
      "brick_code": null,
      "class_code": null,
      "consumed_at": "2023-09-22T18:24:59+00:00",
      "food_name": "grape",
      "full_nutrients": [
        {
          "attr_id": 203,
          "value": 0.3528
        },
        {
          "attr_id": 204,
          "value": 0.0784
        },
        {
          "attr_id": 205,
          "value": 8.869
        },
        {
          "attr_id": 208,
          "value": 33.81
        }
      ],
      "lat": null,
      "lng": null,
      "meal_type": 3,
      "metadata": {
        "is_raw_food": false
      },
      "ndb_no": 9132,
      "nf_calories": 33.81,
      "nf_cholesterol": 0,
      "nf_dietary_fiber": 0.44,
      "nf_p": 9.8,
      "nf_potassium": 93.59,
      "nf_protein": 0.35,
      "nf_saturated_fat": 0.03,
      "nf_sodium": 0.98,
      "nf_sugars": 7.59,
      "nf_total_carbohydrate": 8.87,
      "nf_total_fat": 0.08,
      "nix_brand_id": null,
      "nix_brand_name": null,
      "nix_item_id": null,
      "nix_item_name": null,
      "photo": {
        "highres": "https://nix-tag-images.s3.amazonaws.com/586_highres.jpg",
        "is_user_uploaded": false,
        "thumb": "https://nix-tag-images.s3.amazonaws.com/586_thumb.jpg"
      },
      "serving_qty": 10,
      "serving_unit": "grapes",
      "serving_weight_grams": 49,
      "source": 1,
      "sub_recipe": null,
      "tag_id": null,
      "tags": {
        "food_group": 3,
        "item": "grape",
        "measure": null,
        "quantity": "10.0",
        "tag_id": 586
      },
      "upc": null
    }
  ],
  "matched": true,
  "total_calories": 33.81,
  "total_carbohydrate_g": 8.87,
  "total_fat_g": 0.08,
  "total_protein_g": 0.35,
  "total_sodium_mg": 0.98,
  "total_sugars_g": 7.59
}
```

### List nutrients

List every nutrient Nutritionix reports, with the number (attr_id) that names it in a food's full nutrients, its unit and its daily value.

**Inputs**: None.

**Outputs**

- `count` (number): How many
- `nutrients` (list): The nutrients

**Example output**

```json
{
  "count": 1,
  "nutrients": [
    {
      "api_name": "nf_calories",
      "attr_id": 208,
      "fda_daily_value": 2000,
      "name": "nf_calories",
      "unit": "kcal",
      "usda_nutr_desc": "Energy",
      "usda_sr_order": 300,
      "usda_tag": "ENERC_KCAL"
    }
  ]
}
```

### List restaurant brands

List the restaurant brands Nutritionix has menus for, with each one's brand id, optionally only those whose name contains some words.

**Inputs**

- Name contains (`name_contains`, text): Only brands whose name contains this, such as 'pizza'.

**Outputs**

- `brands` (list): The brands, A to Z
- `count` (number): How many

**Example output**

```json
{
  "brands": [
    {
      "id": "22389211a72974d25c294e35",
      "name": "Chili's"
    }
  ],
  "count": 1
}
```

### Look up food by barcode

Get a grocery product's full nutrition label by the number under its barcode (UPC or EAN).

**Inputs**

- Barcode number (`upc`, text, required): The digits under the product's barcode, such as 049000000450.
- Include servings per container (`servings_per_container`, true/false): Also return how many servings the package holds.

**Outputs**

- `food` (object): The food's nutrition label
- `foods` (list): Every food Nutritionix returned

**Example output**

```json
{
  "food": {
    "alt_measures": null,
    "brand_name": "Coke",
    "brick_code": null,
    "class_code": null,
    "food_name": "Diet Cola",
    "full_nutrients": [
      {
        "attr_id": 203,
        "value": 0
      },
      {
        "attr_id": 204,
        "value": 0
      },
      {
        "attr_id": 205,
        "value": 0
      },
      {
        "attr_id": 208,
        "value": 0
      },
      {
        "attr_id": 307,
        "value": 70
      }
    ],
    "lat": null,
    "lng": null,
    "metadata": {},
    "ndb_no": null,
    "nf_calories": 0,
    "nf_cholesterol": null,
    "nf_dietary_fiber": null,
    "nf_ingredient_statement": "Carbonated Water, Caramel Color, Aspartame, Phosphoric Acid, Potassium Benzoate (to Protect Taste), Natural Flavors, Citric Acid, Caffeine.",
    "nf_metric_qty": 591,
    "nf_metric_uom": "ml",
    "nf_p": null,
    "nf_potassium": null,
    "nf_protein": 0,
    "nf_saturated_fat": null,
    "nf_sodium": 70,
    "nf_sugars": null,
    "nf_total_carbohydrate": 0,
    "nf_total_fat": 0,
    "nix_brand_id": "51db3801176fe9790a89ae0b",
    "nix_brand_name": "Coke",
    "nix_item_id": "51d2fae7cc9bff111580d8d8",
    "nix_item_name": "Diet Cola",
    "note": null,
    "photo": {
      "highres": null,
      "is_user_uploaded": false,
      "thumb": "https://nutritionix-api.s3.amazonaws.com/5b5c17c429f162275dc922b0.jpeg"
    },
    "serving_qty": 1,
    "serving_unit": "bottle",
    "serving_weight_grams": 226,
    "source": 8,
    "tag_id": null,
    "tags": null,
    "updated_at": "2022-06-22T03:14:26+00:00"
  },
  "foods": [
    {
      "alt_measures": null,
      "brand_name": "Coke",
      "brick_code": null,
      "class_code": null,
      "food_name": "Diet Cola",
      "full_nutrients": [
        {
          "attr_id": 203,
          "value": 0
        },
        {
          "attr_id": 204,
          "value": 0
        },
        {
          "attr_id": 205,
          "value": 0
        },
        {
          "attr_id": 208,
          "value": 0
        },
        {
          "attr_id": 307,
          "value": 70
        }
      ],
      "lat": null,
      "lng": null,
      "metadata": {},
      "ndb_no": null,
      "nf_calories": 0,
      "nf_cholesterol": null,
      "nf_dietary_fiber": null,
      "nf_ingredient_statement": "Carbonated Water, Caramel Color, Aspartame, Phosphoric Acid, Potassium Benzoate (to Protect Taste), Natural Flavors, Citric Acid, Caffeine.",
      "nf_metric_qty": 591,
      "nf_metric_uom": "ml",
      "nf_p": null,
      "nf_potassium": null,
      "nf_protein": 0,
      "nf_saturated_fat": null,
      "nf_sodium": 70,
      "nf_sugars": null,
      "nf_total_carbohydrate": 0,
      "nf_total_fat": 0,
      "nix_brand_id": "51db3801176fe9790a89ae0b",
      "nix_brand_name": "Coke",
      "nix_item_id": "51d2fae7cc9bff111580d8d8",
      "nix_item_name": "Diet Cola",
      "note": null,
      "photo": {
        "highres": null,
        "is_user_uploaded": false,
        "thumb": "https://nutritionix-api.s3.amazonaws.com/5b5c17c429f162275dc922b0.jpeg"
      },
      "serving_qty": 1,
      "serving_unit": "bottle",
      "serving_weight_grams": 226,
      "source": 8,
      "tag_id": null,
      "tags": null,
      "updated_at": "2022-06-22T03:14:26+00:00"
    }
  ]
}
```

### Search foods

Find common foods, restaurant items and grocery products by name, optionally only from some brands or within a nutrient limit (such as under 500 calories). Use a branded result's item id with 'Get branded food' for its full label.

**Inputs**

- Search for (`query`, text, required): A food or product name, or the start of one, such as 'chicken'.
- Include common foods (`include_common`, true/false): Include everyday foods without a brand. On unless turned off.
- Include branded foods (`include_branded`, true/false): Include restaurant items and grocery products. On unless turned off.
- Branded food type (`branded_type`, text): Only restaurant foods, or only grocery products. Leave empty for both. One of: `1` (Restaurant foods), `2` (Grocery products).
- Restaurant brands (`brand_ids`, list): Only branded foods from these brands.
- Match item names only (`branded_food_name_only`, true/false): Match branded foods by their item name only, not their brand name.
- Language and country (`locale`, text): Search common foods in this language. Defaults to English (United States). One of: `en_US` (English (United States)), `en_GB` (English (United Kingdom)), `de_DE` (German (Germany)), `fr_FR` (French (France)), `es_ES` (Spanish (Spain)), `es_MX` (Spanish (Mexico)), `it_IT` (Italian (Italy)), `nl_NL` (Dutch (Netherlands)), `pt_PT` (Portuguese (Portugal)), `pt_BR` (Portuguese (Brazil)), and 6 more.
- Limit by nutrient (`nutrient`, text): Only foods whose amount of this nutrient is within the limits given.
- At least (`at_least`, number): The nutrient's lowest amount per serving, in its unit. At least 0.
- At most (`at_most`, number): The nutrient's highest amount per serving, in its unit. At least 0.

**Outputs**

- `branded` (list): Restaurant items and grocery products that match
- `branded_count` (number): How many branded foods
- `common` (list): Common foods that match
- `common_count` (number): How many common foods

**Example output**

```json
{
  "branded": [
    {
      "brand_name": "Original Tommy's Hamburgers",
      "brand_name_item_name": "Original Tommy's Hamburgers Double Hamburger",
      "brand_type": 1,
      "food_name": "Double Hamburger",
      "locale": "en_US",
      "nf_calories": 650,
      "nix_brand_id": "513fbc1283aa2dc80c000273",
      "nix_item_id": "513fc9ca673c4fbc260046ed",
      "photo": {
        "highres": null,
        "is_user_uploaded": false,
        "thumb": "https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png"
      },
      "region": 1,
      "serving_qty": 333,
      "serving_unit": "grams"
    }
  ],
  "branded_count": 1,
  "common": [
    {
      "common_type": null,
      "food_name": "hamburger soup",
      "locale": "en_US",
      "photo": {
        "highres": null,
        "is_user_uploaded": false,
        "thumb": "https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png"
      },
      "serving_qty": 1,
      "serving_unit": "bowl (2 cups)",
      "tag_id": "4818",
      "tag_name": "cheeseburger soup"
    }
  ],
  "common_count": 1
}
```
