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/recipesList all your saved recipes
POST
/v1/recipesCreate a new recipe
GET
/v1/recipes/:idGet a specific recipe by ID
PUT
/v1/recipes/:idUpdate an existing recipe
DELETE
/v1/recipes/:idDelete a recipe
Recipe Object
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Recipe name |
calories | number | No | Calories per serving (default: 0) |
protein | number | No | Protein in grams (default: 0) |
carbs | number | No | Carbohydrates in grams (default: 0) |
fat | number | No | Fat in grams (default: 0) |
serving_description | string | No | Description of one serving |
aliases | string[] | No | Alternative 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:
- You create a recipe called "Protein Smoothie" with 320 calories
- You add "morning smoothie" as an alias
- When you estimate "I had my morning smoothie", the API matches it to your recipe and returns exactly 320 calories