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
From 8,778 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 312ms | 324ms | 358ms | 734ms | 1037ms |
Similar APIs
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
queryrequiredQuery 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-KeyrequiredAPI Key associated with your account.
Response
A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.
caloriespremiumNutritional energy in calories.
serving_size_gServing size in grams.
fat_total_gTotal combined fat (including saturated and trans fats) in grams.
fat_saturated_gSaturated fat in grams.
protein_gpremiumProtein in grams.
sodium_mgSodium in milligrams.
potassium_mgPotassium in milligrams.
cholesterol_mgCholesterol in milligrams.
carbohydrates_total_gTotal carbohydrates (including fiber and sugar) in grams.
fiber_gFiber in grams.
sugar_gSugar in grams.
Sample Request Live Demo!
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 friesHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
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
queryrequiredA 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.quantityrequiredA 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-KeyrequiredAPI Key associated with your account.
Response
A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.
caloriespremiumNutritional energy in calories.
serving_size_gServing size in grams.
fat_total_gTotal combined fat (including saturated and trans fats) in grams.
fat_saturated_gSaturated fat in grams.
protein_gpremiumProtein in grams.
sodium_mgSodium in milligrams.
potassium_mgPotassium in milligrams.
cholesterol_mgCholesterol in milligrams.
carbohydrates_total_gTotal carbohydrates (including fiber and sugar) in grams.
fiber_gFiber in grams.
sugar_gSugar in grams.
Sample Request Live Demo!
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 lbsHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
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
Can I use the Nutrition API for commercial purposes?
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.How do I get an API key and start using the Nutrition API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
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.What happens if a request to the Nutrition API fails?
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.What is the difference between the /v1/nutrition and /v1/nutritionitem endpoints?
The/v1/nutritionendpoint 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/nutritionitemreturns nutrition for a single food item at a specificquantity. If you need full recipe text rather than just nutrition facts, see the Recipe API.How do I get nutrition data for a specific portion size?
With/v1/nutrition, just include the amount inside thequeryparameter (e.g. '1lb brisket and fries') and the algorithm automatically scales the result; otherwise each item defaults to100g. For precise control, use/v1/nutritionitemwith separatequeryandquantityparameters, wherequantitysupports units like '1 cup', '2 lbs', '100g', or '2 tbsp'; explore more health endpoints in the API catalog.What nutrition fields does the response include?
Each result object includescalories,serving_size_g,fat_total_g,fat_saturated_g,protein_g,sodium_mg,potassium_mg,cholesterol_mg,carbohydrates_total_g,fiber_g, andsugar_g. Note thatcaloriesandprotein_gare premium fields, so check the pricing page for plan details.What are some use cases for the Nutrition API?
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.