Skip to content

Food search ​

GET /v1/foods/search finds foods by name. GET /v1/foods/{id} returns one food by its id. Both return nutrients per serving and per 100 g, and both use the same bearer key as scans.

Use search when your user types a food name and picks from a list. Use a scan when the input is a meal photo, a pack label or a sentence such as "2 eggs and a slice of toast".

bash
curl "https://platform-api.nutriscan.app/v1/foods/search?q=greek%20yogurt&limit=5&country=US" \
  -H "Authorization: Bearer $NUTRISCAN_KEY"

Key scope ​

A key needs the search scope for both calls. Keys made on or after December 1, 2026 have it unless you untick it in the console. Older keys are scan only and return 403 scope_missing: create a new key in the console.

Search fields ​

FieldTypeNotes
qstring, requiredThe food name, 2 to 100 characters after trimming. Small typos are tolerated
limitinteger1 to 20. Default 10
countrystring, up to 64A two-letter code (US, DE, FR) or a country name (Germany). Send it for regional values. Without it, or with a value we cannot read, you get global values and country comes back null

Encode the query string. q=mac & cheese must be sent as q=mac%20%26%20cheese.

The response ​

json
{
  "query": "apple",
  "country": null,
  "results": [
    {
      "id": "fd_test_apple",
      "name": "Apple",
      "serving": { "label": "1 medium (182 g)", "grams": 182.0 },
      "per_serving": {
        "calories": 94.64,
        "protein_g": 0.55,
        "carbs_g": 25.12,
        "fat_g": 0.36,
        "fiber_g": 4.37,
        "sugar_g": 18.93,
        "saturated_fat_g": 0.0,
        "trans_fat_g": null,
        "micros": {
          "sodium_mg": 1.82,
          "potassium_mg": 194.74,
          "calcium_mg": 10.92,
          "iron_mg": 0.18,
          "magnesium_mg": null,
          "zinc_mg": null,
          "vitamin_c_mg": 8.37,
          "vitamin_e_mg": null,
          "vitamin_a_mcg": null,
          "vitamin_d_mcg": null,
          "vitamin_k_mcg": null,
          "vitamin_b12_mcg": null,
          "omega_3_mg": null
        }
      },
      "per_100g": {
        "calories": 52.0,
        "protein_g": 0.3,
        "carbs_g": 13.8,
        "fat_g": 0.2,
        "fiber_g": 2.4,
        "sugar_g": 10.4,
        "saturated_fat_g": 0.0,
        "trans_fat_g": null,
        "micros": {
          "sodium_mg": 1.0,
          "potassium_mg": 107.0,
          "calcium_mg": 6.0,
          "iron_mg": 0.1,
          "magnesium_mg": null,
          "zinc_mg": null,
          "vitamin_c_mg": 4.6,
          "vitamin_e_mg": null,
          "vitamin_a_mcg": null,
          "vitamin_d_mcg": null,
          "vitamin_k_mcg": null,
          "vitamin_b12_mcg": null,
          "omega_3_mg": null
        }
      },
      "portions": [
        { "unit": "small", "grams": 149.0 },
        { "unit": "medium", "grams": 182.0 }
      ]
    }
  ],
  "usage": { "credits_charged": 0, "credits_left": 48935 },
  "engine_version": "2026.12.0",
  "test_mode": true
}

This is the answer a test key gives for q=apple. A live answer has the same fields without test_mode.

FieldNotes
queryYour q, trimmed
countryThe two-letter code we read from your country, or null
resultsUp to limit foods, best match first. An empty list when nothing matches
usage.credits_chargedCredits this call used
usage.credits_leftYour balance after the call
engine_versionThe version of the engine that answered
test_modetrue on answers to a test key. Absent on live answers

The food object ​

FieldNotes
idStarts with fd_ or cr_. Treat it as an opaque string and store it whole
nameThe food's name
serving.label, serving.gramsThe usual serving and its weight
per_servingNutrients for that serving
per_100gNutrients for 100 g
portionsOther units for the same food, each with unit and grams. Can be empty

