CalorieNinjas Is Migrating To API Ninjas

CalorieNinjas is being turned down this year, but don't worry! You can find our Nutrition and Recipe APIs are API Ninjas, which contains a massive collection of over 80 different APIs.

API Documentation

To use the CalorieNinjas API, you need to sign up for a free account and get an API key.

/v1/nutrition

HTTP GET

Get a detailed list of nutrition information for each item from an input text query.

Parameters

query (required) - a string containing food or drink items. If you wish to calculate a specific quantity, you may prefix a quantity before an item. For example, 3 tomatoes or 1lb beef brisket. If no quantity is specified, the default quantity is 100 grams. Queries cannot exceed 1500 characters.

Headers

X-Api-Key (required) - API Key associated with your account.

Sample Request URL

Live Demo!

https://api.calorieninjas.com/v1/nutrition?query=   
Sample Response
{
  "items": [
    {
      "sugar_g": 13.3,
      "fiber_g": 4,
      "serving_size_g": 283.495,
      "sodium_mg": 8,
      "name": "onion",
      "potassium_mg": 99,
      "fat_saturated_g": 0.1,
      "fat_total_g": 0.5,
      "calories": 126.7,
      "cholesterol_mg": 0,
      "protein_g": 3.9,
      "carbohydrates_total_g": 28.6
    },
    {
      "sugar_g": 2.6,
      "fiber_g": 1.2,
      "serving_size_g": 100,
      "sodium_mg": 4,
      "name": "tomato",
      "potassium_mg": 23,
      "fat_saturated_g": 0,
      "fat_total_g": 0.2,
      "calories": 18.2,
      "cholesterol_mg": 0,
      "protein_g": 0.9,
      "carbohydrates_total_g": 3.9
    }
  ]
}
import requests

