# Scuba Diving API
> Scuba-diving and gas-planning maths as an API, computed locally and deterministically. The nitrox endpoint takes an oxygen fraction and returns the maximum operating depth (MOD) for a ppO2 limit (1.4 working, 1.6 contingency), and, for a given depth, the oxygen partial pressure, the equivalent air depth (EAD), whether the mix is within its limit and the best mix for that depth — EAN32 has a MOD of 33.75 m at 1.4 and an EAD of 24.4 m at 30 m. The gas endpoint plans breathing gas from a surface air consumption (SAC/RMV) rate: it scales consumption to depth (consumption = SAC × (1 + depth/10)), gives the litres a planned dive needs and the cylinder duration on the available gas down to a reserve, and can derive your SAC from a logged dive's pressure drop, cylinder size and time. The pressure endpoint gives the ambient pressure and the partial pressure of every gas at depth, plus the equivalent narcotic depth (END) for any blend including trimix — helium is non-narcotic, so it cuts narcosis. Metric throughout: depth in metres of sea water, where 10 m ≈ 1 bar. Everything is computed locally and deterministically, so it is instant and private. Ideal for dive-planning, dive-log, freediving and scuba-training app developers, nitrox and trimix calculators, and dive-education tools. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 compute endpoints. This is dive-planning maths, not a decompression-model NDL — always cross-check with tables or a dive computer.

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

## Pricing
- **Free** (Free) — 3,750 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 44,500 calls/Mo, 6 req/s
- **Pro** ($13/Mo) — 215,000 calls/Mo, 15 req/s
- **Mega** ($40/Mo) — 1,210,000 calls/Mo, 40 req/s

## Endpoints

### Scuba

#### `GET /v1/gas` — Gas planning / SAC

**Parameters:**
- `depth` (query, required, string) — Depth in metres Example: `20`
- `sac` (query, optional, string) — Surface air consumption (L/min) Example: `20`
- `time_min` (query, optional, string) — Planned bottom time (min) Example: `30`
- `cylinder_liters` (query, optional, string) — Cylinder volume (L) Example: `12`
- `start_bar` (query, optional, string) — Start pressure (bar) Example: `200`
- `end_bar` (query, optional, string) — End pressure (bar, to derive SAC)
- `reserve_bar` (query, optional, string) — Reserve pressure (bar)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/scuba-api/v1/gas?depth=20&sac=20&time_min=30&cylinder_liters=12&start_bar=200"
```

**Response:**
```json
{
    "data": {
        "note": "Consumption at depth = SAC·(1+depth/10). Gas required = that × time. Duration = available gas ÷ consumption at depth. SAC can be derived from a logged dive.",
        "inputs": {
            "depth": 20,
            "time_min": 30,
            "cylinder_liters": 12
        },
        "derived_sac": false,
        "duration_min": 40,
        "sac_liters_per_min": 20,
        "gas_required_liters": 1800,
        "ambient_pressure_ata": 3,
        "available_gas_liters": 2400,
        "consumption_liters_per_min_at_depth": 60
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:49.639Z",
        "request_id": "474ab975-86f7-48d9-a044-0788ce37fdb6"
    },
    "status": "ok",
    "message": "Gas planning",
    "success": true
}
```

#### `GET /v1/nitrox` — Nitrox MOD, EAD, best mix

**Parameters:**
- `o2` (query, required, string) — O2 fraction (0.32) or percent (32) Example: `32`
- `depth` (query, optional, string) — Depth in metres (for EAD/ppO2/best mix) Example: `30`
- `ppo2_max` (query, optional, string) — ppO2 limit (default 1.4) Example: `1.4`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/scuba-api/v1/nitrox?o2=32&depth=30&ppo2_max=1.4"
```

**Response:**
```json
{
    "data": {
        "note": "ppO2 = FO2·(1+depth/10). MOD is the depth where ppO2 hits the limit (1.4 working, 1.6 contingency). EAD matches the nitrox N2 partial pressure to an air depth.",
        "inputs": {
            "o2": 0.32,
            "depth": 30,
            "ppo2_max": 1.4
        },
        "ppn2_ata": 2.72,
        "ppo2_ata": 1.28,
        "ead_meters": 24.43,
        "mod_meters": 33.75,
        "o2_percent": 32,
        "within_limit": true,
        "best_mix_o2_percent": 35,
        "ambient_pressure_ata": 4
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:49.734Z",
        "request_id": "8ef1f6e7-8b21-49fc-b3d5-32c13aa11e39"
    },
    "status": "ok",
    "message": "Nitrox limits",
    "success": true
}
```

#### `GET /v1/pressure` — Partial pressures + END

**Parameters:**
- `depth` (query, required, string) — Depth in metres Example: `40`
- `o2` (query, optional, string) — O2 fraction/percent (default 0.21) Example: `0.21`
- `he` (query, optional, string) — Helium fraction/percent (trimix) Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/scuba-api/v1/pressure?depth=40&o2=0.21&he=0"
```

**Response:**
```json
{
    "data": {
        "note": "Ambient pressure P = 1 + depth/10 (ata); each gas's partial pressure = fraction·P. END matches the N2 narcosis to an air depth — helium is non-narcotic, so a trimix lowers it.",
        "inputs": {
            "he": 0,
            "o2": 0.21,
            "depth": 40
        },
        "pphe_ata": 0,
        "ppn2_ata": 3.95,
        "ppo2_ata": 1.05,
        "n2_fraction": 0.79,
        "ambient_pressure_ata": 5,
        "equivalent_narcotic_depth_meters": 40
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:49.836Z",
        "request_id": "e91d8f76-09ea-42d2-bcde-977188cca88b"
    },
    "status": "ok",
    "message": "Partial pressures",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Metric: depth in metres of sea water, 10 m ≈ 1 bar, P = 1 + depth/10 (ata). O2/He accepted as a fraction (0.32) or percent (32). This is dive-planning maths, not a decompression-model NDL — always cross-check with tables/a computer.",
        "service": "scuba-api",
        "endpoints": {
            "GET /v1/gas": "Gas consumption, requirement and cylinder duration from a SAC/RMV rate (or derive SAC from a logged dive).",
            "GET /v1/meta": "This document.",
            "GET /v1/nitrox": "MOD, EAD, ppO2 and best mix for a nitrox blend.",
            "GET /v1/pressure": "Ambient pressure, partial pressures and equivalent narcotic depth for any mix (incl. trimix)."
        },
        "description": "Scuba-diving maths: nitrox limits (MOD, EAD, best mix, ppO2), gas planning (SAC consumption and cylinder duration) and partial pressures with equivalent narcotic depth."
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:49.922Z",
        "request_id": "03c4bb8c-c97c-4dc9-98a3-8ce3ebad2563"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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