NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

Nutrition API

The Nutrition API extracts nutrition information from text using natural language processing. From food blogs to menus to recipes, it can read any text and calculate the corresponding nutrition data. It is powered by a comprehensive database of foods.

Available endpoints:

(4.4)

From 8,778 users

2,000+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
312ms324ms358ms734ms1037ms

Didn't find what you were looking for? Suggest an improvement


/v1/nutrition GET

https://api.api-ninjas.com/v1/nutrition

This endpoint uses AI to automatically read any text and extract every food item it contains, along with the right portion for each. It can process multiple food items at once — simply copy and paste any text, such as a recipe or your food journal, directly, and it will return the nutrition data for every food item found. Items without a specified amount default to a 100g serving.

If this isn't what you're looking for and you'd prefer to input items traditionally — a single food item with a specific quantity to get the nutrition for just that item — use the /v1/nutritionitem endpoint instead.

Parameters

  • query  required

    Query text to extract nutrition information. If your query contains commas, make sure they are URL encoded properly (e.g., %2C) - otherwise the server will fail to receive the correct input.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.

  • calories premium

    Nutritional energy in calories.

  • serving_size_g

    Serving size in grams.

  • fat_total_g

    Total combined fat (including saturated and trans fats) in grams.

  • fat_saturated_g

    Saturated fat in grams.

  • fat_trans_g

    Trans fat in grams.

  • protein_g premium

    Protein in grams.

  • sodium_mg

    Sodium in milligrams.

  • potassium_mg

    Potassium in milligrams.

  • cholesterol_mg

    Cholesterol in milligrams.

  • carbohydrates_total_g

    Total carbohydrates (including fiber and sugar) in grams.

  • fiber_g

    Fiber in grams.

  • sugar_g

    Sugar in grams.

  • added_sugars_g premium

    Added sugars in grams.

  • net_carbs_g premium

    Net carbohydrates (total carbohydrates minus fiber) in grams.

  • iron_mg premium

    Iron in milligrams.

  • calcium_mg premium

    Calcium in milligrams.

  • magnesium_mg premium

    Magnesium in milligrams.

  • zinc_mg premium

    Zinc in milligrams.

  • vitamin_a_mcg premium

    Vitamin A in micrograms (RAE).

  • vitamin_c_mg premium

    Vitamin C in milligrams.

  • vitamin_d_mcg premium

    Vitamin D in micrograms.

Sample Request Live Demo!

query

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/nutrition?query=1lb brisket and fries

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      name:"brisket",
      calories:1312.3,
      serving_size_g:453.592,
      fat_total_g:82.9,
      fat_saturated_g:33.2,
      fat_trans_g:1.9,
      protein_g:132,
      sodium_mg:217,
      potassium_mg:781,
      cholesterol_mg:487,
      carbohydrates_total_g:0,
      fiber_g:0,
      sugar_g:0,
      added_sugars_g:0,
      net_carbs_g:0,
      iron_mg:11.2,
      calcium_mg:46.4,
      magnesium_mg:92.8,
      zinc_mg:18.9,
      vitamin_a_mcg:0,
      vitamin_c_mg:0,
      vitamin_d_mcg:0.5
    },
    {
      name:"fries",
      calories:317.7,
      serving_size_g:100,
      fat_total_g:14.8,
      fat_saturated_g:2.3,
      fat_trans_g:0.1,
      protein_g:3.4,
      sodium_mg:212,
      potassium_mg:124,
      cholesterol_mg:0,
      carbohydrates_total_g:41.1,
      fiber_g:3.8,
      sugar_g:0.3,
      added_sugars_g:0,
      net_carbs_g:37.3,
      iron_mg:0.9,
      calcium_mg:23.7,
      magnesium_mg:39.9,
      zinc_mg:0.5,
      vitamin_a_mcg:0,
      vitamin_c_mg:1.1,
      vitamin_d_mcg:0
    }
]

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/nutrition?query=1lb%20brisket%20and%20fries" \ -H "X-Api-Key: YOUR_API_KEY"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.


/v1/nutritionitem GET

https://api.api-ninjas.com/v1/nutritionitem

Returns nutrition information for a single food item with a specific quantity. This endpoint supports various units of measurements for the quantity parameter.

