# Soap Making API
> Soap-making and saponification maths as an API, computed locally and deterministically — the lye-calculator numbers every cold- and hot-process soaper needs, with the safety margin built in. The lye endpoint takes a list of oils as oil:grams pairs (olive, coconut, palm, shea, castor, lard, tallow and a couple of dozen more, each with its standard SAP value) and returns the sodium hydroxide (NaOH) or potassium hydroxide (KOH) to saponify them: lye = Σ(oil grams × SAP) × (1 − superfat), so 1 kg of coconut oil at 5 % superfat needs 169.1 g of NaOH (or 263.6 g of 90 %-pure KOH for liquid soap). It sizes the water by lye-to-water ratio, percentage of oils, or lye-solution concentration, adds the fragrance (a few percent of the oils) and totals the batch weight. The mould endpoint sizes a batch to a mould: oils to fill it ≈ volume(cm³) × 0.40, from a volume or length × width × height. SAP values are grams of NaOH per gram of oil. Everything is computed locally and deterministically, so it is instant and private. Ideal for soap-making, cosmetics, handmade-craft and maker app developers, lye-calculator and recipe tools, and soaping education. Pure local computation — no key, no third-party service, instant. Metric: grams, cm³, percent. Live, nothing stored. 2 compute endpoints. Lye is caustic — wear protection and double-check a new recipe; this is a planning aid.

## 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/soap-api/..."
```

## Pricing
- **Free** (Free) — 5,950 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 58,000 calls/Mo, 6 req/s
- **Pro** ($10/Mo) — 238,000 calls/Mo, 15 req/s
- **Mega** ($32/Mo) — 1,380,000 calls/Mo, 40 req/s

## Endpoints

### Soap

#### `GET /v1/lye` — Lye / water / fragrance

**Parameters:**
- `oils` (query, required, string) — oil:grams pairs, e.g. olive:500,coconut:300 Example: `olive:500,coconut:300,palm:200`
- `superfat` (query, optional, string) — Superfat % (default 5) Example: `5`
- `lye_type` (query, optional, string) — naoh (bar) or koh (liquid) Example: `naoh`
- `koh_purity` (query, optional, string) — KOH purity % (default 90)
- `water_percent` (query, optional, string) — Water as % of oils Example: `38`
- `water_ratio` (query, optional, string) — Or lye:water ratio
- `lye_concentration` (query, optional, string) — Or lye solution %
- `fragrance_percent` (query, optional, string) — Fragrance % of oils (default 4)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/soap-api/v1/lye?oils=olive%3A500%2Ccoconut%3A300%2Cpalm%3A200&superfat=5&lye_type=naoh&water_percent=38"
```

**Response:**
```json
{
    "data": {
        "note": "Lye = Σ(oil grams × SAP) × (1 − superfat). Superfat leaves that % of oils unsaponified for a milder bar. KOH (liquid soap) = NaOH amount × 1.403 ÷ purity. SAP values are g NaOH per g oil.",
        "inputs": {
            "oils": [
                {
                    "name": "olive",
                    "grams": 500
                },
                {
                    "name": "coconut",
                    "grams": 300
                },
                {
                    "name": "palm",
                    "grams": 200
                }
            ],
            "lye_type": "NaOH",
            "superfat_percent": 5
        },
        "lye_type": "NaOH",
        "lye_grams": 141.17,
        "water_grams": 380,
        "water_method": "38% of oils",
        "fragrance_grams": 40,
        "total_oil_grams": 1000,
        "fragrance_percent": 4,
        "batch_weight_grams": 1561.17,
        "lye_solution_grams": 521.17
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:12.606Z",
        "request_id": "aadc1cdb-0f2a-4b1b-b125-b0edec7f5d89"
    },
    "status": "ok",
    "message": "Lye calculator",
    "success": true
}
```

#### `GET /v1/mould` — Mould → oil weight

**Parameters:**
- `volume` (query, optional, string) — Mould volume (cm³, or L×W×H) Example: `1000`
- `length` (query, optional, string) — Length (cm)
- `width` (query, optional, string) — Width (cm)
- `height` (query, optional, string) — Height (cm)
- `oil_density` (query, optional, string) — g oil per cm³ (default 0.40)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/soap-api/v1/mould?volume=1000"
```

**Response:**
```json
{
    "data": {
        "note": "Oils to fill a mould ≈ volume(cm³) × 0.40. Feed this oil weight into /v1/lye (split across your oils by percentage) to size the lye and water.",
        "inputs": {
            "volume": 1000,
            "oil_density": 0.4
        },
        "total_oil_grams": 400,
        "mould_volume_cm3": 1000
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:12.700Z",
        "request_id": "6abdf54f-d73a-434e-8dd8-195217fd1a90"
    },
    "status": "ok",
    "message": "Mould sizing",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec + SAP table

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

**Response:**
```json
{
    "data": {
        "oils": {
            "hemp": 0.1345,
            "lard": 0.138,
            "neem": 0.1387,
            "palm": 0.141,
            "shea": 0.128,
            "olive": 0.134,
            "canola": 0.1241,
            "castor": 0.128,
            "jojoba": 0.069,
            "tallow": 0.14,
            "avocado": 0.133,
            "babassu": 0.175,
            "beeswax": 0.069,
            "coconut": 0.178,
            "soybean": 0.135,
            "grapeseed": 0.1265,
            "rice-bran": 0.128,
            "sunflower": 0.134,
            "palm-kernel": 0.156,
            "cocoa-butter": 0.137,
            "mango-butter": 0.135,
            "sweet-almond": 0.136
        },
        "notes": "Metric: grams, cm³, percent. SAP = g NaOH per g of oil. Always run a new recipe through a trusted lye calculator and wear protection — lye is caustic. KOH for liquid soap, NaOH for bar soap.",
        "service": "soap-api",
        "endpoints": {
            "GET /v1/lye": "Lye, water, fragrance and batch weight from an oils list with superfat.",
            "GET /v1/meta": "This document (includes the supported oils and SAP values).",
            "GET /v1/mould": "Total oil weight to fill a mould volume."
        },
        "description": "Soap-making saponification maths: lye (NaOH/KOH) for a set of oils with superfat, water and fragrance, plus mould sizing."
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:12.799Z",
        "request_id": "ec5dc
…(truncated, see openapi.json for full schema)
```


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