Skip to content

Food recognition API

A food recognition API that turns a meal photo into nutrition

Send a photo of a plate, as an upload or an https link. The API names the dish and returns each item with its portion in grams, calories, macros, 21 nutrients in all, and a NutriScore grade from A to E.

A typical plate uses about 65 credits, about $0.065. The test key is free.

Grilled chicken breast with a grain side and broccoli on a wooden board

Meal photo result

Grilled chicken with rice and salad

B

515kcal

  • Grilled chicken breast248 kcal150 g
  • Steamed white rice205 kcal1 cup (158 g)
  • Green salad with olive oil62 kcal80 g
The card is the fixed sample a test key returns, in the live result format. The photo is for illustration.

What does a food image recognition API return?

For a meal photo, NutriScan returns the dish name, one entry per food it finds with a portion in grams, and the nutrients for each item and for the whole plate.

You set type to meal, which is also the default. The same JSON comes back for every input, so a screen built for photos also works for label photos and text.

FieldWhat you getUse it for
meal.nameThe dish as a person would name it, in the language you asked for.The title of a diary entry.
items[]Each food with portion.display, grams and its own nutrients.A list the user can confirm or adjust.
meal.totalsCalories, 7 macro fields and 13 micronutrients for the whole plate.Daily targets and charts.
meal.nutri_scoreA grade from A to E and a one-sentence reason.A quality badge with text you can show as is.
items[].sourcefood_db, web or estimate.Asking for confirmation on estimated items.
credits_usedWhat this scan cost.Cost tracking per user.

Every field is described on the result page. For the nutrient fields on their own, see the nutrition analysis API and the calorie API.

How do I send a meal photo to the API?

Make one POST to /v1/scans with a bearer key and either an image_url or an image_base64. The result comes back in the same response.

The example sends a link. The Python example uploads a file from disk and asks for German food names.

  1. Send the photo as a link

    Host the image at a public https URL and send it in a meal scan.

    curl https://platform-api.nutriscan.app/v1/scans \
      -H "Authorization: Bearer $NUTRISCAN_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "meal",
        "image_url": "https://example.com/lunch.jpg",
        "language": "en",
        "context": { "meal_time": "lunch", "cooking_method": ["grilled"] }
      }'
  2. Or upload the file

    Base64 needs no hosting. Set a timeout of at least 100 seconds.

    import base64, os, requests
    with open("schnitzel-plate.jpg", "rb") as f:
        photo = base64.b64encode(f.read()).decode()
    resp = requests.post(
        "https://platform-api.nutriscan.app/v1/scans",
        headers={"Authorization": f"Bearer {os.environ['NUTRISCAN_KEY']}"},
        json={"type": "meal", "image_base64": photo, "language": "de"},
        timeout=100,
    )
    scan = resp.json()
    print(scan["meal"]["name"], scan["meal"]["totals"]["calories"])
  3. Read the result

    This is the test-key sample, trimmed. A live scan has the same shape.

    {
      "id": "scn_Q2mX8rT4vK1pLw9eZb3nYh6A",
      "status": "succeeded",
      "meal": {
        "name": "Grilled chicken with rice and salad",
        "nutri_score": "B",
        "nutri_score_reason": "Lean protein and vegetables balance the rice; moderate sodium from the marinade.",
        "totals": { "calories": 515, "protein_g": 51.9, "carbs_g": 47.7, "fat_g": 11.1, "…": "21 nutrients in all" }
      },
      "items": [
        { "name": "Grilled chicken breast", "portion": { "display": "150 g" }, "grams": 150, "calories": 248, "source": "food_db", "…": "…" },
        { "name": "Steamed white rice", "portion": { "display": "1 cup (158 g)" }, "grams": 158, "calories": 205, "…": "…" },
        { "name": "Green salad with olive oil", "portion": { "display": "80 g" }, "grams": 80, "calories": 62, "…": "…" }
      ],
      "credits_used": 0,
      "test_mode": true
    }

Which hints make a meal photo scan better?

Send what your app already knows in the context object, so the scan does not have to guess it from the picture.

Every field is optional free text. Unknown keys inside context are ignored, and unknown keys at the top level of the request return 400 invalid_request.

FieldHint aboutExample
meal_timeWhen the meal is eaten."lunch"
cooking_methodUp to 8 methods.["grilled"]
oil_quantityHow much oil went into the dish."1 tbsp"
consumed_quantityHow much of the plate was eaten."half"
locationWhere the meal is from."Lyon, France"
food_typeThe kind of food. "packaged-food" makes the photo scan run as a label scan."homemade"
goal and food_preferencesThe user's goal and food preferences."high protein"

What are the image limits?

Images can be JPEG, PNG or WebP, up to 10 MB, in a request body of up to 14.5 MB. Resize phone photos before upload.

Formats and size