Parameters

  • query  required

    A single string containing the food item to be queried. If your query contains commas, make sure they are URL encoded properly (e.g., %2C) - otherwise the server will fail to receive the correct input.

  • quantity  required

    A string indicating the quantity of the item in question. Supports various units of measurements (e.g., "1 cup", "2 lbs", "100g", "2 tbsp").

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.

  • calories premium

    Nutritional energy in calories.

  • serving_size_g

    Serving size in grams.

  • fat_total_g

    Total combined fat (including saturated and trans fats) in grams.

  • fat_saturated_g

    Saturated fat in grams.

  • fat_trans_g

    Trans fat in grams.

  • protein_g premium

    Protein in grams.

  • sodium_mg

    Sodium in milligrams.

  • potassium_mg

    Potassium in milligrams.

  • cholesterol_mg

    Cholesterol in milligrams.

  • carbohydrates_total_g

    Total carbohydrates (including fiber and sugar) in grams.

  • fiber_g

    Fiber in grams.

  • sugar_g

    Sugar in grams.

  • added_sugars_g premium

    Added sugars in grams.

  • net_carbs_g premium

    Net carbohydrates (total carbohydrates minus fiber) in grams.

  • iron_mg premium

    Iron in milligrams.

  • calcium_mg premium

    Calcium in milligrams.

  • magnesium_mg premium

    Magnesium in milligrams.

  • zinc_mg premium

    Zinc in milligrams.

  • vitamin_a_mcg premium

    Vitamin A in micrograms (RAE).

  • vitamin_c_mg premium

    Vitamin C in milligrams.

  • vitamin_d_mcg premium

    Vitamin D in micrograms.

Sample Request Live Demo!

query
quantity

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/nutritionitem?query=chicken&quantity=2 lbs

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
{
    name:"chicken",
    calories:2019.8,
    serving_size_g:907.184,
    fat_total_g:117,
    fat_saturated_g:33.2,
    fat_trans_g:0.9,
    protein_g:215.3,
    sodium_mg:655,
    potassium_mg:1625,
    cholesterol_mg:835,
    carbohydrates_total_g:0.4,
    fiber_g:0,
    sugar_g:0,
    added_sugars_g:0,
    net_carbs_g:0.4,
    iron_mg:11.6,
    calcium_mg:84.7,
    magnesium_mg:296.6,
    zinc_mg:20.8,
    vitamin_a_mcg:0,
    vitamin_c_mg:0,
    vitamin_d_mcg:0
}

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/nutritionitem?query=chicken&quantity=2%20lbs" \ -H "X-Api-Key: YOUR_API_KEY"

/v1/nutritionbranded GET Business, Professional, or annual subscriptions only

https://api.api-ninjas.com/v1/nutritionbranded

Search branded and packaged foods by product name, brand, or UPC/EAN barcode to get nutrition information, allergens, and ingredients. This endpoint is powered by a comprehensive database of foods. A barcode lookup returns a single product; a name or brand search returns a ranked list of matching products.

Parameters

Provide at least one of upc, name, or brand.

  • upc  optional

    The UPC/EAN barcode of a product for an exact lookup. Returns a single product.

  • name  optional

    Product name to search for (e.g., "chocolate chip cookies"). Returns a ranked list of matching products.

  • brand  optional

    Brand name to search for (e.g., "Oreo"). Can be combined with name to narrow results.

  • limit  optional

    Maximum number of results to return for a name or brand search. Defaults to 10, maximum 50.

  • offset  optional

    Number of results to skip, for paging through a name or brand search (e.g., limit=50&offset=50 for the next page). Defaults to 0; paging is limited to the first 1000 matches.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON array containing the matching product (an empty array if no product matches the barcode), or an error if the request is unsuccessful. Nutrition values are scaled to the product's serving size. Each object contains the following fields:

  • name

    Name/description of the product.

  • brand

    Brand owner or brand name.

  • barcode

    GTIN/UPC barcode of the product.

  • category

    Branded food category.

  • serving_size_g

    Serving size in grams (or milliliters) that the nutrition values are scaled to.

  • calories

    Nutritional energy in calories.

  • protein_g

    Protein in grams.

  • fat_total_g

    Total combined fat in grams.

  • fat_saturated_g

    Saturated fat in grams.

  • fat_trans_g

    Trans fat in grams.

  • carbohydrates_total_g

    Total carbohydrates in grams.

  • fiber_g

    Fiber in grams.

  • sugar_g

    Sugar in grams.

  • added_sugars_g

    Added sugars in grams.

  • net_carbs_g

    Net carbohydrates (total carbohydrates minus fiber) in grams.

  • sodium_mg

    Sodium in milligrams.

  • potassium_mg

    Potassium in milligrams.

  • cholesterol_mg

    Cholesterol in milligrams.

  • iron_mg

    Iron in milligrams.

  • calcium_mg

    Calcium in milligrams.

  • vitamin_a_mcg

    Vitamin A in micrograms (RAE).

  • vitamin_c_mg

    Vitamin C in milligrams.

  • vitamin_d_mcg

    Vitamin D in micrograms.

  • allergens

    Array of detected allergens (e.g., milk, egg, peanut, tree_nut, soy, wheat, fish, shellfish, sesame).

  • ingredients

    Full ingredient statement from the product label.

Sample Request Live Demo!

