foods

Get a food

Return a single food by its short-id, or a 404 if no food has that id.

Embed related resources with include= and trim with fields[<resource>], the same way the list endpoint does. A retired id (one merged into another food) forwards to the surviving food at 200 with an added canonical_id field, so a stored id never dead-ends after a merge.

get/v1/foods/{id}

Request

  • Base URL: https://api.noms.sh
  • URL: https://api.noms.sh/v1/foods/{id}
  • Auth: API key in header X-API-Key

Path parameters

idstring required

Food short-id (12-char base62).

Example:3f9a1c0b7e2d

Query parameters

includestring nullable

Comma-separated related resources to embed: brand, food_group, nutrients, serving_sizes, images, market_countries.

Example:brand,nutrients
fields[foods]string

Sparse fieldset. A comma-separated subset of foods fields to return (e.g. id,name). Omit to return all fields.

fields[brands]string

Sparse fieldset. A comma-separated subset of brands fields to return (e.g. id,name). Omit to return all fields.

fields[food-groups]string

Sparse fieldset. A comma-separated subset of food-groups fields to return (e.g. id,name). Omit to return all fields.

fields[nutrients]string

Sparse fieldset. A comma-separated subset of nutrients fields to return (e.g. id,name). Omit to return all fields.

fields[serving_sizes]string

Sparse fieldset. A comma-separated subset of serving_sizes fields to return (e.g. descriptor,grams). Omit to return all fields.

fields[images]string

Sparse fieldset. A comma-separated subset of images fields to return (e.g. type,url). Omit to return all fields.

fields[market_countries]string

Sparse fieldset. A comma-separated subset of market_countries fields to return (e.g. country_code). Omit to return all fields.

Headers

If-None-Matchstring

An ETag from a previous response for this URL. If it still matches, the API answers 304 Not Modified with no body; otherwise you get the full 200. Either way the request is metered.

Response

A single food. The flat food resource; nested objects (brand, food_group, nutrients, serving_sizes, images, market_countries) appear only when requested via include=, and fields[<resource>] may trim the keys present. If the requested id was retired by a merge, the canonical food is returned with an extra canonical_id field naming its live id — update any stored reference to it.

Example response

{
  "data": {
    "barcode": "00041570110645",
    "basis_unit": "grams",
    "brand": {
      "id": "XoluRyOx9o3C",
      "name": "Blue Diamond"
    },
    "brand_id": "XoluRyOx9o3C",
    "food_group": {
      "icon_url": "https://images.noms.sh/60f440137489aed9240588a68ffebf455102b257021bfa1cde4d6f6b0b28ac6e",
      "id": "NUTS_AND_SEEDS",
      "name": "Nuts & Seeds"
    },
    "food_group_id": "NUTS_AND_SEEDS",
    "id": "TIgbNPnzCIjX",
    "images": [
      {
        "type": "photo",
        "url": "https://images.noms.sh/60f440137489aed9240588a68ffebf455102b257021bfa1cde4d6f6b0b28ac6e"
      }
    ],
    "ingredients_text": "Almonds, sunflower oil, sea salt.",
    "is_foundational": false,
    "market_countries": [
      {
        "country_code": "US"
      }
    ],
    "name": "Roasted salted almonds",
    "nutrients": [
      {
        "id": "PROTEIN",
        "name": "Protein",
        "unit": "g",
        "value": "21.428571"
      }
    ],
    "serving_sizes": [
      {
        "grams": "28.0",
        "is_default": true,
        "quantity": "28.0",
        "unit": "g"
      }
    ]
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.