
food-recognition-nutrition-api
io.github.NutriScan-App/food-recognition-nutrition-api
Nutrition from a meal photo, a pack label or text, plus food search by name with stable ids.
Documentation
Food recognition and nutrition API
Send a meal photo, a nutrition label or a line of text. Get back calories, macros, 21 nutrients per item and a NutriScore, as JSON.
Runnable examples for the NutriScan API in curl, Python and Node.js, with an MCP server for AI agents.
Try it · Examples · MCP server · Clients · API docs
English · Deutsch · Français · Español
An example result for this plate, shown the way your app could display it.
The NutriScan API is the engine behind the meal scan in the NutriScan app (150,000+ downloads, rated 4.6), opened up as one HTTPS endpoint. You post a photo or a sentence. The response names the dish, lists every item with its portion, and gives calories, macros, 13 micronutrients and a NutriScore grade from A to E.
This repo holds examples you can run in a minute with a free test key. The written docs are at nutriscan.app/api/docs.
Try it
Sign in at platform.nutriscan.app with your email and copy a test key. It costs nothing.
export NUTRISCAN_KEY="ns_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
curl https://platform-api.nutriscan.app/v1/scans \
-H "Authorization: Bearer $NUTRISCAN_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "meal", "image_url": "https://nutriscan.app/images/api/grilled-chicken-grain-plate.webp"}'
{
"id": "scn_SzAxwr3Bm1JFu7TmtTGY6p6v",
"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.0, "protein_g": 51.9, "carbs_g": 47.7, "fat_g": 11.1,
"fiber_g": 2.2, "sugar_g": 1.6, "saturated_fat_g": 2.3, "trans_fat_g": 0.0,
"micros": { "sodium_mg": 457.0, "potassium_mg": 645.0, "iron_mg": 4.2, "vitamin_c_mg": 14.0 }
}
},
"items": [
{
"name": "Grilled chicken breast",
"portion": { "value": 150, "unit": "g", "display": "150 g" },
"grams": 150,
"calories": 248.0, "protein_g": 46.5, "carbs_g": 0.0, "fat_g": 5.4,
"source": "food_db"
}
],
"test_mode": true,
"credits_used": 0
}
That is a real response, shortened. The full one has 13 fields in micros and 3 entries in items. A test key does not look at your photo. It returns this fixed sample (a pack of Greek yogurt for label scans) and uses no credits. The JSON has the same shape as a live scan, so you can build your parser and your screens before you pay for anything.
Three inputs, one endpoint
Everything goes to POST /v1/scans. The type field picks the input, and all three return the same JSON.
| You send | type | What comes back | Example |
|---|---|---|---|
| A photo of a plate, a bowl or a takeaway box | meal | The dish, each item with an estimated portion, nutrients per item and for the meal | Python, Node.js |
| A photo of the nutrition table on a pack | label | The table as JSON, per pack or per serving | Label OCR |
| A sentence such as "2 eggs and a slice of toast" | text | Calories and nutrients for what the sentence describes | Text to macros |
Each result has 21 nutrients for the meal and for every item (calories, 7 macro fields, 13 micronutrients), a NutriScore with a one-sentence reason, and names in one of 12 languages.
Food search
GET /v1/foods/search?q=apple finds foods by name, and GET /v1/foods/{id} returns one food by its id. Each food has a serving, nutrients per serving and per 100 g, and its portion units. A search uses 3 credits and a lookup uses 1; a test key is free and knows three sample foods. The key needs the search scope.
curl "https://platform-api.nutriscan.app/v1/foods/search?q=apple&limit=5" \
-H "Authorization: Bearer $NUTRISCAN_KEY"
Example: food-search-api. Reference: food search docs.
Examples
Every folder is one small program with no dependencies. Copy the file you need.
| Folder | What it does |
|---|---|
food-recognition-api-python | Scans a photo from disk or a URL and prints the dish, the NutriScore and a line per item |
food-recognition-api-node | The same in Node.js with the built-in fetch |
nutrition-label-ocr-api | Reads the nutrition table on a pack photo and prints it as a table or JSON |
calorie-api-text-to-macros | Turns a typed meal into calories and macros, with safe retries |
food-search-api | Finds foods by name and fetches one by its id, with nutrients per serving and per 100 g |
streaming-food-scan | Shows the detected items while the scan is still running (server-sent events) |
meal-photo-calorie-api-web-app | A one-file web app where you upload a photo and see the result card. The key stays on the server |
food-logging-api-telegram-bot | A Telegram bot that logs a meal from a photo or a message |
indian-food-nutrition-api | A text scan of an Indian meal, with names in English or Hindi |
mcp-nutrition-server | Config files for Claude Code, Claude Desktop, Codex and Cursor |
Run any of them from the repo root:
git clone https://github.com/NutriScan-App/food-recognition-nutrition-api && cd food-recognition-nutrition-api
python3 examples/food-recognition-api-python/scan_photo.py
MCP server
AI agents can call the same scan through the hosted MCP server at https://platform-api.nutriscan.app/mcp. It has five tools: analyze_meal, get_scan, search_foods, get_food and get_usage. In Claude Code:
claude mcp add --transport http nutriscan https://platform-api.nutriscan.app/mcp \
--header "Authorization: Bearer $NUTRISCAN_KEY"
Configs for the Claude desktop app, Codex and Cursor are in examples/mcp-nutrition-server. The registry manifest is server.json.
Python and Node.js clients
Two small clients live in packages/. Each is one file with no dependencies. They pick image_url or image_base64 for you, send an idempotency key with every scan so a retry never costs twice, and raise one error type that carries the API's error code.
from nutriscan import NutriScan
ns = NutriScan() # reads NUTRISCAN_KEY
result = ns.scan("lunch.jpg") # a path, bytes or an https URL
print(result["meal"]["name"], result["meal"]["totals"]["calories"])
import { NutriScan } from "nutriscan";
const ns = new NutriScan(); // reads NUTRISCAN_KEY
const { meal } = await ns.scan({ text: "2 eggs and a slice of toast" });
console.log(meal.name, meal.totals.calories);
Install the one you need:
pip install nutriscan # Python 3.9+
npm install nutriscan # Node.js 18+
For coding agents
Point your agent at AGENTS.md and openapi.yaml. Between them they hold the endpoint, the request fields, the result schema and every error code, which is enough to write an integration without opening a browser. The spec also imports into Postman and other API tools.
Pricing
Test keys are free. Live scans use prepaid credits at $0.001 each. A typical meal photo uses about 65 credits, which is about $0.065. Packs start at $49, credits never expire, and there is no subscription. Each result reports its exact cost in credits_used. Details are on the pricing page.
Limits
- Photos are JPEG, PNG or WebP, up to 10 MB. HEIC is not supported yet.
- A scan can take up to 95 seconds. Set your HTTP timeout to 100 seconds or use streaming.
- 60 scans a minute per account. Email support@nutriscan.app for more.
- Food search needs a key with the
searchscope and is limited to 60 calls a minute per account. Keys made before December 1, 2026 are scan only. - There is no barcode endpoint. For a packaged food, send a photo of its nutrition label.
- The numbers are estimates for food logging. Do not use them for medical decisions.
The full list is on the limits page, and every error code is on the errors page.
What is open source here
The code in this repo is MIT licensed. Copy it into your product. The API it calls is a hosted, paid service covered by the NutriScan terms.
If an example has a bug, open an issue. For anything about your account or your scans, email support@nutriscan.app.
License
MIT
No installation packages available.