# Get Food

### Description

[Swagger doc](https://api.whisk.com/spec/#/FoodAPI/FoodAPI_GetFood)

Returns brand, nutrition data and available measurements for food

### Parameters

<table><thead><tr><th width="139">Name</th><th width="102">Optional</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>food_hits</td><td>no</td><td>array[string]</td><td>Food identifiers to be fetched</td></tr><tr><td>response_mask.paths</td><td>yes</td><td>array[string]</td><td>List of top level fields of result model to be returned. Minimal required set of fields should be specified to reduce payload size</td></tr></tbody></table>

#### Request example

The recommended set of fields to request to cover the common use case of displaying a product is&#x20;

```
title
brand
nutrition
measures
```

```bash
curl -X GET "https://api.whisk.com/food/v2/get?food_hits=CiMyMDJlNjM2M2Q3YWRkNjU0ZmI2OGZmZTNkZGM1ODliMzY5ZA==&food_hits=CiMyMDI2OTdjYjQ5MGU5YmM0MTMzYTg5OWYzOWJhZTI3NmEyZQ==&language=en&country=gb&response_mask.paths=title&response_mask.paths=brand&response_mask.paths=nutrition&response_mask.paths=measures" -H  "accept: application/json" -H  "Authorization: Bearer %WHISK_TOKEN%"
```

### Response

Data returned in JSON. Empty strings, zero values, empty arrays and null values are not returned.&#x20;

#### Json response example with the proper response\_mask.paths specified

```json
{
  "food": [
    {
      "title": "apple",
      "measures": {
        "measures_with_nutrition": [
          {
            "nutrition": {
              "nutrition": [
                {
                  "unit_name": "NUTRITION_UNIT_MKG",
                  "code": "NUTRITION_CODE_VITB12"
                },
                {
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_CHOLE"
                },
                {
                  "amount": 10.100000381469727,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_SUGAR"
                },
                {
                  "amount": 0.6000000238418579,
                  "unit_name": "NUTRITION_UNIT_MKG",
                  "code": "NUTRITION_CODE_VITK1"
                },
                {
                  "amount": 0.03999999910593033,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FAPU"
                },
                {
                  "amount": 0.019999999552965164,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FASAT"
                },
                {
                  "amount": 12.760000228881836,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_CHOCDF"
                },
                {
                  "unit_name": "NUTRITION_UNIT_MKG",
                  "code": "NUTRITION_CODE_FOL"
                },
                {
                  "amount": 11.399999618530273,
                  "unit_name": "NUTRITION_UNIT_MKG",
                  "code": "NUTRITION_CODE_VITA_RAE"
                },
                {
                  "amount": 0.05000000074505806,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_ZN"
                },
                {
                  "amount": 0.029999999329447746,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_RIBF"
                },
                {
                  "amount": 0.12999999523162842,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FAT"
                },
                {
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FAMS"
                },
                {
                  "amount": 0.27000001072883606,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_PROCNT"
                },
                {
                  "amount": 11,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_P"
                },
                {
                  "amount": 4,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_VITC"
                },
                {
                  "amount": 90,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_K"
                },
                {
                  "amount": 4,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_MG"
                },
                {
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FATRN"
                },
                {
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_NA"
                },
                {
                  "amount": 0.05000000074505806,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_TOCPHA"
                },
                {
                  "amount": 1.2999999523162842,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FIBTG"
                },
                {
                  "amount": 0.03999999910593033,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_VITB6A"
                },
                {
                  "amount": 47.79999923706055,
                  "unit_name": "NUTRITION_UNIT_KCAL",
                  "code": "NUTRITION_CODE_ENERC_KCAL"
                },
                {
                  "amount": 0.019999999552965164,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_THIA"
                },
                {
                  "amount": 5,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_CA"
                },
                {
                  "unit_name": "NUTRITION_UNIT_MKG",
                  "code": "NUTRITION_CODE_VITD"
                },
                {
                  "amount": 0.09000000357627869,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_NIA"
                },
                {
                  "amount": 0.07000000029802322,
                  "unit_name": "NUTRITION_UNIT_MG",
                  "code": "NUTRITION_CODE_FE"
                }
              ]
            },
            "measures": [
              {
                "amount": 4.625121890828984,
                "name": "small",
                "measure_unit": "MEASURE_UNIT_OZ",
                "nutrition_coefficient": 1.3112000000000001
              },
              {
                "amount": 131.12,
                "name": "small",
                "measure_unit": "MEASURE_UNIT_G",
                "nutrition_coefficient": 1.3112000000000001
              },
              {
                "amount": 5.649477745844799,
                "name": "medium",
                "measure_unit": "MEASURE_UNIT_OZ",
                "nutrition_coefficient": 1.6016
              },
              {
                "amount": 160.16,
                "name": "medium",
                "measure_unit": "MEASURE_UNIT_G",
                "nutrition_coefficient": 1.6016
              },
              {
                "amount": 3.5273961949580412,
                "name": "100 G",
                "measure_unit": "MEASURE_UNIT_OZ",
                "nutrition_coefficient": 1
              },
              {
                "amount": 100,
                "name": "100 G",
                "measure_unit": "MEASURE_UNIT_G",
                "nutrition_coefficient": 1
              },
              {
                "amount": 182,
                "name": "medium",
                "measure_unit": "MEASURE_UNIT_G",
                "nutrition_coefficient": 1.82
              },
              {
                "amount": 6.922162292985661,
                "name": "large",
                "measure_unit": "MEASURE_UNIT_OZ",
                "nutrition_coefficient": 1.9624000000000001
              },
              {
                "amount": 196.24,
                "name": "large",
                "measure_unit": "MEASURE_UNIT_G",
                "nutrition_coefficient": 1.9624000000000001
              }
            ]
          }
        ]
      },
      "food_hit": "CiMyMDI2OTdjYjQ5MGU5YmM0MTMzYTg5OWYzOWJhZTI3NmEyZQ=="
    }
  ]
}


```

#### Core Attributes

In case `response_mask.paths`  `brand, title, nutrition, measures` as in the example above are passed&#x20;

<table><thead><tr><th width="200">Name</th><th width="102">Optional</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td>title</td><td>no</td><td>string</td><td>Localized food name</td></tr><tr><td>brand</td><td>yes</td><td>string</td><td>Brand name</td></tr><tr><td>measures</td><td>yes</td><td>object</td><td>Wrapper object for a list of measures</td></tr><tr><td>measures.measures_with_nutrition</td><td>no</td><td>array</td><td>List of measurements specific to this food along with the nutrition per 100 g</td></tr><tr><td>measures.measures_with_nutrition.measures.amount</td><td>no</td><td>double</td><td>Number of <code>measure_unit</code> within one measure e.g. slice of cheese is 20g, cup of milk is 240ml. Not rounded</td></tr><tr><td>measures.measures_with_nutrition.measures.measure_unit</td><td>no</td><td>enum</td><td>MEASURE_UNIT_G | MEASURE_UNIT_ML | MEASURE_UNIT_OZ | MEASURE_UNIT_FL_OZ<br></td></tr><tr><td>measures.measures_with_nutrition.measures.nutrition_coefficient</td><td>no</td><td>double</td><td>Multiplier to use with nutrition per 100g to get nutrition of measure. It's derived from product density</td></tr><tr><td>measures.measures_with_nutrition.measures.name</td><td>no</td><td>string</td><td>Localized measurement name e.g. <code>slice</code></td></tr><tr><td>measures_with_nutrition.nutrition</td><td>no</td><td>object</td><td>Wrapper object for nutrition list</td></tr><tr><td>measures_with_nutrition.nutrition.nutrition</td><td>no</td><td>array</td><td>List of nutrition components</td></tr><tr><td>measures_with_nutrition.nutrition.nutrition.amount</td><td>yes</td><td>double</td><td>Amount of nutrition component per 100g of the food</td></tr><tr><td>measures_with_nutrition.nutrition.nutrition.unit_name</td><td>no</td><td>enum</td><td>NUTRITION_UNIT_G | NUTRITION_UNIT_MG | NUTRITION_UNIT_MKG | NUTRITION_UNIT_KCAL<br>Macronutrients and Fiber are returned in grams<br>Micronutrients are returned either in milligrams of micrograms<br>Energy is returned in Kilocalories</td></tr><tr><td>measures_with_nutrition.nutrition.nutrition.code</td><td>no</td><td>enum</td><td>See below</td></tr></tbody></table>

#### Nutrition codes

Whisk is always trying to provide full up to date nutritional data, although all nutrition codes for food are not always available. Nutrition codes for missing data are not returned.

* NUTRITION\_CODE\_ENERC\_KCAL: Energy
* NUTRITION\_CODE\_FAT: Total Fat
* NUTRITION\_CODE\_FASAT: Saturated Fat&#x20;
* NUTRITION\_CODE\_CHOCDF: Carbohydrate Total
* &#x20;NUTRITION\_CODE\_SUGAR: Sugars&#x20;
* NUTRITION\_CODE\_PROCNT: Protein&#x20;
* NUTRITION\_CODE\_NA: Sodium&#x20;
* NUTRITION\_CODE\_FIBTG: Fiber
* &#x20;NUTRITION\_CODE\_FATRN: Trans Fat&#x20;
* NUTRITION\_CODE\_FAMS: Monounsaturated Fat&#x20;
* NUTRITION\_CODE\_FAPU: Polyunsaturated Fat&#x20;
* NUTRITION\_CODE\_FAT\_UNSAT: Unsaturated Fat&#x20;
* NUTRITION\_CODE\_CHOLE: Cholesterol&#x20;
* NUTRITION\_CODE\_CA: Calcium&#x20;
* NUTRITION\_CODE\_MG: Magnesium&#x20;
* NUTRITION\_CODE\_K: Potassium&#x20;
* NUTRITION\_CODE\_FE: Iron&#x20;
* NUTRITION\_CODE\_ZN: Zinc&#x20;
* NUTRITION\_CODE\_P: Phosphorus&#x20;
* NUTRITION\_CODE\_VITA\_RAE: Vitamin A&#x20;
* NUTRITION\_CODE\_VITC: Vitamin C&#x20;
* NUTRITION\_CODE\_THIA: Thiamin B1&#x20;
* NUTRITION\_CODE\_RIBF: Riboflavin B2&#x20;
* NUTRITION\_CODE\_NIA: Niacin B3&#x20;
* NUTRITION\_CODE\_VITB6A: Vitamin B6&#x20;
* NUTRITION\_CODE\_FOL: Folic Acid B9&#x20;
* NUTRITION\_CODE\_VITB12: Vitamin B12&#x20;
* NUTRITION\_CODE\_VITD: Vitamin D&#x20;
* NUTRITION\_CODE\_TOCPHA: Vitamin E&#x20;
* NUTRITION\_CODE\_VITK1: Vitamin K

#### Imperial measures

When country is specified in the request and is one of USA, UK, Canada, then Whisk API will return measures in both Metric and Imperial systems.&#x20;

#### Measures and nutrition explained

To support volume based measures we've introduced a `nutrition_coefficient` attribute. Let's see it on the following example

```
      "title":"milk",
        "measures_with_nutrition": [
          {
            "nutrition": {
              "nutrition": [
                {
                  "amount": 60,
                  "unit_name": "NUTRITION_UNIT_KCAL",
                  "code": "NUTRITION_CODE_ENERC_KCAL"
                },
                {
                  "amount": 3.200000047683716,
                  "unit_name": "NUTRITION_UNIT_G",
                  "code": "NUTRITION_CODE_FAT"
                }
              ]
            },
            "measures": [
              {
                "amount": 240,
                "name": "cup",
                "measure_unit": "MEASURE_UNIT_ML",
                "nutrition_coefficient": 2.448
              },
              {
                "amount": 100,
                "name": "100 Ml",
                "measure_unit": "MEASURE_UNIT_ML",
                "nutrition_coefficient": 1.02
              }
            ]
          }
        ]
```

\
Whisk API returns nutrition per `100g` in metric units. It's a standard adopted all over the world including USDA and KFDA.&#x20;

The response above means:

There's `60 kCal` and `3.2g` of Fat in `100g` of Milk.

The cup of milk has volume of `240 ml` or `8.11 fl oz`. The cup of milk weights `2.448` times more than `100g` of milk.\
So the cup of milk has `60 * 2.448 = 146.88 kCal` and `3.2 * 2.448 = 7.8g` of Fat.

Sometimes one product may come with different attributes e.g. `cooked` or `fried`. Since nutrition of `cooked` product is different, it will come as a separate item within `measures_with_nutrition` array.&#x20;
