Nutrition API

TastyAPI is a nutrition API built around one advantage: speed. Send a food photo or a plain-text description and get a full nutritional breakdown — calories, macros, vitamins, minerals, allergens, and dietary flags — back as JSON in about a second. Fast enough to run inline while a user waits, not as a background job.

Speed is the feature

Nutrition data in about a second

The model does one thing — food — and runs on a low-latency inference stack, so a typical request comes back in about a second, not the 4–10 seconds a general-purpose multimodal model takes on the same input. That gap is the difference between analysis you can run while the user waits and analysis you have to queue.

In practice, ~1-second responses let you show nutrition the moment a meal is logged, keep an interactive form responsive, and run large backfills without per-call latency dominating throughput. The benchmarks page has the head-to-head numbers.

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.
  • Packaging and label workflows. Generate FDA Nutrition Facts panels from a formulation — see the free nutrition label generator for a working example built on this endpoint.
  • 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

How fast is it?

A typical call returns in about a second — fast enough to run inline in a user-facing flow. General-purpose vision models usually take 4–10 seconds for the same task; see the benchmarks.

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