Quick Start
Go from zero to your first nutrition analysis in under a minute. Send natural language ingredients, get back structured nutrient data, diet labels, and confidence scores.
1. Get your API key
Sign up at nutrientapi.com to get a free API key. The free tier includes 100 recipes per month — no credit card required.
Your API key will look something like this:
sk_live_7a3b9f2e...
Keep your key secret. Do not expose it in client-side code or public repositories. Always make API calls from your server.
2. Make your first request
The API has a single endpoint: POST /v1/analyze. Send a recipe title, a list of ingredients in plain English, and the number of servings.
POST https://api.nutrientapi.com/v1/analyze
curl https://api.nutrientapi.com/v1/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Chicken and Rice Bowl",
"ingredients": [
"200g chicken breast",
"1 cup brown rice",
"1 tbsp olive oil",
"2 cups steamed broccoli"
],
"servings": 2
}'
That's it. The API parses each ingredient, matches it to a USDA food, converts the portion to grams, calculates 14 nutrients, and classifies the recipe with diet and health labels.
3. Understand the response
A successful response includes four main sections:
ingredients— per-ingredient breakdown with parsed quantities, matched USDA food, gram weights, confidence scores, and nutrientstotals— summed nutrients across all ingredients for the full recipeper_serving— nutrients divided by the serving countdiet_labelsandhealth_labels— automatic classifications like "high-protein", "gluten-free", etc.
Here is an abbreviated response:
{
"status": "success",
"ingredients": [
{
"text": "200g chicken breast",
"parsed": {
"qty": 200,
"unit": "g",
"food": "Chicken breast, raw",
"gram_weight": 200.0
},
"confidence": {
"match": 0.97,
"conversion": 1.0,
"overall": 0.97
},
"nutrients": {
"calories": 330.0,
"protein": 62.0,
"fat_total": 7.2,
"carbs_total": 0.0
// ... 14 nutrients total
}
}
// ... remaining ingredients
],
"totals": {
"calories": 857.0,
"protein": 76.4,
"fat_total": 24.2,
"carbs_total": 73.6
// ...
},
"per_serving": {
"calories": 428.5,
"protein": 38.2,
"fat_total": 12.1,
"carbs_total": 36.8
// ...
},
"diet_labels": ["high-protein"],
"health_labels": ["dairy-free", "gluten-free"]
}
Confidence scores tell you how reliable each ingredient's result is. A
match score of 0.97 means the AI is highly confident it found the right USDA food. A conversion score of 1.0 means the gram weight is exact (no estimation needed). See the API Reference for details.
4. Code examples
Python
import requests
response = requests.post(
"https://api.nutrientapi.com/v1/analyze",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"title": "Overnight Oats",
"ingredients": [
"1/2 cup rolled oats",
"1 cup whole milk",
"1 tbsp honey",
"1/4 cup blueberries",
],
"servings": 1,
},
)
data = response.json()
# Per-serving nutrients
print(f"Calories: {data['per_serving']['calories']} kcal")
print(f"Protein: {data['per_serving']['protein']} g")
print(f"Carbs: {data['per_serving']['carbs_total']} g")
print(f"Fat: {data['per_serving']['fat_total']} g")
# Labels
print(f"Diet: {data['diet_labels']}")
print(f"Health: {data['health_labels']}")
# Check confidence for each ingredient
for ing in data["ingredients"]:
score = ing["confidence"]["overall"]
if score < 0.8:
print(f"Low confidence for: {ing['text']} ({score})")
JavaScript (Node.js)
const response = await fetch("https://api.nutrientapi.com/v1/analyze", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
title: "Overnight Oats",
ingredients: [
"1/2 cup rolled oats",
"1 cup whole milk",
"1 tbsp honey",
"1/4 cup blueberries",
],
servings: 1,
}),
});
const data = await response.json();
// Per-serving nutrients
console.log(`Calories: ${data.per_serving.calories} kcal`);
console.log(`Protein: ${data.per_serving.protein} g`);
// Flag low-confidence ingredients for review
data.ingredients
.filter(ing => ing.confidence.overall < 0.8)
.forEach(ing => {
console.warn(`Review: ${ing.text} (confidence: ${ing.confidence.overall})`);
});
Ruby
require "net/http"
require "json"
require "uri"
uri = URI("https://api.nutrientapi.com/v1/analyze")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = {
title: "Overnight Oats",
ingredients: [
"1/2 cup rolled oats",
"1 cup whole milk",
"1 tbsp honey",
"1/4 cup blueberries",
],
servings: 1,
}.to_json
response = http.request(request)
data = JSON.parse(response.body)
# Per-serving nutrients
puts "Calories: #{data['per_serving']['calories']} kcal"
puts "Protein: #{data['per_serving']['protein']} g"
# Check for low confidence
data["ingredients"].each do |ing|
if ing["confidence"]["overall"] < 0.8
puts "Review: #{ing['text']} (#{ing['confidence']['overall']})"
end
end
Next steps
- API Reference — full request/response schema, all 14 nutrients, error codes, and rate limits
- Confidence Scores — understand match and conversion confidence to build reliable applications
- Labels — how diet and health label classification works