# Hydroponics API
> Hydroponics and indoor-grow maths as an API, computed locally and deterministically — the nutrient-strength and grow-light numbers a grower dials in every day. The ec endpoint converts between electrical conductivity (EC in mS/cm) and the PPM/TDS reading on whichever scale a meter uses: the 500 (NaCl, US) scale turns EC 2.0 into 1000 ppm, the 700 (KCl) scale into 1400 ppm and the 640 (EU) scale into 1280 — the source of endless confusion between meters. The dli endpoint computes the Daily Light Integral, DLI = PPFD × photoperiod × 3600 ÷ 1,000,000, the total moles of light a crop gets in a day (leafy greens want about 12–17, fruiting crops 20–30+), and reverses it to the PPFD a fixture must deliver to hit a target DLI over a given day length. The reservoir endpoint balances a tank to a target EC: how much plain water to add to dilute a too-strong solution (W = V × (current/target − 1)), or how much concentrated stock to add to raise it. Everything is computed locally and deterministically, so it is instant and private. Ideal for hydroponics, vertical-farming, controlled-environment-agriculture, grow-room and smart-garden app developers, dosing and lighting tools, and horticulture education. Pure local computation — no key, no third-party service, instant. EC in mS/cm, volume in litres, PPFD in µmol/m²/s. Live, nothing stored. 3 compute endpoints. State your TDS scale; confirm with a calibrated meter.

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

## Pricing
- **Free** (Free) — 4,250 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 45,000 calls/Mo, 6 req/s
- **Pro** ($15/Mo) — 207,000 calls/Mo, 15 req/s
- **Mega** ($46/Mo) — 1,175,000 calls/Mo, 40 req/s

## Endpoints

### Hydroponics

#### `GET /v1/dli` — DLI from PPFD

**Parameters:**
- `ppfd` (query, optional, string) — PPFD in µmol/m²/s (or target_dli) Example: `600`
- `photoperiod` (query, required, string) — Light hours per day Example: `18`
- `target_dli` (query, optional, string) — Target DLI (for required PPFD)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydroponics-api/v1/dli?ppfd=600&photoperiod=18"
```

**Response:**
```json
{
    "data": {
        "dli": 38.88,
        "note": "DLI (mol/m²/day) = PPFD (µmol/m²/s) × photoperiod(h) × 3600 ÷ 1,000,000. Leafy greens want ~12–17, fruiting crops ~20–30+.",
        "inputs": {
            "ppfd": 600,
            "photoperiod": 18
        }
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:44.969Z",
        "request_id": "760d0282-3e28-43b4-a2b1-60e1dd00de43"
    },
    "status": "ok",
    "message": "DLI from PPFD",
    "success": true
}
```

#### `GET /v1/ec` — EC ↔ PPM/TDS

**Parameters:**
- `ec` (query, optional, string) — EC in mS/cm (or use ppm) Example: `2.0`
- `ppm` (query, optional, string) — PPM/TDS (or use ec)
- `scale` (query, optional, string) — 500/nacl, 700/kcl, 640/eu Example: `700`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydroponics-api/v1/ec?ec=2.0&scale=700"
```

**Response:**
```json
{
    "data": {
        "ppm": 1400,
        "note": "PPM = EC(mS/cm) × scale factor. The 500 (NaCl, US) scale gives EC 2.0 → 1000 ppm; the 700 (KCl) scale → 1400 ppm; the 640 (EU) scale → 1280 ppm.",
        "inputs": {
            "scale": "700",
            "factor": 700
        },
        "ec_ms_cm": 2,
        "ec_microsiemens": 2000
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:45.071Z",
        "request_id": "0e64f99a-bda8-4e29-8f13-8a00c393c79d"
    },
    "status": "ok",
    "message": "EC/PPM conversion",
    "success": true
}
```

#### `GET /v1/reservoir` — Adjust reservoir EC

**Parameters:**
- `volume` (query, required, string) — Reservoir volume (litres) Example: `100`
- `current_ec` (query, required, string) — Current EC (mS/cm) Example: `2.4`
- `target_ec` (query, required, string) — Target EC (mS/cm) Example: `1.6`
- `stock_ec` (query, optional, string) — Stock EC for raising

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydroponics-api/v1/reservoir?volume=100&current_ec=2.4&target_ec=1.6"
```

**Response:**
```json
{
    "data": {
        "note": "To lower EC, add plain water: W = V × (current/target − 1). Mixing conserves total dissolved salts, so EC × volume stays constant.",
        "action": "dilute",
        "inputs": {
            "volume": 100,
            "target_ec": 1.6,
            "current_ec": 2.4
        },
        "add_water_liters": 50,
        "final_volume_liters": 150
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:45.146Z",
        "request_id": "79911e27-6eca-4dd1-9167-d3587088b294"
    },
    "status": "ok",
    "message": "Reservoir adjust",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "EC in mS/cm, PPM as mg/L, volume in litres, PPFD in µmol/m²/s, photoperiod in hours. PPM depends on the TDS scale — always state which. This is a growing aid; confirm with a calibrated meter.",
        "service": "hydroponics-api",
        "endpoints": {
            "GET /v1/ec": "Convert between EC (mS/cm) and PPM/TDS on the 500/700/640 scale.",
            "GET /v1/dli": "Daily Light Integral from PPFD and photoperiod, or the PPFD needed for a target DLI.",
            "GET /v1/meta": "This document.",
            "GET /v1/reservoir": "Water to add to dilute to a target EC, or stock to concentrate."
        },
        "description": "Hydroponics / indoor-grow maths: EC↔PPM nutrient strength, grow-light DLI from PPFD, and reservoir dilution to a target EC."
    },
    "meta": {
        "timestamp": "2026-06-05T21:48:45.229Z",
        "request_id": "75670cde-8227-44e7-bae8-77faa1f83573"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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