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.

Available endpoints:

  • /v1/nutrition - Extract nutrition information from freeform text
  • /v1/nutritionitem - Get nutrition information for a single food item with a specific quantity
(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

Returns a list of nutrition information extracted from given text. Nutrition data for each food item is scaled to 100g unless a quantity is specified within the query parameter.

An intelligent feature of this endpoint is custom portioning - if the query text specifies quantities of individual food items or ingredients, the algorithm will automatically scale the nutrition data in the result accordingly.

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.

  • 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.

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,
      protein_g:132,
      sodium_mg:217,
      potassium_mg:781,
      cholesterol_mg:487,
      carbohydrates_total_g:0,
      fiber_g:0,
      sugar_g:0
    },
    {
      name:"fries",
      calories:317.7,
      serving_size_g:100,
      fat_total_g:14.8,
      fat_saturated_g:2.3,
      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
    }
]

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.

  • 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.

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,
    protein_g:215.3,
    sodium_mg:655,
    potassium_mg:1625,
    cholesterol_mg:835,
    carbohydrates_total_g:0.4,
    fiber_g:0,
    sugar_g: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"

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.