# Dilution Calculator API
> Laboratory dilution and molarity maths as an API, computed locally and deterministically. The dilution endpoint solves the standard C1·V1 = C2·V2 relation: give any three of the stock concentration, stock volume, final concentration and final volume and it returns the fourth, plus the volume of stock needed, the diluent to add (V2 − V1) and the dilution factor — and it warns you if the numbers would concentrate rather than dilute. The molarity endpoint ties together moles, molarity, volume, mass and molar mass via moles = molarity × volume(L) and mass = moles × molar mass: pass any sufficient subset (for example a target molarity, volume and molar mass) and it returns how much solute you need, with volumes in litres and millilitres and mass in grams and milligrams. The serial endpoint builds a serial-dilution series from a stock concentration, a dilution factor and a number of steps, giving the concentration at each tube and — if you pass a per-tube total volume — the transfer and diluent volumes for each step. Volumes accept litres, millilitres, centilitres, decilitres and microlitres; mass accepts grams, kilograms, milligrams and micrograms. Everything is computed locally and deterministically, so it is instant and private. Ideal for chemistry and biology lab tools, LIMS and bench apps, education and homework helpers, and pharmacy and pipetting calculators. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is a dilution and molarity calculator; for chemical-compound data and properties use a chemistry API and for the ideal gas law use a gas-law 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/dilution-api/..."
```

## Pricing
- **Free** (Free) — 13,135 calls/Mo, 2 req/s
- **Starter** ($15/Mo) — 22,750 calls/Mo, 8 req/s
- **Pro** ($35/Mo) — 277,500 calls/Mo, 20 req/s
- **Mega** ($73/Mo) — 1,430,000 calls/Mo, 50 req/s

## Endpoints

### Dilution

#### `GET /v1/dilution` — C1·V1 = C2·V2 solver

**Parameters:**
- `c1` (query, optional, string) — Stock concentration Example: `10`
- `v1` (query, optional, string) — Stock volume
- `c2` (query, optional, string) — Final concentration Example: `1`
- `v2` (query, optional, string) — Final volume Example: `100`
- `_` (query, optional, string) — Provide exactly three to solve the fourth

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dilution-api/v1/dilution?c1=10&c2=1&v2=100"
```

**Response:**
```json
{
    "data": {
        "c1": 10,
        "c2": 1,
        "v1": 10,
        "v2": 100,
        "note": "C1·V1 = C2·V2. Concentrations share one unit; volumes share another. Diluent to add = V2 − V1.",
        "solved_for": "v1",
        "diluent_to_add": 90,
        "dilution_factor": 10,
        "stock_volume_needed": 10
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.812Z",
        "request_id": "ba6a5d1d-90dc-4eed-acd4-c46b4f3b309a"
    },
    "status": "ok",
    "message": "C1·V1 = C2·V2 solver",
    "success": true
}
```

#### `GET /v1/molarity` — Molarity / moles / mass

**Parameters:**
- `molarity` (query, optional, string) — Molarity (mol/L) Example: `0.5`
- `volume` (query, optional, string) — Volume Example: `2`
- `volume_unit` (query, optional, string) — l|ml|cl|dl|ul Example: `l`
- `molar_mass` (query, optional, string) — Molar mass (g/mol) Example: `58.44`
- `mass` (query, optional, string) — Mass
- `mass_unit` (query, optional, string) — g|kg|mg|ug Example: `g`
- `moles` (query, optional, string) — Moles

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dilution-api/v1/molarity?molarity=0.5&volume=2&volume_unit=l&molar_mass=58.44&mass_unit=g"
```

**Response:**
```json
{
    "data": {
        "note": "moles = molarity × volume(L); mass = moles × molar mass. Provide any sufficient subset.",
        "moles": 1,
        "mass_mg": 58440,
        "molarity": 0.5,
        "volume_ml": 2000,
        "mass_grams": 58.44,
        "molar_mass": 58.44,
        "volume_litres": 2
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.910Z",
        "request_id": "b8b677af-2b7b-46e5-a42f-d0cc4398e886"
    },
    "status": "ok",
    "message": "Molarity / moles / mass relations",
    "success": true
}
```

#### `GET /v1/serial` — Serial dilution series

**Parameters:**
- `stock_concentration` (query, required, string) — Stock concentration (c0) Example: `1000`
- `dilution_factor` (query, required, string) — Factor per step (e.g. 10) Example: `10`
- `steps` (query, optional, string) — Number of steps (default 5) Example: `3`
- `total_volume` (query, optional, string) — Per-tube volume (for transfer/diluent) Example: `1000`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dilution-api/v1/serial?stock_concentration=1000&dilution_factor=10&steps=3&total_volume=1000"
```

**Response:**
```json
{
    "data": {
        "note": "Each step divides the concentration by the dilution factor. With total_volume, transfer = total/factor and diluent = total − transfer per tube.",
        "steps": 3,
        "series": [
            {
                "step": 1,
                "dilution": "1:10",
                "concentration": 100
            },
            {
                "step": 2,
                "dilution": "1:100",
                "concentration": 10
            },
            {
                "step": 3,
                "dilution": "1:1000",
                "concentration": 1
            }
        ],
        "dilution_factor": 10,
        "per_step_volumes": {
            "total_volume": 1000,
            "diluent_volume": 900,
            "transfer_volume": 100
        },
        "final_concentration": 1,
        "stock_concentration": 1000
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.999Z",
        "request_id": "afcf0d82-7209-49dd-a7c1-6aa9831fa287"
    },
    "status": "ok",
    "message": "Serial dilution series",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "dilution",
        "note": "Laboratory dilution & molarity maths — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/dilution",
            "/v1/molarity",
            "/v1/serial",
            "/v1/meta"
        ],
        "mass_units": [
            "g",
            "kg",
            "mg",
            "ug",
            "µg"
        ],
        "volume_units": [
            "l",
            "litre",
            "liter",
            "ml",
            "cl",
            "dl",
            "ul",
            "µl",
            "microlitre"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:11.092Z",
        "request_id": "9a355b27-87be-440d-947b-387298e28bd4"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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