# pH Calculator API
> pH and acid–base maths as an API, computed locally and deterministically. The ph endpoint converts freely between the four ways of describing acidity — the pH, the pOH, the hydronium-ion concentration [H+] and the hydroxide concentration [OH−]: give any one and it returns the others using pH = −log₁₀[H+], [OH−] = Kw/[H+] and pH + pOH = pKw, and classifies the solution as acidic, neutral or basic. The strong endpoint gives the pH of a strong acid or strong base from its molarity ([H+] = c for an acid, [OH−] = c for a base), warning when the solution is so dilute that water self-ionisation matters. The buffer endpoint applies the Henderson–Hasselbalch equation, pH = pKa + log₁₀([A−]/[HA]), to a buffer from a pKa and the conjugate-base-to-acid ratio (given directly or as two concentrations), and also handles a base buffer from a pKb. Kw defaults to 1×10⁻¹⁴ (25 °C) and can be overridden for other temperatures. Everything is computed locally and deterministically, so it is instant and private. Ideal for chemistry and biology lab tools, titration and buffer-prep apps, water-treatment and aquarium software, and science education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is pH and acid–base chemistry; for solution dilution and molarity use a dilution 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/phcalc-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 30,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($49/Mo) — 2,000,000 calls/Mo, 40 req/s

## Endpoints

### pH

#### `GET /v1/buffer` — Henderson–Hasselbalch buffer

**Parameters:**
- `pka` (query, optional, string) — pKa (acid buffer) Example: `4.76`
- `pkb` (query, optional, string) — Or pKb (base buffer)
- `ratio` (query, optional, string) — Conjugate-base/acid ratio Example: `10`
- `conjugate_base` (query, optional, string) — Or [A−] concentration
- `acid` (query, optional, string) — And [HA] concentration

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/phcalc-api/v1/buffer?pka=4.76&ratio=10"
```

**Response:**
```json
{
    "data": {
        "pH": 5.76,
        "pKa": 4.76,
        "pOH": 8.24,
        "mode": "acid_buffer",
        "formula": "pH = pKa + log10([A−]/[HA]).",
        "classification": "acidic",
        "ratio_base_over_acid": 10
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:55.903Z",
        "request_id": "400a1044-abfb-47c6-8c6a-bdb50da724bd"
    },
    "status": "ok",
    "message": "Henderson-Hasselbalch buffer",
    "success": true
}
```

#### `GET /v1/ph` — pH / pOH / [H+] / [OH−] conversion

**Parameters:**
- `ph` (query, optional, string) — pH
- `poh` (query, optional, string) — Or pOH
- `hydronium` (query, optional, string) — Or [H+] (mol/L) Example: `0.001`
- `hydroxide` (query, optional, string) — Or [OH−] (mol/L)
- `kw` (query, optional, string) — Water ion product (default 1e-14)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/phcalc-api/v1/ph?hydronium=0.001"
```

**Response:**
```json
{
    "data": {
        "pH": 3,
        "pKw": 14,
        "pOH": 11,
        "note": "pH = −log10[H+]; [OH−] = Kw/[H+]; pH + pOH = pKw (14 at 25 °C).",
        "classification": "acidic",
        "hydronium_concentration": 0.001,
        "hydroxide_concentration": 1.0e-11
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:56.018Z",
        "request_id": "573b8aef-f0e4-4f71-b132-06d27f37aa9e"
    },
    "status": "ok",
    "message": "pH / pOH / [H+] / [OH-] conversion",
    "success": true
}
```

#### `GET /v1/strong` — pH of a strong acid or base

**Parameters:**
- `type` (query, optional, string) — acid|base (default acid) Example: `acid`
- `concentration` (query, required, string) — Molarity (mol/L) Example: `0.01`
- `kw` (query, optional, string) — Kw (default 1e-14)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/phcalc-api/v1/strong?type=acid&concentration=0.01"
```

**Response:**
```json
{
    "data": {
        "pH": 2,
        "pOH": 12,
        "type": "acid",
        "formula": "strong acid: [H+] = c, pH = −log10(c).",
        "concentration": 0.01,
        "classification": "acidic",
        "hydronium_concentration": 0.01,
        "hydroxide_concentration": 1.0e-12
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:56.124Z",
        "request_id": "fe87ebc9-0ae0-4c6c-9025-b744fc8eeb37"
    },
    "status": "ok",
    "message": "pH of a strong acid or base",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "phcalc",
        "note": "pH / acid-base maths — computed locally and deterministically, no key, no third-party service. Kw defaults to 1e-14 (25 °C).",
        "endpoints": [
            "/v1/ph",
            "/v1/strong",
            "/v1/buffer",
            "/v1/meta"
        ],
        "default_pKw": 14
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:56.228Z",
        "request_id": "f896586d-a878-498b-9421-de4f9c91a44e"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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