Developer API

Query Food Info's reference nutrition data programmatically. A small, versioned, read-only REST API. Free to start: create an account, generate a key and you get 100 requests a day. Requests authenticate with an API key in the X-Api-Key header.

Descripción general

Versioned under /api/v1, JSON only, server-to-server (no browser CORS). Reuses the same reference data the site runs on. Create a key in "Your API keys" below; a free account is enough to get one.

URL base
https://api.food-info.org/api/v1
Formato
JSON
Autenticación
X-Api-Keyheader
Plan
Free tier, or Practitioner for higher limits

The full OpenAPI 3 description is published at https://api.food-info.org/api/v1/openapi.json, so you can import it into Postman or Insomnia, or generate a typed client, rather than writing one by hand.

Autenticación

Send your secret key in the X-Api-Key header on every request. Keys are tied to your account; keep them server-side and never expose them in a browser or mobile app. A missing, invalid or revoked key returns 401.

curl -H "X-Api-Key: YOUR_KEY" \
  "https://api.food-info.org/api/v1/nutrients"

Límites de uso

Two tiers. Every read endpoint below works on both; the paid plan buys throughput rather than access. Limits are counted per account, not per key, so generating extra keys does not raise your quota.

PlanPer minutePer dayRecipe endpoints
Free10100No (403)
Practitioner6010,000Yes

Every response carries X-RateLimit-Limit-Minute, X-RateLimit-Limit-Day and X-RateLimit-Tier, so you can read your current allowance in-band rather than discovering it on a 429. Exceeding a limit returns 429 with a Retry-After header in seconds, so you can back off precisely.

Endpoints

Los dos puntos al inicio indican un parámetro de ruta (p. ej., :id). Donde se muestre: limit va de 1 a 100 (por defecto 25); home_nation es un código de país ISO (p. ej., GB) que prioriza los alimentos de referencia de ese país.

GET/nutrients

El catálogo de nutrientes — id, name, unit, categoría — para que puedas descubrir los valores de nutrientId que aceptan los endpoints de búsqueda inversa.

GET/foods/search

Busca alimentos por nombre (subcadena sin distinción entre mayúsculas y minúsculas). Parámetros: q (obligatorio, ≤200 caracteres), home_nation, limit. Devuelve id, description, ndbNumber.

curl -H "X-Api-Key: YOUR_KEY" \
  "https://api.food-info.org/api/v1/foods/search?q=oats&limit=5"

GET/foods/:id

Un único alimento por id de FoodData Central: id, description, ndbNumber, dataType, publicationDate. 404 si no se encuentra.

GET/foods/:id/panel

Panel nutricional completo: cantidades agrupadas por 100 g + por ración y % de ingesta de referencia. Parámetros: portionId (opcional), source ("UK RI" / "FDA 2016"; por defecto UK RI). 404 si no se encuentra.

GET/nutrients/:nutrientId/top-foods

Búsqueda inversa: alimentos de referencia más ricos en un nutriente por 100 g, de mayor a menor. Parámetros: home_nation, limit.

curl -H "X-Api-Key: YOUR_KEY" \
  "https://api.food-info.org/api/v1/nutrients/1089/top-foods?limit=3"

Respuesta (ids y cantidades de alimentos son ilustrativos):

{
  "Nutrient": { "Id": 1089, "Name": "Iron, Fe", "Unit": "MG" },
  "Results": [
    { "FoodId": 170554, "Description": "Spices, thyme, dried", "Amount": 123.6 },
    { "FoodId": 169966, "Description": "Seeds, sesame flour",  "Amount": 14.6 }
  ]
}

GET/nutrients/:nutrientId/bottom-foods

Inverso de los alimentos más ricos: alimentos de referencia con menos cantidad de un nutriente por 100 g. Mismos parámetros y estructura de respuesta.

Recipe endpoints (Practitioner)

The two endpoints below need a Practitioner key. A free key reaches them but receives 403 with the required and current tier named in the body. Both are POST and take JSON.

POST/recipes/parse

Parses raw ingredient lines into structured quantity, unit and food name. Deterministic text handling only, with no database lookup and no food matching, so it is the cheap call to use when you only need structure. Body: { "lines": ["2 tbsp olive oil", "200g plain flour"] }.

curl -H "X-Api-Key: YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"lines":["2 tbsp olive oil","200g plain flour"]}' \
  "https://api.food-info.org/api/v1/recipes/parse"

POST/recipes/analyze

Full analysis: resolves each line to a food, then returns per-serving and per-100 g nutrition with source attribution and review flags for lines it was unsure about. Body takes lines (required), region (ISO country code, biases matching to that country's reference foods) and servings.

Returns ingredients, perServing, per100g, totalGrams, servings, sources, reviewFlags and nutrientGroups. Each nutrient row carries nutrientId, name, unit, perServing, per100g, percentDailyValue and referenceAmount. Check reviewFlags before displaying a result as authoritative.

curl -H "X-Api-Key: YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"lines":["2 eggs","100ml milk"],"region":"GB","servings":2}' \
  "https://api.food-info.org/api/v1/recipes/analyze"

Errores

EstadoSignificado
400Entrada inválida — p. ej., q en blanco o un nutrientId no positivo. El cuerpo es un objeto JSON con un mensaje de error.
401 / 403Missing, invalid or revoked key (401), or a Practitioner-only endpoint called with a free key (403). The 403 body names the tier required and the tier you hold.
404No existe ningún alimento o nutriente con ese id.
429Límite de uso superado — consulta Retry-After.

Tus claves de API

Sign in to generate an API key. A free account is enough to start: 100 requests a day.

Create a free account