Skip to main content
Analyze Nutrition Facts Label
curl --request POST \
  --url https://app-api.spikeapi.com/v3/nutrition_records/ingredients/label \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "analysis_mode": "precise",
  "body": "<string>",
  "body_url": "<string>"
}
'
import requests

url = "https://app-api.spikeapi.com/v3/nutrition_records/ingredients/label"

payload = {
    "analysis_mode": "precise",
    "body": "<string>",
    "body_url": "<string>"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    analysis_mode: 'precise',
    body: JSON.stringify('<string>'),
    body_url: '<string>'
  })
};

fetch('https://app-api.spikeapi.com/v3/nutrition_records/ingredients/label', 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://app-api.spikeapi.com/v3/nutrition_records/ingredients/label",
  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([
    'analysis_mode' => 'precise',
    'body' => '<string>',
    'body_url' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$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://app-api.spikeapi.com/v3/nutrition_records/ingredients/label"

	payload := strings.NewReader("{\n  \"analysis_mode\": \"precise\",\n  \"body\": \"<string>\",\n  \"body_url\": \"<string>\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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://app-api.spikeapi.com/v3/nutrition_records/ingredients/label")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"analysis_mode\": \"precise\",\n  \"body\": \"<string>\",\n  \"body_url\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://app-api.spikeapi.com/v3/nutrition_records/ingredients/label")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"analysis_mode\": \"precise\",\n  \"body\": \"<string>\",\n  \"body_url\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "name": "<string>",
  "serving_size": 1.01,
  "failure_reason": "<string>",
  "nutritional_fields": {
    "calcium_mg": 123,
    "carbohydrate_g": 123,
    "cholesterol_mg": 123,
    "energy_kcal": 123,
    "fat_monounsaturated_g": 123,
    "fat_polyunsaturated_g": 123,
    "fat_saturated_g": 123,
    "fat_total_g": 123,
    "fat_trans_g": 123,
    "fiber_total_dietary_g": 123,
    "folate_mcg": 123,
    "iron_mg": 123,
    "magnesium_mg": 123,
    "manganese_mcg": 123,
    "niacin_mg": 123,
    "phosphorus_mg": 123,
    "potassium_mg": 123,
    "protein_g": 123,
    "riboflavin_mg": 123,
    "salt_g": 123,
    "salt_mg": 123,
    "sodium_g": 123,
    "sodium_mg": 123,
    "sugars_total_g": 123,
    "thiamin_mg": 123,
    "vitamin_a_rae_mcg": 123,
    "vitamin_b12_mcg": 123,
    "vitamin_b6_mg": 123,
    "vitamin_c_mg": 123,
    "vitamin_d_mcg": 123,
    "vitamin_e_mg": 123,
    "vitamin_k_mcg": 123,
    "zinc_mg": 123
  }
}
{
  "detail": "<string>",
  "errors": [
    {
      "location": "<string>",
      "message": "<string>",
      "value": "<unknown>"
    }
  ],
  "instance": "<string>",
  "status": 123,
  "title": "<string>",
  "type": "about:blank"
}
{
  "detail": "<string>",
  "errors": [
    {
      "location": "<string>",
      "message": "<string>",
      "value": "<unknown>"
    }
  ],
  "instance": "<string>",
  "status": 123,
  "title": "<string>",
  "type": "about:blank"
}
{
  "detail": "<string>",
  "errors": [
    {
      "location": "<string>",
      "message": "<string>",
      "value": "<unknown>"
    }
  ],
  "instance": "<string>",
  "status": 123,
  "title": "<string>",
  "type": "about:blank"
}
{
  "detail": "<string>",
  "errors": [
    {
      "location": "<string>",
      "message": "<string>",
      "value": "<unknown>"
    }
  ],
  "instance": "<string>",
  "status": 123,
  "title": "<string>",
  "type": "about:blank"
}
{
  "detail": "<string>",
  "errors": [
    {
      "location": "<string>",
      "message": "<string>",
      "value": "<unknown>"
    }
  ],
  "instance": "<string>",
  "status": 123,
  "title": "<string>",
  "type": "about:blank"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
analysis_mode
enum<string>
default:precise

A preferred mode for the analysis

Available options:
fast,
precise
body
string

Base64-encoded binary data, this or 'body_url' is required

body_url
string

URL to the image, this or 'body' is required

Response

OK

name
string
required

Detected ingredient name

Example:

"beef and broccoli stir-fry"

serving_size
number<double>
required

Serving size in metric units

Required range: x >= 0.01
Example:

120

unit
enum<string>
required

Metric unit (g for solids, ml for liquids)

Available options:
g,
mg,
mcg,
ml,
kcal
Example:

"g"

failure_reason
string
read-only

Reason for processing failure

Example:

"Unable to identify label"

nutritional_fields
object

Nutritional values in the given serving size

status
enum<string>
read-only

Processing status

Available options:
completed,
failed
Example:

"completed"