Helenis API
Start for free

API reference

Nutrition Analysis API

Calories, macros and 24 nutrients of any meal, from words in any language or a photo. USDA data.

Host
nutrition-analysis-calories-macros-from-text.p.rapidapi.com
Base path
/v1/nutrition
Auth
X-RapidAPI-Key, X-RapidAPI-Host
For agents
openapi.json · nutrition.md

Meal Analysis

A meal in words or a photo, to calories, macros and micronutrients.

Analyze Meal Text

POST /v1/nutrition/analyze

Calories, macros and micronutrients of a meal described in words. Get calories and nutrients of a meal described in words, any language ('2 eggs and toast with butter'): each food's grams, USDA match and nutrients, then totals. Values come from USDA FoodData Central; unknown foods go to `unmatched`. 10 credits up to 5 foods, +2 per extra food.

Parameters of Analyze Meal Text
ParameterInTypeDescription
text required body string What was eaten, in any language and in plain words: '2 eggs and a slice of toast with butter', '200 g de riz et un yaourt'. Weights, volumes, household measures and counts are understood.
curl -X POST "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/analyze" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "2 eggs fried in butter, a slice of toast and a glass of orange juice"
  }'

Analyze Meal Photo

POST /v1/nutrition/analyze/photo

Calories and macros of a meal photo, from its URL. The foods and portions on a meal photo, estimated by vision, then matched to USDA foods for calories, macros and micronutrients. Portions from a photo are estimates: add a `description` to help. 15 credits for up to 5 foods, +2 per extra food.

Parameters of Analyze Meal Photo
ParameterInTypeDescription
url required body string Direct link to a photo of the meal: JPEG, PNG, WEBP, HEIC, GIF, BMP or TIFF, up to 20 MB.
description body string Optional hint about the meal (e.g. 'chicken curry, about 300 g'): helps name dishes and portions the photo cannot show.
curl -X POST "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/analyze/photo" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Full_English_breakfast_-_London%2C_UK.jpg/1280px-Full_English_breakfast_-_London%2C_UK.jpg"
  }'

Analyze Uploaded Meal Photo

POST /v1/nutrition/analyze/photo/upload

Calories and macros of an uploaded meal photo. Same as Analyze Meal Photo, for a file sent as multipart/form-data (field `file`). 15 credits for up to 5 foods, +2 per extra food.

Parameters of Analyze Uploaded Meal Photo
ParameterInTypeDescription
file required form file Photo, up to 20 MB.
description form string Optional hint about the meal (e.g. 'chicken curry, about 300 g'): helps name dishes and portions the photo cannot show.
curl -X POST "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/analyze/photo/upload" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com" \
  -F "file=@./my-file"

Food Database

USDA foods: search, nutrients per 100 g and household portions. No AI.

Search Foods

GET /v1/nutrition/foods/search

Search USDA foods by name: nutrients per 100 g and portions. Over 13,000 USDA foods (Foundation, SR Legacy and FNDDS), best match first, each with 24 nutrients per 100 g and its household portions (1 cup, 1 slice, 1 large...). No AI. 1 credit.

Parameters of Search Foods
ParameterInTypeDescription
q required query string Food name in English, e.g. 'greek yogurt', 'chicken breast grilled', 'big mac'.
limit query integer Foods to return, 1-50. Default 10.
dataset query "foundation" | "sr_legacy" | "fndds" Only one USDA dataset: foundation (analysed ingredients), sr_legacy (reference foods, fast foods) or fndds (foods as eaten).
curl -G "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/foods/search" \
  --data-urlencode "q=greek yogurt" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com"

Get Food Nutrients

GET /v1/nutrition/foods/{fdc_id}

One USDA food by FDC id, for 100 g or any amount. Nutrients per 100 g, household portions, and optionally the nutrients of `grams`. 404 `food_not_found` (not billed) for an unknown id. 1 credit.

