# Food Cost API
> Restaurant food-costing maths as an API, computed locally and deterministically — the menu-engineering and cost-control numbers a kitchen runs on. The recipe endpoint totals a dish from its ingredient line costs (or quantities × unit prices), divides by the yield factor (1 − waste %) so trim and shrinkage raise the true cost, and splits it across the portions to a cost per plate — and against a menu price it returns the food-cost percentage and gross profit. The plate endpoint prices a dish both ways: give a menu price and get the food-cost percentage and markup factor, or give a target food-cost percentage and get the suggested menu price (a 30 % target is a 3.33× markup), plus gross profit, gross margin and, with a labour cost, the prime-cost percentage. The period endpoint turns inventory movement into the cost of goods sold — COGS = opening inventory + purchases − closing inventory — and the food or pour cost percentage against sales, the headline number on every P&L (28–35 % for food, 18–24 % for beverage). Everything is computed locally and deterministically, so it is instant and private. Ideal for restaurant-tech, POS, kitchen-management, catering and hospitality app developers, menu-engineering and recipe-costing tools, and culinary-school training. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 compute endpoints. This is food-cost and menu-pricing maths; for unit conversion use a cooking API and for generic margin maths a pricing API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/foodcost-api/..."
```

## Pricing
- **Free** (Free) — 4,750 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 48,000 calls/Mo, 6 req/s
- **Pro** ($13/Mo) — 223,000 calls/Mo, 15 req/s
- **Mega** ($42/Mo) — 1,300,000 calls/Mo, 40 req/s

## Endpoints

### FoodCost

#### `GET /v1/period` — Period COGS & food cost %

**Parameters:**
- `opening_inventory` (query, required, string) — Opening inventory value Example: `5000`
- `purchases` (query, required, string) — Purchases in period Example: `12000`
- `closing_inventory` (query, required, string) — Closing inventory value Example: `4000`
- `sales` (query, required, string) — Food (or beverage) sales Example: `40000`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/foodcost-api/v1/period?opening_inventory=5000&purchases=12000&closing_inventory=4000&sales=40000"
```

**Response:**
```json
{
    "data": {
        "cogs": 13000,
        "note": "COGS = opening inventory + purchases − closing inventory. Food (or pour) cost % = COGS / sales — typically 28–35% for food, 18–24% for beverage.",
        "inputs": {
            "sales": 40000,
            "purchases": 12000,
            "closing_inventory": 4000,
            "opening_inventory": 5000
        },
        "cost_percent": 32.5,
        "gross_profit": 27000,
        "gross_profit_percent": 67.5
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:47.797Z",
        "request_id": "116584e5-8435-4288-9bff-bf23a34fba2a"
    },
    "status": "ok",
    "message": "Period COGS",
    "success": true
}
```

#### `GET /v1/plate` — Menu pricing & food-cost %

**Parameters:**
- `plate_cost` (query, required, string) — Cost per plate Example: `1.25`
- `menu_price` (query, optional, string) — Menu price (or target_food_cost_percent)
- `target_food_cost_percent` (query, optional, string) — Target food-cost % Example: `30`
- `labor_cost` (query, optional, string) — Labour cost per plate (for prime cost)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/foodcost-api/v1/plate?plate_cost=1.25&target_food_cost_percent=30"
```

**Response:**
```json
{
    "data": {
        "note": "Menu price = plate cost / target food-cost %. A 30% target means a 3.33x markup. Prime cost (food + labour) under ~60% of sales is the usual benchmark.",
        "inputs": {
            "plate_cost": 1.25
        },
        "gross_profit": 2.92,
        "markup_factor": 3.3333,
        "gross_margin_percent": 70,
        "suggested_menu_price": 4.17,
        "target_food_cost_percent": 30
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:47.898Z",
        "request_id": "50874672-2d72-490d-8baa-d16dd4acf4c2"
    },
    "status": "ok",
    "message": "Plate pricing",
    "success": true
}
```

#### `GET /v1/recipe` — Recipe & per-portion cost

**Parameters:**
- `costs` (query, optional, string) — Comma list of ingredient line costs Example: `2.50,1.20,0.80`
- `quantities` (query, optional, string) — Comma list of quantities (with unit_prices)
- `unit_prices` (query, optional, string) — Comma list of unit prices
- `portions` (query, optional, string) — Number of portions (default 1) Example: `4`
- `waste_percent` (query, optional, string) — Yield loss % (default 0) Example: `10`
- `menu_price` (query, optional, string) — Menu price (for food-cost %)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/foodcost-api/v1/recipe?costs=2.50%2C1.20%2C0.80&portions=4&waste_percent=10"
```

**Response:**
```json
{
    "data": {
        "note": "Recipe cost = Σ ingredient line costs, divided by the yield factor (1 − waste%) and the portions. Yield loss raises the true cost per usable plate.",
        "inputs": {
            "portions": 4,
            "ingredients": 3,
            "waste_percent": 10
        },
        "raw_cost": 4.5,
        "cost_per_portion": 1.25,
        "yield_adjusted_cost": 5
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:48.001Z",
        "request_id": "6be51d9c-4bd2-4d53-8244-733349dc24b3"
    },
    "status": "ok",
    "message": "Recipe cost",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/foodcost-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "One consistent currency in, costs and percentages out. Ingredient costs can be line costs or quantities × unit prices. For generic margin maths use a margin API and for unit conversion a cooking API.",
        "service": "foodcost-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/plate": "Menu price ↔ food-cost %, gross profit, markup and prime cost.",
            "GET /v1/period": "Period COGS and food/pour cost % from inventory and sales.",
            "GET /v1/recipe": "Recipe cost and cost per portion from ingredient costs and yield loss."
        },
        "description": "Restaurant food-costing maths: recipe/plate costing with yield loss, menu pricing to a target food-cost %, and period cost of goods (food & pour cost)."
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:48.098Z",
        "request_id": "dabc119c-a8b4-4124-9d45-f33c63faad7a"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/foodcost-api
OpenAPI spec: https://www.oanor.com/api/foodcost-api/openapi.json