name
brand
upc

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/nutritionbranded?name=oreo

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      name:"OREO CREAMY VANILLA ICE CREAM FLAVORED BLENDED WITH OREO COOKIE PIECES COATED WITH OREO COOKIE CRUMBS ICE CREAM ROLL, OREO COOKIE PIECES",
      brand:"OREO",
      barcode:"016264011102",
      category:"Ice Cream & Frozen Yogurt",
      serving_size_g:100,
      calories:270,
      protein_g:4,
      fat_total_g:13,
      fat_saturated_g:7,
      fat_trans_g:0,
      carbohydrates_total_g:34,
      fiber_g:1,
      sugar_g:22,
      added_sugars_g:null,
      net_carbs_g:33,
      sodium_mg:170,
      potassium_mg:null,
      cholesterol_mg:25,
      iron_mg:1.1,
      calcium_mg:150,
      vitamin_a_mcg:null,
      vitamin_c_mg:0,
      vitamin_d_mcg:null,
      allergens:[
        "milk",
        "soy",
        "wheat"
      ],
      ingredients:"MILKFAT AND NONFAT MILK, OREO COOKIE PIECES (UNBLEACHED ENRICHED FLOUR [WHEAT FLOUR, NIA..."
    },
    {
      name:"GOLDEN OREO CREAMY VANILLA FLAVORED ICE CREAM WITH GOLDEN OREO COOKIE PIECES TOPPED WITH WHIPPED ICING AND A GOLDEN OREO COOKIE PREMIUM ICE CREAM CAKE, GOLDEN OREO COOKIE PIECES",
      brand:"OREO",
      barcode:"016264127339",
      category:"Ice Cream & Frozen Yogurt",
      serving_size_g:75,
      calories:219.8,
      protein_g:2,
      fat_total_g:12,
      fat_saturated_g:8,
      fat_trans_g:0,
      carbohydrates_total_g:28,
      fiber_g:0,
      sugar_g:18,
      added_sugars_g:null,
      net_carbs_g:28,
      sodium_mg:114.8,
      potassium_mg:null,
      cholesterol_mg:20.2,
      iron_mg:0.4,
      calcium_mg:80.2,
      vitamin_a_mcg:null,
      vitamin_c_mg:0,
      vitamin_d_mcg:null,
      allergens:[
        "milk",
        "soy",
        "wheat"
      ],
      ingredients:"MILKFAT AND NONFAT MILK, SUGAR, GOLDEN OREO COOKIE PIECES (UNBLEACHED ENRICHED FLOUR (WH..."
    },
    {
      name:"OREO VANILLA PUDDING WITH OREO COOKIE PIECES, OREO",
      brand:"OREO",
      barcode:"633456342044",
      category:"Puddings & Custards",
      serving_size_g:99,
      calories:119.8,
      protein_g:2,
      fat_total_g:3,
      fat_saturated_g:1.5,
      fat_trans_g:0,
      carbohydrates_total_g:22,
      fiber_g:0,
      sugar_g:17,
      added_sugars_g:14,
      net_carbs_g:22,
      sodium_mg:95,
      potassium_mg:80.2,
      cholesterol_mg:5,
      iron_mg:0,
      calcium_mg:65.3,
      vitamin_a_mcg:null,
      vitamin_c_mg:null,
      vitamin_d_mcg:null,
      allergens:[
        "milk",
        "soy",
        "wheat"
      ],
      ingredients:"MILK, WATER, SUGAR, MODIFIED FOOD STARCH, LESS THAN 1% OF: NATURAL & ARTIFICIAL FLAVORS,..."
    },
    "..."
]

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/nutritionbranded?name=oreo" \ -H "X-Api-Key: YOUR_API_KEY"

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the Nutrition API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • The /v1/nutrition endpoint uses natural language processing to read freeform text (such as a menu, recipe, or food blog) and returns an array of nutrition objects for every food item it detects, while /v1/nutritionitem returns nutrition for a single food item at a specific quantity. If you need full recipe text rather than just nutrition facts, see the Recipe API.
  • With /v1/nutrition, just include the amount inside the query parameter (e.g. '1lb brisket and fries') and the algorithm automatically scales the result; otherwise each item defaults to 100g. For precise control, use /v1/nutritionitem with separate query and quantity parameters, where quantity supports units like '1 cup', '2 lbs', '100g', or '2 tbsp'; explore more health endpoints in the API catalog.
  • Each result object includes calories, serving_size_g, fat_total_g, fat_saturated_g, protein_g, sodium_mg, potassium_mg, cholesterol_mg, carbohydrates_total_g, fiber_g, and sugar_g. Note that calories and protein_g are premium fields, so check the pricing page for plan details.
  • Because it extracts nutrition data directly from freeform text, the API is ideal for analyzing restaurant menus, calculating nutrition for recipes, building diet-tracking and meal-planning apps, or auto-labeling food blog content. It pairs well with the Recipe API and the Calories Burned API for full diet and fitness tools.