per_serving and per_100g hold the same 21 fields: calories, protein_g, carbs_g, fat_g, fiber_g, sugar_g, saturated_fat_g, trans_fat_g, and 13 values under micros (sodium_mg, potassium_mg, calcium_mg, iron_mg, magnesium_mg, zinc_mg, vitamin_c_mg, vitamin_e_mg, vitamin_a_mcg, vitamin_d_mcg, vitamin_k_mcg, vitamin_b12_mcg, omega_3_mg).

A nutrient we do not know is null, never 0. Show it as unknown, and do not add it to a daily total as zero.

A food has no NutriScore grade and no confidence value. Those belong to scan results.

To show a different amount, multiply per_100g by grams / 100. For one of the portions, use its grams.

Get a food by id ​

bash
curl https://platform-api.nutriscan.app/v1/foods/fd_test_apple \
  -H "Authorization: Bearer $NUTRISCAN_KEY"

The response is the food object with usage and engine_version beside its fields, plus test_mode for a test key.

The same food keeps the same id, so you can store ids in your own tables, for example in a user's saved foods, and fetch the food again later. An id we do not know, or one that has been retired, returns 404 not_found. Handle that by searching again by name.

Credits ​

CallLive keyTest key
Search that returns 2003 credits0
Lookup by id that returns 2001 credit0
Any error response00

A search with an empty results list is still a 200 and uses 3 credits. A search needs 3 credits left to run and a lookup needs 1, otherwise the call returns 402 insufficient_credits. Pack prices are on Nutrition API pricing.

Test keys ​

A test key knows three sample foods: Masala Dosa (cr_test_masala_dosa), Paneer Tikka (fd_test_paneer_tikka) and Apple (fd_test_apple). A search returns the samples whose name matches your text: q=apple returns Apple, q=pan returns Paneer Tikka, and q=pizza returns an empty list. A lookup works for the three sample ids only. Test calls use no credits and run with a zero balance.

Limits ​

  • 60 calls a minute per account, across all keys. Past that: 429 rate_limited with a Retry-After header.
  • A daily limit per account. Past it: 429 daily_limit, and Retry-After counts the seconds to 00:00 UTC, when it resets.
  • Very fast bursts from one address can get 429 rate_limited with Retry-After: 10.

Wait for the number of seconds in Retry-After before the next call. Search is for looking foods up as your users need them. Store the id of a food a user picked, so the next read is a 1-credit lookup and no new search.

Errors ​

Errors use the same JSON as the rest of the API, described on the errors page. None of them uses credits.

StatusCodeWhen
400invalid_requestq is missing, shorter than 2 or longer than 100 characters, or limit is not a whole number from 1 to 20
401invalid_api_keyThe key is missing, wrong or revoked
402insufficient_creditsNot enough credits for the call
403scope_missingThe key has no search scope
404not_foundNo food has that id
429rate_limitedMore than 60 calls in a minute
429daily_limitThe daily limit is reached. Resets at 00:00 UTC
503search_unavailableSearch is down for a moment. Retry after a few seconds

Example: search, then fetch ​

python
import os, requests

API = "https://platform-api.nutriscan.app/v1"
headers = {"Authorization": f"Bearer {os.environ['NUTRISCAN_KEY']}"}

found = requests.get(f"{API}/foods/search", headers=headers,
                     params={"q": "apple", "limit": 5}, timeout=30)
found.raise_for_status()
for food in found.json()["results"]:
    print(food["id"], food["name"], food["per_100g"]["calories"], "kcal per 100 g")

food = requests.get(f"{API}/foods/fd_test_apple", headers=headers, timeout=30).json()
print(food["serving"]["label"], food["per_serving"]["calories"], "kcal")
js
const API = "https://platform-api.nutriscan.app/v1";
const headers = { Authorization: `Bearer ${process.env.NUTRISCAN_KEY}` };

const res = await fetch(`${API}/foods/search?${new URLSearchParams({ q: "apple", limit: "5" })}`, { headers });
if (!res.ok) throw new Error((await res.json()).error.code);
const { results } = await res.json();
for (const food of results) console.log(food.id, food.name, food.per_100g.calories, "kcal per 100 g");

Related pages: authentication for keys and scopes, limits for rate limits across the API, the MCP server for the same calls as agent tools, and the Food Search API overview.