# Nutrition Analysis API

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

**Food logging without a food picker.** Your users write the meal the way they would say it, in their own language: *"2 eggs and a slice of toast with butter"*, *"200 g de riz et un yaourt"*, *"zwei Brötchen mit Nutella"*. Or they snap a photo. The API returns each **food**, its **grams**, its **calories**, **macros** and **micronutrients**, and the **totals** of the meal. Every value comes from **USDA FoodData Central**, never from the AI's imagination. From **$0.006 a meal** and **$0.0006 a lookup**.

- Host: `nutrition-analysis-calories-macros-from-text.p.rapidapi.com`
- Base URL: `https://nutrition-analysis-calories-macros-from-text.p.rapidapi.com/v1/nutrition`
- Auth: headers `X-RapidAPI-Key` and `X-RapidAPI-Host`
- OpenAPI: https://helenis-api.com/docs/nutrition/openapi.json

## Endpoints

### 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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `text` | body | `string` | yes | 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. | `2 eggs fried in butter, a slice of toast and a glass of orange juice` |

```bash
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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `url` | body | `string` | yes | Direct link to a photo of the meal: JPEG, PNG, WEBP, HEIC, GIF, BMP or TIFF, up to 20 MB. | `https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Full_English_breakf...` |
| `description` | body | `string` | no | Optional hint about the meal (e.g. 'chicken curry, about 300 g'): helps name dishes and portions the photo cannot show. |  |

```bash
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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `file` | form | `file` | yes | Photo, up to 20 MB. |  |
| `description` | form | `string` | no | Optional hint about the meal (e.g. 'chicken curry, about 300 g'): helps name dishes and portions the photo cannot show. |  |

```bash
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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `q` | query | `string` | yes | Food name in English, e.g. 'greek yogurt', 'chicken breast grilled', 'big mac'. | `greek yogurt` |
| `limit` | query | `integer` | no | Foods to return, 1-50. Default `10`. |  |
| `dataset` | query | `"foundation" \| "sr_legacy" \| "fndds"` | no | Only one USDA dataset: foundation (analysed ingredients), sr_legacy (reference foods, fast foods) or fndds (foods as eaten). |  |

```bash
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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `fdc_id` | path | `integer` | yes | USDA FDC id. | `2707159` |
| `grams` | query | `number` | no | Also give the nutrients of this many grams. | `150` |

```bash
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.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `code` | query | `string` | yes | EAN-13, EAN-8, UPC-A or GTIN-14 digits. | `3017624010701` |

```bash
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"
```

## Sample call

Analyze Meal Text: `POST /v1/nutrition/analyze`.

```bash
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"
  }'
```

## Response

```json
{
  "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)

```bash
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

```bash
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"
```

```json
{
  "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. |

## Pricing

Meal: 10 credits (photo 15) for up to 5 foods, +2 per extra food. Search, food, barcode: 1. Failed calls are never billed.

| Plan | Price | Credits included | Above the quota |
|---|---|---|---|
| BASIC | Free | 20 / day | resets every day |
| PRO | $4.99/month | 8,000 / month | $0.007 per credit |
| ULTRA | $14.99/month | 25,000 / month | $0.007 per credit |
| MEGA | $49.99/month | 80,000 / month | $0.007 per credit |

Apify actor **Calorie & Nutrition Calculator - Meals, Photos & Barcodes**: billed per event; free-plan users get 5 meals or photos and 20 barcodes per run.

| Event | Charged for | Price |
|---|---|---|
| `meal-analyzed` | each meal text analysed (5 foods) | $0.0055 |
| `photo-analyzed` | each meal photo analysed (5 foods) | $0.008 |
| `extra-food` | each food beyond 5 in a meal | $0.0008 |
| `barcode-product` | each barcode found | $0.001 |

## Links

- API reference (HTML): https://helenis-api.com/docs/nutrition
- OpenAPI: https://helenis-api.com/docs/nutrition/openapi.json
- Overview and pricing: https://helenis-api.com/apis/nutrition/
- RapidAPI listing: https://rapidapi.com/helenis-api-helenis-api-life/api/nutrition-analysis-calories-macros-from-text?utm_source=helenis&utm_medium=site&utm_campaign=nutrition&utm_content=markdown

## Conventions (every Helenis API)

- Auth: two headers on every call, `X-RapidAPI-Key` (your key) and `X-RapidAPI-Host` (the API's host). One RapidAPI key works for every API you subscribe to.
- Billing in credits: one for a simple call, more for heavier work (a minute of audio, a page read by AI). Each API states its rule.
- Failed calls are never billed: a `4xx` bills zero credits and a `5xx` is never counted.
- Errors share one envelope: `{"error": {"status", "code", "message"}}` with a stable machine-readable `code`.
- `400`: fix the input (validation errors are always 400, never 422); not billed.
- `429`: rate limit; wait for `Retry-After`. `503`: temporary upstream or AI failure (`ai_error`, `upstream_timeout`); retry later, not billed.
- Values the source does not give come back as `null`, never invented.
