Nutrition API

TastyAPI is a nutrition API that turns any food into a structured nutrition breakdown — calories, macronutrients, vitamins, minerals, allergens, and dietary flags. Send a plain-text description or a photo; get clean JSON back in about a second.

Two endpoints, one data model

Send food as text or as an image

Use POST /analyze-food when you already know the food — a logged meal, a menu item, a recipe line. Use POST /analyze-image when you only have a photo and need the dish identified first. Both return the same nutrition schema, so you can mix them in one product without branching your parsing code.

Quickstart

Authenticate with a bearer token and post a food description. Every plan starts with a 7-day free trial.

cURL
curl -X POST https://tastyapi.com/analyze-food \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: text/plain" \
  --data "grilled chicken salad, 2 cups"
Python
import requests

r = requests.post(
    "https://tastyapi.com/analyze-food",
    headers={"Authorization": "Bearer YOUR_API_KEY",
             "Content-Type": "text/plain"},
    data="grilled chicken salad, 2 cups",
)
food = r.json()["analysis"]
print(food["nutrients"]["calories"]["amount"],
      food["nutrients"]["protein"]["amount"])
200 OK
{
  "analysis": {
    "foodName": "Grilled Chicken Salad",
    "servingSize": { "amount": 250, "unit": "g" },
    "nutrients": {
      "calories": { "amount": 320, "unit": "kcal" },
      "protein": { "amount": 34, "unit": "g" },
      "carbohydrates": { "amount": 12, "unit": "g" },
      "fat": { "amount": 14, "unit": "g" }
    },
    "allergens": { "contains": [], "mayContain": [] },
    "dietaryInfo": { "isVegetarian": false, "isVegan": false, "isGlutenFree": true }
  },
  "language": "en"
}

Response fields

FieldTypeDescription
analysis.foodNamestringNormalized name of the identified food or dish.
analysis.servingSizeobjectamount and unit (g, ml, oz, cup) for the detected portion.
analysis.nutrientsobjectEach of calories, protein, carbohydrates, fat as an { amount, unit } pair, plus nested vitamins and minerals.
analysis.allergensobjectcontains and mayContain string arrays.
analysis.dietaryInfoobjectBooleans: isVegetarian, isVegan, isGlutenFree, isKosher, isHalal.
analysis.confidencenumberModel confidence, from 0 to 1.
languagestringLanguage of the response (set via the lang query parameter).

Image analysis adds an imageAnalysis object (quality and ambiguity signals). See the full schema in the API reference or the machine-readable OpenAPI spec.

What developers build with it

  • Calorie and macro trackers. Let users log a meal in words or a photo instead of searching a database and guessing portions by hand.
  • Food diaries and meal planners. Turn free-text entries like "two eggs and toast" into structured, summable nutrition.
  • Fitness and weight-management apps. Attach protein, fiber, and calorie totals to workouts and daily goals.
  • Restaurant and menu tools. Estimate nutrition for menu items or user-submitted dishes at scale.
  • Assistants and agents. Give an LLM a single tool that answers "what's in this?" — see the MCP server for a drop-in integration.

Coverage and accuracy

The model is specialized for food — trained on tens of millions of food images and reference nutrition data rather than adapted from a general-purpose model. It handles prepared meals, packaged products, and raw ingredients, estimates portion size from context, and responds in 8 languages.

Values are calibrated estimates, typically within 10–15% of laboratory analysis, and are meant for tracking and informational use — not clinical diagnosis. When a portion is ambiguous, include a quantity in the request (for example, "2 cups") to tighten the estimate.

Authentication and limits

Pass your key as a bearer token on every request. Usage counts against your plan's monthly quota; on an auth or quota problem the API returns a 4xx with a JSON error body so you can surface it cleanly.

Error response
{ "error": "Invalid or expired token" }
  • 401 — API key invalid, expired, or over its usage limit.
  • 402 — no API key supplied, or the subscription needs payment (the body includes checkout details).
  • 400 — missing or malformed input.

Quotas by plan are listed on the pricing page; the full request and response reference lives in the API docs.

Frequently asked

Do I need an image?

No. /analyze-food works from a text description alone. Use image recognition only when you start from a photo.

What format does it return?

JSON over HTTPS, with a stable schema across both endpoints. Browse the nutrition database for live examples of the output.

Can I use it for packaged products?

Yes — describe the item or photograph the plate. For exact label values on a specific SKU, treat the response as a close estimate.

Build with the Nutrition API

Get a key and make your first call in minutes. 7-day free trial on every plan.

Get an API key