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:
- /v1/nutrition - Extract nutrition information from freeform text
- /v1/nutritionitem - Get nutrition information for a single food item with a specific quantity
- /v1/nutritionbranded - Search branded/packaged foods by name, brand, or barcode
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
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
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.
fat_trans_gTrans 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.
added_sugars_gpremiumAdded sugars in grams.
net_carbs_gpremiumNet carbohydrates (total carbohydrates minus fiber) in grams.
iron_mgpremiumIron in milligrams.
calcium_mgpremiumCalcium in milligrams.
magnesium_mgpremiumMagnesium in milligrams.
zinc_mgpremiumZinc in milligrams.
vitamin_a_mcgpremiumVitamin A in micrograms (RAE).
vitamin_c_mgpremiumVitamin C in milligrams.
vitamin_d_mcgpremiumVitamin D in micrograms.
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.
fat_trans_gTrans 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.
added_sugars_gpremiumAdded sugars in grams.
net_carbs_gpremiumNet carbohydrates (total carbohydrates minus fiber) in grams.
iron_mgpremiumIron in milligrams.
calcium_mgpremiumCalcium in milligrams.
magnesium_mgpremiumMagnesium in milligrams.
zinc_mgpremiumZinc in milligrams.
vitamin_a_mcgpremiumVitamin A in micrograms (RAE).
vitamin_c_mgpremiumVitamin C in milligrams.
vitamin_d_mcgpremiumVitamin D in micrograms.
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"/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.
upcoptionalThe UPC/EAN barcode of a product for an exact lookup. Returns a single product.
nameoptionalProduct name to search for (e.g., "chocolate chip cookies"). Returns a ranked list of matching products.
brandoptionalBrand name to search for (e.g., "Oreo"). Can be combined with
nameto narrow results.limitoptionalMaximum number of results to return for a
nameorbrandsearch. Defaults to10, maximum50.offsetoptionalNumber of results to skip, for paging through a
nameorbrandsearch (e.g.,limit=50&offset=50for the next page). Defaults to0; paging is limited to the first1000matches.
Headers
X-Api-KeyrequiredAPI 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:
nameName/description of the product.
brandBrand owner or brand name.
barcodeGTIN/UPC barcode of the product.
categoryBranded food category.
serving_size_gServing size in grams (or milliliters) that the nutrition values are scaled to.
caloriesNutritional energy in calories.
protein_gProtein in grams.
fat_total_gTotal combined fat in grams.
fat_saturated_gSaturated fat in grams.
fat_trans_gTrans fat in grams.
carbohydrates_total_gTotal carbohydrates in grams.
fiber_gFiber in grams.
sugar_gSugar in grams.
added_sugars_gAdded sugars in grams.
net_carbs_gNet carbohydrates (total carbohydrates minus fiber) in grams.
sodium_mgSodium in milligrams.
potassium_mgPotassium in milligrams.
cholesterol_mgCholesterol in milligrams.
iron_mgIron in milligrams.
calcium_mgCalcium in milligrams.
vitamin_a_mcgVitamin A in micrograms (RAE).
vitamin_c_mgVitamin C in milligrams.
vitamin_d_mcgVitamin D in micrograms.
allergensArray of detected allergens (e.g., milk, egg, peanut, tree_nut, soy, wheat, fish, shellfish, sesame).
ingredientsFull ingredient statement from the product label.
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/nutritionbranded?name=oreoHeaders
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/nutritionbranded?name=oreo" \
-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.