Skip to main content
POST
/
api
/
parseIngredients
Parse Ingredients from Text
curl --request POST \
  --url https://api.example.com/api/parseIngredients \
  --header 'Content-Type: application/json' \
  --data '
{
  "text": "<string>"
}
'
{
  "success": true,
  "data": "<string>",
  "error": {
    "code": "<string>",
    "message": "<string>"
  }
}

Overview

The /api/parseIngredients endpoint extracts structured ingredient data from raw HTML or text content. It uses AI to parse ingredients into a structured format with amounts, units, ingredient names, descriptions, and substitutions. This endpoint is useful when you have recipe HTML content but need to extract just the ingredients in a structured format.

Request

text
string
required
Raw HTML or text content containing ingredient information. Maximum 15,000 characters.This can be the full HTML of a recipe page or just the ingredients section.

Response

Success Response

success
boolean
required
Always true for successful responses
data
string
required
JSON string containing the parsed recipe title and ingredients. Parse this string to access the structured data.The parsed structure is an array: [title, ingredientGroups]

Error Response

success
boolean
Always false for error responses
error
object
Error details

Error Codes

ERR_INVALID_URL
Text input is required and must be a string (despite the code name, this is used for input validation)
ERR_NO_RECIPE_FOUND
Text input is empty or no valid recipe found in the provided HTML
ERR_AI_PARSE_FAILED
AI returned invalid response format or no response from AI service
ERR_TIMEOUT
AI service request timed out
ERR_UNKNOWN
AI service is not configured or an unexpected error occurred

Features

This endpoint automatically:
  • Extracts recipe title from HTML
  • Parses ingredient amounts exactly as written (preserves fractions like “2 1/2”)
  • Identifies ingredient units and names
  • Creates logical ingredient groupings (sauce, main, garnish, etc.)
  • Generates descriptions for each ingredient explaining its culinary purpose
  • Suggests 1-3 realistic substitutions for each ingredient

Examples

curl -X POST https://your-domain.com/api/parseIngredients \
  -H "Content-Type: application/json" \
  -d '{
    "text": "<h1>Gochujang Pasta</h1><h2>Ingredients</h2><ul><li>2 tablespoons unsalted butter</li><li>2 cloves garlic, minced</li><li>2 tablespoons gochujang</li><li>1/2 cup heavy cream</li></ul>"
  }'

Success Response Example

{
  "success": true,
  "data": "[\"Gochujang Pasta\", [{\"groupName\": \"For the sauce\", \"ingredients\": [{\"amount\": \"2\", \"units\": \"tablespoons\", \"ingredient\": \"unsalted butter\", \"description\": \"Creates silky base and rich mouthfeel\", \"substitutions\": [\"ghee\", \"olive oil\"]}, {\"amount\": \"2\", \"units\": \"tablespoons\", \"ingredient\": \"gochujang\", \"description\": \"Adds spicy-sweet depth and fermented complexity\", \"substitutions\": [\"sriracha mixed with miso\", \"sambal oelek\"]}]}]]"
}
When parsed, the data field contains:
[
  "Gochujang Pasta",
  [
    {
      "groupName": "For the sauce",
      "ingredients": [
        {
          "amount": "2",
          "units": "tablespoons",
          "ingredient": "unsalted butter",
          "description": "Creates silky base and rich mouthfeel",
          "substitutions": ["ghee", "olive oil"]
        },
        {
          "amount": "2",
          "units": "tablespoons",
          "ingredient": "gochujang",
          "description": "Adds spicy-sweet depth and fermented complexity",
          "substitutions": ["sriracha mixed with miso", "sambal oelek"]
        }
      ]
    }
  ]
]

Error Response Example

{
  "success": false,
  "error": {
    "code": "ERR_NO_RECIPE_FOUND",
    "message": "No valid recipe found in the provided HTML"
  }
}
The input text is limited to the first 15,000 characters. Longer content will be truncated.
This endpoint uses AI and may consume API tokens. Ensure your AI service (Groq) is properly configured with an API key.

Build docs developers (and LLMs) love