Skip to main content

Endpoint

GET /foods/:id
Retrieve complete information about a specific food using its numeric ID. This endpoint also increments the food’s search count for analytics.

Path Parameters

id
integer
required
The unique numeric ID of the foodConstraints: Must be a positive integer (>= 1)Example: /foods/1234

Response

success
boolean
required
Indicates if the request was successful
data
object
required
Complete food object
id
integer
required
Unique numeric food identifier
name
string
required
Food name
source
string
required
Data source: nutritional_table, user_contributed, or ai_generated
category_level_1
string
required
Main category (e.g., “Frutas”, “Legumes”, “Cereais”)
category_level_2
string
Subcategory (level 2)
category_level_3
string
Sub-subcategory (level 3)
image
string
URL to food image (if available)
fodmap
object
FODMAP information (null if not available)
level
string
required
FODMAP level: free, low, medium, or high
portion_note
string
Portion-specific notes (e.g., “1/2 cup”, “100g”)
additional_notes
string
Additional FODMAP notes or warnings
search_information
object
required
Metadata about how FODMAP data was matched
match_type
string
required
Type of match: single_ingredient or multiple_ingredients
category
string
FODMAP category (for single ingredient)
name_english
string
English name from FODMAP database
detected_keyword
string
Keyword that triggered the FODMAP match
total_ingredients
integer
Number of ingredients (for multiple_ingredients match)
ingredients
array
Array of ingredient FODMAP data (for multiple_ingredients match)
portuguese_keyword
string
Portuguese keyword
name_english
string
English ingredient name
level
string
FODMAP level for this ingredient
portion_note
string
Portion note for this ingredient
category
string
FODMAP category
nutrition
object
Nutritional information (null if not available)
energy_kcal
number
required
Energy in kilocalories
energy_kj
number
required
Energy in kilojoules
reference_portion
string
required
Reference portion (typically “100g”)
macronutrients
object
required
Complete macronutrient breakdown
lipids_g
string
required
Total fats in grams
saturated_fatty_acids_g
string
Saturated fats in grams
monounsaturated_fatty_acids_g
string
Monounsaturated fats in grams
polyunsaturated_fatty_acids_g
string
Polyunsaturated fats in grams
linoleic_acid_g
string
Linoleic acid in grams
trans_fatty_acids_g
string
Trans fats in grams
cholesterol_mg
string
Cholesterol in milligrams
carbohydrates_g
string
required
Total carbohydrates in grams
sugars_g
string
Sugars in grams
oligosaccharides_g
string
Oligosaccharides in grams
starch_g
string
Starch in grams
protein_g
string
required
Protein in grams
fiber_g
string
Dietary fiber in grams
salt_g
string
Salt in grams
alcohol_g
string
Alcohol in grams
water_g
string
Water content in grams
organic_acids_g
string
Organic acids in grams
ash_g
string
Ash content in grams
vitamins
object
Vitamin content as key-value pairs (e.g., {"vitamin_c_mg": "10.5"})
minerals
object
Mineral content as key-value pairs (e.g., {"calcium_mg": "120"})
data_sources
object
required
Information about data sources
nutritional_data
string
required
Source of nutritional data (e.g., “Portuguese Nutrition Table”)
fodmap_data
string
Source of FODMAP data (e.g., “Monash University FODMAP Database”)
ai_generated
object
AI generation metadata (if applicable)
is_ai_generated
boolean
required
Whether this food data was AI-generated
ai_source
string
AI model used (e.g., “GPT-4”)
fields_affected
array
Array of field names that were AI-generated
searchCount
integer
required
Number of times this food has been searched (incremented by this request)
createdAt
string
required
ISO 8601 timestamp when the food was created
updatedAt
string
required
ISO 8601 timestamp when the food was last updated

Examples

Get food by ID

curl "https://api.ceboelha.com/foods/1234"

Response Example

{
  "success": true,
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "id": 1234,
    "name": "Abacate",
    "source": "nutritional_table",
    "category_level_1": "Frutas",
    "category_level_2": "Frutas Frescas",
    "category_level_3": "Frutas Tropicais",
    "image": null,
    "fodmap": {
      "level": "low",
      "portion_note": "1/8 unidade (20g)",
      "additional_notes": "Porções maiores podem ser altas em FODMAPs",
      "search_information": {
        "match_type": "single_ingredient",
        "category": "Fruits",
        "name_english": "Avocado",
        "detected_keyword": "abacate"
      }
    },
    "nutrition": {
      "energy_kcal": 160,
      "energy_kj": 670,
      "reference_portion": "100g",
      "macronutrients": {
        "lipids_g": "14.7",
        "saturated_fatty_acids_g": "2.1",
        "monounsaturated_fatty_acids_g": "9.8",
        "polyunsaturated_fatty_acids_g": "1.8",
        "linoleic_acid_g": "1.7",
        "trans_fatty_acids_g": "0",
        "cholesterol_mg": "0",
        "carbohydrates_g": "8.5",
        "sugars_g": "0.7",
        "oligosaccharides_g": "0",
        "starch_g": "0",
        "protein_g": "2.0",
        "fiber_g": "6.7",
        "salt_g": "0.007",
        "alcohol_g": "0",
        "water_g": "73.2",
        "organic_acids_g": "0",
        "ash_g": "1.6"
      },
      "vitamins": {
        "vitamin_c_mg": "10",
        "vitamin_e_mg": "2.1"
      },
      "minerals": {
        "potassium_mg": "485",
        "magnesium_mg": "29"
      }
    },
    "data_sources": {
      "nutritional_data": "Portuguese Nutrition Table",
      "fodmap_data": "Monash University FODMAP Database"
    },
    "searchCount": 327,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-03-01T14:22:00.000Z"
  }
}

Error Responses

404 Not Found

Returned when a food with the specified ID does not exist.
{
  "success": false,
  "error": "Alimento não encontrado"
}

400 Bad Request

Returned when the ID parameter is invalid (not a positive integer).
{
  "success": false,
  "error": "Invalid ID format"
}

Notes

  • This endpoint increments the searchCount field each time it’s called (analytics)
  • The search count increment happens asynchronously and won’t affect response time
  • Foods may have FODMAP data, nutrition data, both, or neither
  • The fodmap.search_information field provides transparency about how FODMAP data was matched

Build docs developers (and LLMs) love