Parameters of Get Food Nutrients
ParameterInTypeDescription
fdc_id required path integer USDA FDC id.
grams query number Also give the nutrients of this many grams.
curl -G "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/foods/{fdc_id}" \
  --data-urlencode "grams=150" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com"

Barcode

Packaged food by barcode, from Open Food Facts. No AI.

Get Product by Barcode

GET /v1/nutrition/barcode

Packaged food by EAN/UPC barcode: nutrition, Nutri-Score, allergens. Name, brand, quantity, serving size, nutrients per 100 g (or 100 ml) and per serving, Nutri-Score, NOVA group, allergens, traces and ingredients, from Open Food Facts (ODbL: credit it when you show the data). 404 `product_not_found` (not billed) for an unknown barcode. 1 credit.

Parameters of Get Product by Barcode
ParameterInTypeDescription
code required query string EAN-13, EAN-8, UPC-A or GTIN-14 digits.
curl -G "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/barcode" \
  --data-urlencode "code=3017624010701" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com"

Response

{
  "language": "en",
  "items": [
    {
      "input": "2 eggs fried in butter",
      "name": "egg, fried in butter",
      "quantity": 2.0,
      "unit": "egg",
      "grams": 110.0,
      "grams_source": "portion",
      "portion": { "label": "1 egg", "grams": 55.0 },
      "match": {
        "fdc_id": 2707159,
        "description": "Egg, whole, fried with butter",
        "dataset": "fndds",
        "category": "Eggs and omelets"
      },
      "nutrients": {
        "calories_kcal": 200.0,
        "protein_g": 12.8,
        "fat_g": 16.1,
        "saturated_fat_g": 6.6,
        "carbs_g": 0.99,
        "fiber_g": 0.0,
        "sugar_g": 0.24,
        "cholesterol_mg": 438.0,
        "sodium_mg": 289.0,
        "calcium_mg": 50.6,
        "iron_mg": 1.7,
        "vitamin_d_ug": 2.6,
        "vitamin_b12_ug": 0.84,
        "...": "..."
      }
    },
    {
      "input": "a slice of toast",
      "name": "bread, toasted",
      "quantity": 1.0,
      "unit": "slice",
      "grams": 25.0,
      "grams_source": "portion",
      "portion": { "label": "1 medium or regular slice", "grams": 25.0 },
      "match": { "fdc_id": 2707599, "description": "Bread, white, toasted", "dataset": "fndds", "category": "Yeast breads" },
      "nutrients": { "calories_kcal": 73.2, "protein_g": 2.6, "fat_g": 0.98, "carbs_g": 13.5, "...": "..." }
    },
    {
      "input": "a glass of orange juice",
      "name": "orange juice",
      "quantity": 1.0,
      "unit": "glass",
      "grams": 248.0,
      "grams_source": "estimated",
      "match": { "fdc_id": 2709186, "description": "Orange juice, 100%, NFS", "dataset": "fndds", "category": "Citrus juice" },
      "nutrients": { "calories_kcal": 117.0, "protein_g": 1.9, "carbs_g": 25.3, "vitamin_c_mg": 71.2, "...": "..." }
    }
  ],
  "unmatched": [],
  "totals": {
    "calories_kcal": 390.0,
    "protein_g": 17.3,
    "fat_g": 17.9,
    "carbs_g": 39.8,
    "fiber_g": 1.4,
    "sugar_g": 22.0,
    "sodium_mg": 418.0,
    "vitamin_c_mg": 71.2,
    "...": "..."
  },
  "incomplete": [],
  "macros": { "protein_pct": 17.8, "carbs_pct": 40.9, "fat_pct": 41.4 },
  "total_grams": 383.0,
  "source": "USDA FoodData Central (public domain)",
  "note": "Estimates for information only, not medical or dietary advice. Nutrient values come from USDA FoodData Central; quantities given without a weight are estimated."
}

From a real response, shortened (each food and the totals carry all 24 nutrients). grams_source tells you where the grams came from: stated (a weight or volume you gave, volumes converted with USDA densities), portion (your count times a USDA household portion) or estimated (an ordinary portion: the AI's estimate, or the usual local size, such as a 125 g yogurt pot in a French text instead of USDA's 4 oz). assumption says which portion was assumed whenever you gave no weight or volume.

