---
name: tandoor-manager
description: Manage recipes, meal plans, and shopping lists in a Tandoor instance. Use when searching for recipes, adding new ones, or planning meals.
---

# Tandoor Manager

This skill allows you to interact with a personal Tandoor instance via its REST API. It supports searching for recipes, retrieving details, and managing meal plans.

## Quick Start

### Search for recipes
```bash
./scripts/tandoor_api.sh GET "/api/recipe/?query=Pizza"
```

### Get recipe details
```bash
./scripts/tandoor_api.sh GET "/api/recipe/123/"
```

### Get all PropertyTypes (Eigenschaften wie Carbohydrates, etc.)
```bash
./scripts/tandoor_api.sh GET "/api/property-type/"
```

### Create a minimal recipe
```bash
./scripts/tandoor_api.sh POST "/api/recipe/" '{"name": "New Recipe", "servings": 4}'
```

## Workflows

### 1. Finding and Reading a Recipe
1. Use `GET /api/recipe/?query=NAME` to find the recipe ID.
2. Use `GET /api/recipe/ID/` to get the full details.

### 2. Managing Ingredients & Properties (Eigenschaften)
1. Use `GET /api/food/` to find an ingredient ID.
2. Use `GET /api/property-type/` to see available property definitions (e.g., Protein, Carbohydrates).
3. Update ingredients with nutritional data using IDs from step 2.

### 2b. Sync Nutrition Data from FDC (USDA FoodData Central)
If a food has an `fdc_id` set, you can sync all available nutrition data from the FDC database:
```bash
./scripts/tandoor_api.sh POST "/api/food/{food_id}/fdc/" '{"fdc_id": <FDC_ID>}'
```
**Important:** The `fdc_id` MUST be included in the POST body, even if it's already set on the food object.
- Existing properties with an `fdc_id` will be overwritten with FDC values.
- Existing properties without an `fdc_id` will be left unchanged.
- New properties from FDC will be added if they don't exist.

Example for carrots (food_id=122, fdc_id=2258587):
```bash
./scripts/tandoor_api.sh POST "/api/food/122/fdc/" '{"fdc_id": 2258587}'
```

### 3. Meal Planning
1. Identify the recipe ID.
2. Use `POST /api/meal-plan/` with the recipe ID, date, and meal type.

### 4. Food Hierarchy (Parent-Child)
To organize food items into logical groups:
1. **Set a Parent:** Use the specialized move endpoint.
   ```bash
   ./scripts/tandoor_api.sh PUT "/api/food/{child_id}/move/{parent_id}/"
   ```
2. **Remove Parent (Move to Root):** Use the batch update endpoint.
   ```bash
   ./scripts/tandoor_api.sh PUT "/api/food/batch_update/" '{"foods": [{id}], "parent_remove": true}'
   ```
   *Note: The `parent` field is read-only in standard PATCH requests; these specialized endpoints must be used.*

### 5. Updating Recipes (Steps & Ingredients)
When updating a recipe's structure (adding steps or reassigning ingredients):
1. **Use Recipe Patch:** It is safer to use `PATCH /api/recipe/{id}/` with the `steps` array than updating steps individually.
2. **Flat ID Format:** Always use flat IDs for food and unit in the `ingredients` list to avoid `IntegrityError` (trying to create existing items) or validation failures:
   ```json
   "ingredients": [{"food": 87, "amount": 400, "unit": 2}]
   ```
3. **Mandatory Fields:** When sending `steps`, the `ingredients` field is **required** for every step, even if empty (`[]`).
4. **Layout:** Use `###` headers in `instruction` and set `"show_ingredients_table": true` for a professional look.
5. **CSRF/Referer:** Write operations (POST/PATCH/DELETE) require a `Referer` header matching the server URL (handled by `tandoor_api.sh`).

## Resources
- There is a guideline of good practice when creating and reviewing recipies. **ENSUR THAT YOU READ THIS BEFOR EDITING A RECIPIE!** You find it in ./recipie_guidelines.md

### API Documentation
- **Online (Current):** [https://rezept.papst.beer/openapi/](https://rezept.papst.beer/openapi/)
- **Local Spec:** `references/Tandoor (2.6.6).yaml`

### scripts/tandoor_api.sh
A helper script that automatically handles authentication using the key stored in `.secrets`.

### references/api.md
Full list of available endpoints and common filter examples.
