Saltar al contenido
Almendra
Esc
↑↓navegar↵abrir⌘Jvista previa

Create a custom food

Adds a food to the account’s own foods (Foods > My foods in the dashboard), usable in meal plans, recipes and exchange groups. Values are per 100 g.

Requires the library:write permission.

POST/foods
Autorización
AuthorizationToken Bearer (API Key) · headerobligatorio

Almendra API key, bound to one professional account. Send it as Authorization: Bearer YOUR_API_KEY.

Ámbitos:library:write
Cuerpo de la solicitud
application/json
namestringobligatorio
longitud mín. 1 · longitud máx. 120
categorystring
longitud máx. 60
caloriesKcalnumberobligatorio
mín. 0
proteinGnumberobligatorio
mín. 0
carbsGnumberobligatorio
mín. 0
fatGnumberobligatorio
mín. 0
nutrientsobject

Other nutrients, per 100 g, with the names GET /foods/{food_id} returns (fiber_g, sodium_mg, vitaminC_mg, …). Unknown names answer 400.

measuresFoodMeasureInput[]

Household measures (e.g. 1 slice = 30 g). Grams are always available.

máx. 19 elementos
Mostrar propiedades
Array de FoodMeasureInput
amountnumberobligatorio
mín. 0
descriptionstringobligatorio
longitud mín. 1 · longitud máx. 60
gramsnumberobligatorio
mín. 0
Respuestas
201

Food created

_idstringobligatorio
namestringobligatorio
typestringobligatorio

food: from a food composition database; custom_food: created by an account; recipe: a recipe.

Valores permitidos:foodcustom_foodrecipe
sourcestring

Food composition database the values come from

categorystring
createdByThisAccountbooleanobligatorio
caloriesKcalnumber
proteinGnumber
carbsGnumber
fatGnumber
nutrientsobjectobligatorio

Every other nutrient the food has, per 100 g, keyed by name and unit (sodium_mg, vitaminB12_ug, …).

measuresFoodMeasure[]obligatorio

Household measures and their weight in grams, including the account's own measures for this food. A meal plan's unit is one of these (or grams).

Mostrar propiedades
Array de FoodMeasure
amountnumberobligatorio
descriptionstringobligatorio
gramsnumberobligatorio
400

Invalid path parameter, query parameter or request body

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

401

Missing or invalid API key

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

403

The account behind the API key has no active paid plan, or the key lacks the permission this operation needs

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

415

Request body sent without Content-Type: application/json

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

429

Rate limit exceeded (600 requests per 60 seconds); retry after Retry-After seconds

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

500

Unexpected server error

successbooleanobligatorio
Valores permitidos:false
messagestringobligatorio

Same as error.message.

errorobjectobligatorio
Mostrar propiedades
statusintegerobligatorio

HTTP status code of the response.

codestringobligatorio

Machine-readable error code, stable across versions; branch on this rather than on message.

Valores permitidos:bad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictpayload_too_largeunsupported_media_typeunprocessable_entityrate_limitedinternal_errornot_implementedbad_gatewayservice_unavailablegateway_timeout
messagestringobligatorio

Human-readable explanation of what went wrong.

Pruébalo
Servidor
Autorización
Cuerpoapplication/json
Solicitud
curl -X POST 'https://api.almendra.io/openapi/v1/foods' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Pan integral de la panadería",
  "category": "string",
  "caloriesKcal": 247,
  "proteinG": 13,
  "carbsG": 41,
  "fatG": 3.4,
  "nutrients": {
    "fiber_g": 7,
    "sodium_mg": 400
  },
  "measures": [
    {
      "amount": 1,
      "description": "taza",
      "grams": 240
    }
  ]
}'
Respuesta
{
  "_id": "string",
  "name": "Pechuga de pollo, cocida",
  "type": "food",
  "source": "CENAN (2017)",
  "category": "string",
  "createdByThisAccount": true,
  "caloriesKcal": 165,
  "proteinG": 31,
  "carbsG": 0,
  "fatG": 3.6,
  "nutrients": {
    "fiber_g": 0,
    "sodium_mg": 74,
    "iron_mg": 1
  },
  "measures": [
    {
      "amount": 1,
      "description": "taza",
      "grams": 240
    }
  ]
}

¿No encuentras lo que buscas?

Nuestro equipo responde en menos de 1 día hábil, de lunes a viernes de 9:30 a 18:00 (GMT-5).

Escríbenos

¿Te ha resultado útil esta página?