MacroEstimator

Recipes Endpoint

Create and manage custom recipes for consistent nutrition tracking. When you estimate nutrition for a food that matches one of your saved recipes, the API will use your custom nutrition data.

Endpoints

GET/v1/recipes

List all your saved recipes

POST/v1/recipes

Create a new recipe

GET/v1/recipes/:id

Get a specific recipe by ID

PUT/v1/recipes/:id

Update an existing recipe

DELETE/v1/recipes/:id

Delete a recipe

Recipe Object

FieldTypeRequiredDescription
namestringYesRecipe name
caloriesnumberNoCalories per serving (default: 0)
proteinnumberNoProtein in grams (default: 0)
carbsnumberNoCarbohydrates in grams (default: 0)
fatnumberNoFat in grams (default: 0)
serving_descriptionstringNoDescription of one serving
aliasesstring[]NoAlternative names for matching

List Recipes

curl "https://api.macroestimator.com/v1/recipes" \
  -H "Authorization: Bearer YOUR_API_KEY"
Responsejson
{
  "recipes": [
    {
      "id": "abc123",
      "name": "Mom's Lasagna",
      "calories": 450,
      "protein": 28,
      "carbs": 42,
      "fat": 18,
      "serving_description": "1 piece (4x4 inches)",
      "aliases": ["lasagna", "family lasagna"],
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Create Recipe

curl -X POST "https://api.macroestimator.com/v1/recipes" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Protein Smoothie",
    "calories": 320,
    "protein": 35,
    "carbs": 28,
    "fat": 8,
    "serving_description": "1 large glass (16oz)",
    "aliases": ["morning smoothie", "gym smoothie"]
  }'
Response (201 Created)json
{
  "id": "def456",
  "name": "Protein Smoothie",
  "message": "Recipe created"
}

Update Recipe

curl -X PUT "https://api.macroestimator.com/v1/recipes/def456" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "calories": 340,
    "protein": 38
  }'
Responsejson
{
  "id": "def456",
  "message": "Recipe updated"
}

Delete Recipe

curl -X DELETE "https://api.macroestimator.com/v1/recipes/def456" \
  -H "Authorization: Bearer YOUR_API_KEY"
Responsejson
{
  "message": "Recipe deleted"
}

How Recipes Work with Estimates

When you submit an estimate request, the API will automatically check if any food mentioned matches one of your saved recipes (by name or alias). If a match is found, your custom nutrition data is used instead of the AI estimation.

Example:

  1. You create a recipe called "Protein Smoothie" with 320 calories
  2. You add "morning smoothie" as an alias
  3. When you estimate "I had my morning smoothie", the API matches it to your recipe and returns exactly 320 calories