api_url = 'https://api.calorieninjas.com/v1/nutrition?query='
query = '3lb carrots and a chicken sandwich'
response = requests.get(api_url + query, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
    print(response.text)
else:
    print("Error:", response.status_code, response.text)
var query = '3lb carrots and a chicken sandwich'
$.ajax({
    method: 'GET',
    url: 'https://api.calorieninjas.com/v1/nutrition?query=' + query,
    headers: { 'X-Api-Key': 'YOUR_API_KEY'},
    contentType: 'application/json',
    success: function(result) {
        console.log(result);
    },
    error: function ajaxError(jqXHR) {
        console.error('Error: ', jqXHR.responseText);
    }
});
const request = require('request');
var query = '3lb carrots and a chicken sandwich';
request.get({
  url: 'https://api.calorieninjas.com/v1/nutrition?query='+query,
  headers: {
    'X-Api-Key': 'YOUR_API_KEY'
  },
}, function(error, response, body) {
  if(error) return console.error('Request failed:', error);
  else if(response.statusCode != 200) return console.error('Error:', response.statusCode, body.toString('utf8'));
  else console.log(body)
});
String query = '3lb carrots and a chicken sandwich';
Response response = Request.Get("https://api.calorieninjas.com/v1/nutrition?query="+query)
.addHeader("X-Api-Key", "YOUR_API_KEY")
.execute();
let query = "3lb carrots and a chicken sandwich".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: "https://api.calorieninjas.com/v1/nutrition?query="+query!)!
var request = URLRequest(url: url)
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-Api-Key")
let task = URLSession.shared.dataTask(with: request) {(data, response, error) in
    guard let data = data else { return }
    print(String(data: data, encoding: .utf8)!)
}
task.resume()
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *query = @"https://api.calorieninjas.com/v1/nutrition?query=3lb carrots and a chicken sandwich";
NSString* encodedQuery = [query stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
[request setHTTPMethod:@"GET"];
[request setURL:[NSURL URLWithString:encodedQuery]];
[request setValue:@"YOUR_API_KEY" forHTTPHeaderField:@"X-Api-Key"];
NSError *error = nil;
NSHTTPURLResponse *responseCode = nil;

NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseCode error:&error];
NSLog([[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding]);
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/imagetextnutrition

HTTP POST

Get a detailed list of nutrition information scanned from an image containing food/beverage text. Example use cases include menus, recipes, and food journal entries.

Headers

X-Api-Key (required) - API Key associated with your account.

Sample Request URL

Live Demo!

https://calorieninjas.com/v1/imagetextnutrition
Sample Response
Code Example
import requests

api_url = 'https://api.calorieninjas.com/v1/imagetextnutrition'
image_file_descriptor = open('yourimage.jpeg', 'rb')
files = {'media': image_file_descriptor}
r = requests.post(api_url, files=files)
print r.json()
var formData = new FormData();
formData.append('file', $('#imagefile')[0].files[0]);
$.ajax({
    method: 'POST',
    url: 'https://api.calorieninjas.com/v1/imagetextnutrition',
    data: formData,
    enctype: 'multipart/form-data',
    processData: false,
    contentType: false, 
    success: function(result) {
        console.log(result);
    },
    error: function ajaxError(jqXHR, textStatus, errorThrown) {
        alert(jqXHR.responseText);
    }
});
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/recipe

HTTP GET

Get a list of up to 10 recipes matching the search query.

Parameters

query (required) - a string containing a dish name. Partial match is supported (e.g., risotto will match mushroom risotto).

Headers

X-Api-Key (required) - API Key associated with your account.

Sample Request URL

Live Demo!

https://api.calorieninjas.com/v1/recipe?query=   
Sample Response
[
  {
    "title": "Champagne Mushroom Risotto",
    "ingredients": "3 tb Butter or margarine|1 c Converted rice|2/3 c Onion; chopped|1 3/4 c Water|3/4 c Champagne or dry white wine|1 cn Cream of mushroom soup|1/4 ts Fresh ground pepper|1/8 ts Ground nutmeg|1/8 ts Ground red pepper(optional)|1 c Red bell pepper; julienne|Fresh parsley; finely chop|Parmesan cheese (optional)",
    "servings": "6 Servings",
    "instructions": "Melt butter in medium saucepan. Add rice and onion. Cook over medium heat, stirring frequently, 3-4 minutes or until onion is tender. Add water and champagne. Bring to a boil. Reduce heat, cover and simmer 20 minutes. Stir in cream of mushroom soup, pepper, nutmeg, and, if desired, ground red pepper. Cook and stir 5 minutes, or until creamy and heated through. Stir in red bell pepper and parsley. Sprinkle with cheese, if desired."
  },
  {
    "title": "Red Wine and Mushroom Risotto",
    "ingredients": "1 oz Porcini mushrooms; dried|2 c Boiling water|1 1/2 lb Mushrooms; cremini or white|6 tb Unsalted butter|5 1/2 c Chicken broth|6 oz Pancetta; 1/4 inch thick|1 c Onion; chopped fine|1 tb Fresh rosemary; chopped fine|1 tb Fresh sage; chopped fine|3 c Arborio rice|2 c Dry red wine; * see note|3 tb Fresh parsley; chopped fine|1 c Parmesan cheese; freshly|Grated|Garnishes|Parmesan curls|Fresh rosemary sprigs",
    "servings": "6 Servings",
    "instructions": "In a small bowl, soak porcini in boiling water 30 minutes. Pour soaking liq through a fine sieve lined with a dampened paper towel or coffee filter int bowl and reserve. Wash porcini under cold water to remove any grit and pat Chop porcini fine. Chop fine 1/4 pound cremini or white mushrooms (about 1-1/2 cuos) and reser Depending on size, halve and/or quarter remaining 1-1/4 pounds cremini or w mushrooms, and in a large heavy skillet cook in 4 tablespoons butter with s and pepper to taste over moderate heat, stirring, until tender, 5 to 10 min Remove skillet from heat and reserve mushrooms in skillet. (They will be re just before serving.) On a large sauce pan heat broth and keep at a bare simmer. In a 5- to 6-quart heavy saucepan, cook pancetta over moderate heat, stirri minutes. Add reserved finely chopped cremini or white mushrooms, remaining tablespoons butter, onion, rosemary, sage, and salt and pepper to taste and stirring until onion is softened. Stir in rice and cook, stirring, until co well with fat, about 1 minute. Add 1 cuop wine and cook, stirring constantl until absorbed. Add remaining cup wine and cook, stirring constantly, until absorbed. Add 1 cup simmering broth and cook, stirring constantly, until absorbed. Co cooking and adding broth, 1/2 cup at a time, stirring constantly and lettin each addition be absorbed before adding next, until rice is tender and creamy-looking but still al dente, 20 to 25 minutes. About half way through cooking, add reserved porcini soaking liquid and cho porcini, stirring constantly until liquid is absorbed, and continue cooking adding broth in same manner. During last few minutes of cooking, reheat reserved cremini or white mushro skillet over moderate heat, stirring, until hot, and stir in parsley and sa pepper to taste. Stir grated Parmesan and salt and pepper to taste into ris Serve risotto immediately, topped with cremini or white mushrooms and garni with Parmesan curls and rosemary sprigs. Serves 6."
  }
]
import requests

api_url = 'https://api.calorieninjas.com/v1/recipe?query='
query = 'mushroom risotto'
response = requests.get(api_url + query, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
    print(response.text)
else:
    print("Error:", response.status_code, response.text)
var query = 'mushroom risotto'
$.ajax({
    method: 'GET',
    url: 'https://api.calorieninjas.com/v1/recipe?query=' + query,
    headers: { 'X-Api-Key': 'YOUR_API_KEY'},
    contentType: 'application/json',
    success: function(result) {
        console.log(result);
    },
    error: function ajaxError(jqXHR) {
        console.error('Error: ', jqXHR.responseText);
    }
});
const request = require('request');
var query = 'mushroom risotto';
request.get({
  url: 'https://api.calorieninjas.com/v1/recipe?query='+query,
  headers: {
    'X-Api-Key': 'YOUR_API_KEY'
  },
}, function(error, response, body) {
  if(error) return console.error('Request failed:', error);
  else if(response.statusCode != 200) return console.error('Error:', response.statusCode, body.toString('utf8'));
  else console.log(body)
});
String query = 'mushroom risotto';
Response response = Request.Get("https://api.calorieninjas.com/v1/recipe?query="+query)
.addHeader("X-Api-Key", "YOUR_API_KEY")
.execute();
let query = "mushroom risotto".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: "https://api.calorieninjas.com/v1/recipe?query="+query!)!
var request = URLRequest(url: url)
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-Api-Key")
let task = URLSession.shared.dataTask(with: request) {(data, response, error) in
    guard let data = data else { return }
    print(String(data: data, encoding: .utf8)!)
}
task.resume()
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *query = @"https://api.calorieninjas.com/v1/recipe?query=mushroom risotto";
NSString* encodedQuery = [query stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
[request setHTTPMethod:@"GET"];
[request setURL:[NSURL URLWithString:encodedQuery]];
[request setValue:@"YOUR_API_KEY" forHTTPHeaderField:@"X-Api-Key"];
NSError *error = nil;
NSHTTPURLResponse *responseCode = nil;

NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseCode error:&error];
NSLog([[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding]);
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.