# Hydration Calculator API
> Hydration and fluid-balance maths as an API, computed locally and deterministically. The daily endpoint estimates the daily fluid need from bodyweight (about 35 ml per kilogram), the minutes of exercise (about 12 ml per minute) and the climate (hot adds 500 ml, very hot 1000 ml, cold subtracts 200 ml), reported in millilitres, litres and 250 ml glasses. The sweat endpoint computes the sweat rate and the degree of dehydration from a before-and-after body weight, the fluid drunk and the duration — sweat loss = (pre − post) + intake − urine, with 1 kg of lost mass treated as 1 litre, and it flags when losses pass the 2 % of body mass where performance falls off. The rehydrate endpoint computes the post-exercise rehydration target, about 1.5 times the fluid deficit to cover ongoing urine losses, with a sodium note for larger losses. Everything is computed locally and deterministically, so it is instant and private. Ideal for fitness, sports and wellness app developers, endurance-training and hydration-reminder tools, and health dashboards. Pure local computation — no key, no third-party service, instant. Live, nothing stored. General guidance, not medical advice. 3 endpoints. This is fluid balance; for basal calories use a BMR API and for heart-rate zones use a heart-rate 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/hydration-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($12/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($39/Mo) — 1,516,000 calls/Mo, 40 req/s

## Endpoints

### Hydration

#### `GET /v1/daily` — Daily fluid need

**Parameters:**
- `weight` (query, required, string) — Bodyweight (kg) Example: `70`
- `activity_minutes` (query, optional, string) — Exercise minutes (default 0) Example: `30`
- `climate` (query, optional, string) — temperate | hot | very_hot | cold Example: `temperate`
- `ml_per_kg` (query, optional, string) — ml per kg (default 35) Example: `35`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydration-api/v1/daily?weight=70&activity_minutes=30&climate=temperate&ml_per_kg=35"
```

**Response:**
```json
{
    "data": {
        "note": "≈ 35 ml/kg baseline + 12 ml per minute of exercise + climate adjustment (hot +500, very_hot +1000, cold −200 ml).",
        "inputs": {
            "weight": 70,
            "climate": "temperate",
            "ml_per_kg": 35,
            "activity_minutes": 30
        },
        "total_ml": 2810,
        "climate_ml": 0,
        "activity_ml": 360,
        "baseline_ml": 2450,
        "total_litres": 2.81,
        "glasses_250ml": 11.24
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:20.711Z",
        "request_id": "1afd7374-cd5e-4daa-a80e-0e1ce7a67f83"
    },
    "status": "ok",
    "message": "Daily fluid need",
    "success": true
}
```

#### `GET /v1/rehydrate` — Rehydration target

**Parameters:**
- `fluid_loss` (query, optional, string) — Fluid deficit (L) Example: `1.5`
- `pre_weight` (query, optional, string) — Or weight before (kg)
- `post_weight` (query, optional, string) — and weight after (kg)
- `replacement_factor` (query, optional, string) — Replacement factor (default 1.5) Example: `1.5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydration-api/v1/rehydrate?fluid_loss=1.5&replacement_factor=1.5"
```

**Response:**
```json
{
    "data": {
        "note": "Drink about 1.5× the fluid deficit over the hours after exercise to fully rehydrate (extra covers ongoing urine loss).",
        "inputs": {
            "replacement_factor": 1.5,
            "fluid_deficit_litres": 1.5
        },
        "sodium_note": "For losses over ~2 % body mass, include sodium (~0.5–0.7 g/L) to retain the fluid.",
        "glasses_250ml": 9,
        "rehydration_target_ml": 2250,
        "rehydration_target_litres": 2.25
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:20.801Z",
        "request_id": "f7eaae2b-f3b7-4ca5-b59c-5a62c518f434"
    },
    "status": "ok",
    "message": "Rehydration target",
    "success": true
}
```

#### `GET /v1/sweat` — Sweat rate

**Parameters:**
- `pre_weight` (query, required, string) — Weight before (kg) Example: `70`
- `post_weight` (query, required, string) — Weight after (kg) Example: `68.5`
- `duration` (query, required, string) — Duration (hours) Example: `1`
- `fluid_intake` (query, optional, string) — Fluid drunk during (L, default 0) Example: `0.5`
- `urine` (query, optional, string) — Urine voided (L, default 0) Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hydration-api/v1/sweat?pre_weight=70&post_weight=68.5&duration=1&fluid_intake=0.5&urine=0"
```

**Response:**
```json
{
    "data": {
        "note": "Sweat loss = (pre − post) + fluid intake − urine, 1 kg ≈ 1 L. Performance drops noticeably past 2 % body-mass loss.",
        "inputs": {
            "duration": 1,
            "pre_weight": 70,
            "post_weight": 68.5,
            "fluid_intake": 0.5
        },
        "dehydration_flag": "significant (>=2% body mass)",
        "sweat_loss_litres": 2,
        "sweat_rate_l_per_h": 2,
        "body_mass_loss_percent": 2.143
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:20.901Z",
        "request_id": "e7d1c448-f06a-4830-9216-31341aea5d0e"
    },
    "status": "ok",
    "message": "Sweat rate",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Weight in kg, volume in litres, time in hours, 1 kg of mass loss ≈ 1 L of fluid. General guidance — individual needs vary; not medical advice.",
        "service": "hydration-api",
        "formulae": {
            "daily": "≈ 35 ml/kg + 12 ml/min activity + climate",
            "sweat": "loss = (pre − post) + intake − urine,  rate = loss/hours",
            "rehydrate": "target = 1.5 × deficit"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/daily": "Daily fluid need from weight, exercise minutes and climate.",
            "GET /v1/sweat": "Sweat rate and dehydration percentage from before/after weights.",
            "GET /v1/rehydrate": "Rehydration volume (1.5× the fluid deficit) after exercise."
        },
        "description": "Hydration and fluid-balance calculator: daily water needs, sweat rate from body-mass change, and post-exercise rehydration targets."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:21.008Z",
        "request_id": "f65cc29e-80e7-4f79-8f74-16e52298aecd"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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