JPEG up to 50 megapixels, PNG and WebP up to 24. A larger body returns 413 request_too_large. iPhones save HEIC by default, which is not supported yet, so convert on the device.

Links must be public

image_url takes https only, up to 2,048 characters. We fetch it once, follow no redirects and give up after 5 seconds with 400 image_url_unreachable.

One image per scan

Send image_url or image_base64, not both. A table of every limit is on the limits page.

How long does a food photo scan take?

A scan can take up to 95 seconds, and big plates with many items take longest. Set your client timeout to at least 100 seconds, or stream the result.

Add "stream": true and the call answers at once as text/event-stream. The items the photo shows arrive after about 10 to 15 seconds, so your screen can list them while the numbers finish. A streamed scan can run up to 140 seconds and uses the same credits.

Streaming docs
event: scan.started
data: {"id":"scn_8Kd2…","status":"processing"}
event: items.detected
data: {"id":"scn_8Kd2…","dish_name":"Tofu salad bowl","items":[{"name":"Tofu","portion":"100 g"}, …]}
event: scan.completed
data: { …the same JSON as a normal response… }

The items in items.detected are a first look. The final result can rename, add or drop items. If the connection drops, the scan still finishes and GET /v1/scans/{id} returns it.

From our public pricing

What does a meal photo scan cost?

A typical plate uses about 65 credits, which is about $0.065. Credits are $0.001 each and sold in prepaid packs from $49.

RequestCreditsCost
Normal plateabout 65about $0.065
Big plate with 9 itemsabout 130about $0.13
Photo with no food20 or morefrom $0.02
Scan that fails on our side0$0

A scan is priced from the work it took, so your real figure shows up in credits_used after the first live scans. A scan needs 20 credits in your balance to start. The $49 Starter pack covers about 750 meal photos. Credits never expire, there is no subscription, and test-key scans cost nothing.

To build a diary on top of scans, see the food logging API.

Pack prices

What happens when the photo has no food?

The API returns 422 no_food_detected. The scan did work to find that out, so it is charged for the work it used, at least 20 credits.

Do not retry the same photo. Ask the user for a new one. Errors found before the scan starts, such as a bad key or too few credits, come back as plain JSON even when you stream. With streaming on, a failure during the scan arrives as an error event in place of scan.completed.

All error codes
{ "error": { "code": "no_food_detected", "message": "…" } }

Suggested text for your user: "We could not find food in this photo. Try again with the plate in the frame."

Where does the food recognition API not fit?

It reads a photo, a label or a line of text. It does not search a food database or look up barcodes.

What it does

Names the dish and lists each item with a portion in grams from one meal photo.

Returns 21 nutrients per item and a NutriScore grade with a reason, in 12 languages.

Takes the photo as an upload or an https URL, and reads packaged food from a nutrition label photo.

What it does not do

No food search endpoint, no barcode lookup and no searchable food database. For one food, send text with an amount.

A scan is not instant. It can take up to 95 seconds, so it suits a screen with a progress state, not a live camera feed.

One image per scan, as JPEG, PNG or WebP. HEIC needs converting first.

The numbers are estimates for food logging, not for medical decisions.

Questions about meal photo recognition

Anything else, the API docs cover every field and error. Fitness and coaching teams can start from the fitness app guide.

Does the API find every item on a plate?

The scan names the dish, lists the items it finds and estimates each portion from the photo. Every item carries a source field, food_db, web or estimate, so your app can ask the user to confirm the items that are estimates.

How do I send a photo from a phone?

Send the file as image_base64, or host it and send a public https image_url. JPEG, PNG and WebP work. HEIC does not yet, so convert iPhone photos to JPEG on the device before you upload.

How much does one meal photo cost?

A typical plate uses about 65 credits, which is about $0.065. A big plate with 9 items uses about 130. Every scan uses at least 20 credits. Credits are prepaid in packs from $49 and never expire.

How long does a photo scan take?

A scan can take up to 95 seconds, so set your client timeout to at least 100 seconds. With stream set to true, the detected items arrive after about 10 to 15 seconds and the full result follows.

Can I look up a food by barcode or search by name?

No. There is no barcode endpoint, no food search endpoint and no searchable food database. For one food, send text with an amount, such as 150 g of Greek yogurt. For a packaged food, send a photo of its nutrition table with type label.

Can I try it before buying credits?

Yes. A new account gets a test key at no cost. It returns a fixed sample result in the live format, grilled chicken with rice and salad, grade B, 515 kcal, and uses no credits.

Send your first meal photo today

Sign in with your email, run photos through the test key, and buy credits when you are ready to go live.

  • Test key at sign-up
  • Packs from $49
  • No subscription
  • Credits never expire
A breaded pork schnitzel with a lemon wedge
Example resultSchweineschnitzel, paniert1 Schnitzel, 150 g420 kcal
NutriScan app meal screen listing calories, macros, vitamins and minerals for one logged meal