Skip to main content

Nutrition API

Endpoint#

/nutrition

Method#

GET

Description#

The Nutrition API allows you to retrieve direct specific nutritional information for a single food item. It accepts a mandatory name parameter, an optional brand parameter, and optional quantity and unit parameters. If quantity and unit are not provided, the API intelligently infers the most likely defaults. The API's accuracy is grounded in our research, which has been validated in top peer-reviewed academic publications.

URL#

https://us-central1-snapcalorieb2bapi.cloudfunctions.net/nutrition

Parameters#

  • key: The API key for authentication (required).
  • name: The name of the food item (required).
  • brand: The brand name of the food item (optional).
  • quantity: The quantity of the food item (optional).
  • unit: The unit of the food item (optional).

Sample Request#

curl -X GET 'https://us-central1-snapcalorieb2bapi.cloudfunctions.net/nutrition?key=YOUR_API_KEY&name=apple&quantity=1&unit=whole'

Sample Responses#

  • Success Response:
{  "code": 200,  "success": true,  "data": {    "name": "apple",    "nutrition_per_100g": {      // Guaranteed fields      "mass_g": 100,      "calories_kcal": 61,      "carb_g": 14.8,      "fat_g": 0.15,      "protein_g": 0.17,
      // Detailed Nutrients, if available      // All possible fields are shown here, but if a nutrient is not availble,      // it will not be present in the response.      // Vitamins      "b1_mg": ,      "b2_mg": ,      "b3_mg": ,      "b5_mg": ,      "b6_mg": ,      "b12_mcg": ,      "folate_mcg": ,      "vitamin_a_mcg": 3,      "vitamin_c_mg": 4.6,      "vitamin_d_iu": ,      "vitamin_e_mg": ,      "vitamin_k_mcg": ,
      // Minerals      "calcium_mg": 5,      "copper_mg": ,      "iron_mg": 0.03,      "magnesium_mg": ,      "manganese_mg": ,      "phosphorus_mg": ,      "potassium_mg": 104,      "selenium_mcg": ,      "sodium_mg": 0,      "zinc_mg": ,
      // Carbohydrates      "fiber_g": 2.1,      "starch_g": ,      "sugar_g": 12.1,
      // Lipids aka Fats      "monounsaturated_g": ,      "polyunsaturated_g": ,      "omega_3_fatty_acids_g": 0.051,      "omega_6_fatty_acids_g": ,      "saturated_fats_g": 0,      "trans_fats_g": ,      "cholesterol_mg": 0,
      // Proteins      "cystine_g": ,      "histidine_g": ,      "isoleucine_g": ,      "leucine_g": ,      "lysine_g": ,      "methionine_g": ,      "phenylalanine_g": ,      "threonine_g": ,      "tryptophan_g": ,      "tyrosine_g": ,      "valine_g": ,
      // Other Details      "percent_fruit": 1, // Portion of item that is fruit from 0-1      "percent_vegetable": 0,  // Portion of item that is vegetable from 0-1      "percent_legume_or_nuts": 0, // Portion of item that is legume or nuts from 0-1      "is_beverage": false,      "source_urls": [        "https://fdc.nal.usda.gov/fdc-app.html#/food-details/2344711/nutrients"      ]    },    "alt_units": [      {        "unit": "cup",        "weight_in_grams": 125      },      {        "unit": "calorie",        "weight_in_grams": 1.6393      },      {        "unit": "g",        "weight_in_grams": 1      },      {        "unit": "whole",        "weight_in_grams": 200      },      {        "unit": "serving",        "weight_in_grams": 200      },    ],    "default_portion": {      "quantity": 1,      "unit": "whole"    },    "selected_portion": {      "quantity": 1,      "unit": "whole"    },    "selected_portion_nutrition": {      "mass_g": 200,      "calories_kcal": 122,      "carb_g": 29.6,      "fat_g": 0.3,      "protein_g": 0.34,
      // Detailed Nutrients, if available      // Same fields as above in nutrition_per_100_g      // "b1_mg": ,      // "b2_mg": ,      // ...    }  }}
  • Nutritional Value Not Found or Non Food Item:
{  "code": 200,  "success": false,  "data": null}
  • Error Response:

See Error Responses for how the API will signal malformed or failed requests.

Notes#

  • Replace name, brand, quantity, and unit in the sample request with actual values.
  • Ensure that requests are sent over HTTPS for security.
  • The API intelligently infers default values for quantity and unit when not provided.

Get Started#

Request an API Key