API Reference
Analyze Nutrients
Analyze the nutritional content of a list of ingredients.
POST
/
v1
/
nutrients
/
analyze
Analyze Nutrients
curl --request POST \
--url https://api.mrcook.app/v1/nutrients/analyze \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ingredients": [
"500 grams ground beef",
"4 slices bacon",
"4 slices cheddar cheese",
"4 hamburger buns"
],
"servings": "4 servings"
}
'import requests
url = "https://api.mrcook.app/v1/nutrients/analyze"
payload = {
"ingredients": ["500 grams ground beef", "4 slices bacon", "4 slices cheddar cheese", "4 hamburger buns"],
"servings": "4 servings"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ingredients: [
'500 grams ground beef',
'4 slices bacon',
'4 slices cheddar cheese',
'4 hamburger buns'
],
servings: '4 servings'
})
};
fetch('https://api.mrcook.app/v1/nutrients/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mrcook.app/v1/nutrients/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ingredients' => [
'500 grams ground beef',
'4 slices bacon',
'4 slices cheddar cheese',
'4 hamburger buns'
],
'servings' => '4 servings'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mrcook.app/v1/nutrients/analyze"
payload := strings.NewReader("{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mrcook.app/v1/nutrients/analyze")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mrcook.app/v1/nutrients/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"calories": 550,
"carbohydrates": 30.5,
"protein": 45.2,
"fat": 28.8,
"sugar": 5.1,
"confidence": 92
}
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key. Learn more: https://docs.mrcook.app/business-api/api-key"
}{
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient credits. Please purchase more credits: https://docs.mrcook.app/business-api/pricing"
}{
"code": "FORBIDDEN",
"message": "You don't have permission to access this resource."
}{
"code": "TOO_MANY_REQUESTS",
"message": "Rate limit exceeded. Please contact support if you need a higher limit."
}{
"code": "ANALYSIS_FAILED",
"message": "Nutrient analysis failed. Please try again later."
}Authorizations
How to get your API key: https://docs.mrcook.app/business-api/api-key
Body
application/json
An array of strings, where each string is one ingredient.
Minimum array length:
1Example:
[
"500 grams ground beef",
"4 slices bacon",
"4 slices cheddar cheese",
"4 hamburger buns"
]
The number of servings the ingredients are for (e.g., '4 servings'). Defaults to 1 if not specified.
Example:
"4 servings"
⌘I
Analyze Nutrients
curl --request POST \
--url https://api.mrcook.app/v1/nutrients/analyze \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ingredients": [
"500 grams ground beef",
"4 slices bacon",
"4 slices cheddar cheese",
"4 hamburger buns"
],
"servings": "4 servings"
}
'import requests
url = "https://api.mrcook.app/v1/nutrients/analyze"
payload = {
"ingredients": ["500 grams ground beef", "4 slices bacon", "4 slices cheddar cheese", "4 hamburger buns"],
"servings": "4 servings"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ingredients: [
'500 grams ground beef',
'4 slices bacon',
'4 slices cheddar cheese',
'4 hamburger buns'
],
servings: '4 servings'
})
};
fetch('https://api.mrcook.app/v1/nutrients/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mrcook.app/v1/nutrients/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ingredients' => [
'500 grams ground beef',
'4 slices bacon',
'4 slices cheddar cheese',
'4 hamburger buns'
],
'servings' => '4 servings'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mrcook.app/v1/nutrients/analyze"
payload := strings.NewReader("{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mrcook.app/v1/nutrients/analyze")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mrcook.app/v1/nutrients/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ingredients\": [\n \"500 grams ground beef\",\n \"4 slices bacon\",\n \"4 slices cheddar cheese\",\n \"4 hamburger buns\"\n ],\n \"servings\": \"4 servings\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"calories": 550,
"carbohydrates": 30.5,
"protein": 45.2,
"fat": 28.8,
"sugar": 5.1,
"confidence": 92
}
}{
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key. Learn more: https://docs.mrcook.app/business-api/api-key"
}{
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient credits. Please purchase more credits: https://docs.mrcook.app/business-api/pricing"
}{
"code": "FORBIDDEN",
"message": "You don't have permission to access this resource."
}{
"code": "TOO_MANY_REQUESTS",
"message": "Rate limit exceeded. Please contact support if you need a higher limit."
}{
"code": "ANALYSIS_FAILED",
"message": "Nutrient analysis failed. Please try again later."
}