Why developers pick this API

  • 🧠 AI that reads, a database that counts: the AI only splits the meal and reads the amounts. Nutrients come from USDA tables, and a food USDA does not know is listed in unmatched instead of being guessed.
  • 🌍 Any language, any kitchen: French, Spanish, German, Italian, Portuguese, Japanese... Regional dishes USDA lacks (Schnitzel, muesli, carbonara) are counted through their ingredients.
  • 💸 Priced to log every meal: a meal from $0.006 and a lookup or barcode from $0.0006 on PRO, where AI calorie APIs charge $0.01 to $0.0125 a photo and barcode APIs $0.004 to $0.02. Failed calls (4xx, 5xx) use 0 credits.
  • ⚡ Fast: 2 to 4 seconds for a meal, milliseconds for a lookup.

Dishes USDA does not know

USDA is a U.S. database: a dish it lacks is counted through its ingredients, flagged with part_of. "Un piatto di spaghetti alla carbonara" comes back as cooked pasta, pork jowl, egg and romano cheese, each with part_of: "spaghetti carbonara"; "Müsli" as rolled oats, nuts and dried fruit. A food with no credible USDA match goes to unmatched with its estimated grams, and stays out of the totals.

Food search and lookup (no AI)

curl "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/foods/search?q=greek%20yogurt&limit=5" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com"

Each food comes with its 24 nutrients per 100 g and its household portions (1 container, 150 g, 1 cup, 245 g). GET /foods/{fdc_id}?grams=110 gives one food, plus the nutrients of the amount you ask for. Search is in English, in USDA's words ("egg fried", "bread whole wheat").

Barcode

curl "https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition/barcode?code=3017624010701" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" -H "X-RapidAPI-Host: nutrition-analysis-calories-macros-from-text.p.rapidapi.com"
{
  "barcode": "3017624010701",
  "name": "Nutella",
  "brand": "Ferrero",
  "quantity": "400.0 g",
  "categories": ["breakfasts", "spreads", "sweet spreads", "hazelnut spreads", "chocolate spreads", "cocoa and hazelnuts spreads"],
  "ingredients": "sugar, palm oil, hazelnuts (13%), skimmed milk powder (8.7%), fat reduced cocoa (7.4%), emulsifier: lecithins (soya), vanillin",
  "allergens": ["nuts"],
  "traces": ["milk", "nuts", "soybeans"],
  "nutriscore": "e",
  "has_nutrition": true,
  "per": "100g",
  "per_100": { "calories_kcal": 539.0, "protein_g": 6.3, "fat_g": 30.9, "saturated_fat_g": 10.6, "carbs_g": 57.5, "sugar_g": 56.3, "sodium_mg": 43.0 },
  "salt_g_per_100": 0.11,
  "image_url": "https://images.openfoodfacts.org/images/products/301/762/401/0701/front_en.100.400.jpg",
  "url": "https://world.openfoodfacts.org/product/3017624010701",
  "source": "Open Food Facts (openfoodfacts.org), ODbL 1.0"
}

From a real response. Barcode data comes from Open Food Facts under the Open Database License: when you show it, credit Open Food Facts (the source field says so).

Errors

Status code Meaning
400 invalid_request Missing or empty text, text over 2,000 characters, bad parameter.
400 plan_limit The free BASIC plan takes meals of up to 300 characters. Not billed.
400 unsupported_file / file_too_large The photo is not an image, or is over 20 MB.
400 invalid_barcode A barcode is 8 to 14 digits.
404 food_not_found / product_not_found Unknown FDC id or barcode. Not billed.
429 daily_limit_reached Daily safety limit of your plan; resets at 00:00 UTC.
503 ai_error / source_unavailable The AI provider or Open Food Facts did not answer; retry. Not billed.

See the plans Error handling