# Water Hammer API
> Water-hammer (hydraulic-transient) maths as an API, computed locally and deterministically — the surge-pressure, wave-speed and valve-timing numbers a piping or plumbing engineer guards a system with. The surge endpoint applies the Joukowsky equation Δp = ρ · a · Δv: a sudden stop of the flow spikes the pressure by the fluid density × the pressure-wave speed × the velocity change — stopping 2 m/s of water at a ≈ 1200 m/s adds about 24 bar (348 psi), far above the line pressure, which is what bangs the pipes and can split fittings. The wave-speed endpoint gives that pressure-wave speed: a = √(K/ρ) in a rigid pipe (≈ 1,480 m/s for water), slowed in a real elastic pipe to √(K/ρ) ÷ √(1 + (K·D)/(E·t)) — a thin or plastic pipe gives a lower wave speed and a gentler surge, which is why PVC tolerates hammer better than steel. The critical-time endpoint gives 2L/a, the round-trip time of the wave: close a valve faster than this and you get the full Joukowsky surge, slower and the returning relief wave eats into it, so sizing closure times (or fitting a surge tank or air chamber) above the critical time is the standard cure. Everything is computed locally and deterministically, so it is instant and private. Ideal for piping- and plumbing-design tools, pump-station and pipeline-surge analysis, and hydraulic-engineering utilities. Pure local computation — no key, no third-party service, instant. Idealised single-pipe transient. 3 compute endpoints. For steady pipe pressure drop use a Darcy API; for pump head and affinity a pump 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/waterhammer-api/..."
```

## Pricing
- **Free** (Free) — 4,900 calls/Mo, 2 req/s
- **Starter** ($13/Mo) — 50,500 calls/Mo, 6 req/s
- **Pro** ($39/Mo) — 216,000 calls/Mo, 15 req/s
- **Mega** ($121/Mo) — 1,125,000 calls/Mo, 40 req/s

## Endpoints

### Hammer

#### `GET /v1/critical-time` — Critical valve-closure time

**Parameters:**
- `pipe_length_m` (query, required, string) — Pipe length (m) Example: `500`
- `wave_speed_m_s` (query, required, string) — Pressure-wave speed (m/s) Example: `1200`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/waterhammer-api/v1/critical-time?pipe_length_m=500&wave_speed_m_s=1200"
```

#### `GET /v1/surge` — Joukowsky surge pressure

**Parameters:**
- `wave_speed_m_s` (query, required, string) — Pressure-wave speed (m/s) Example: `1200`
- `velocity_change_m_s` (query, required, string) — Velocity change (m/s) Example: `2`
- `fluid_density_kg_m3` (query, optional, string) — Fluid density (kg/m³, default 998) Example: `998`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/waterhammer-api/v1/surge?wave_speed_m_s=1200&velocity_change_m_s=2&fluid_density_kg_m3=998"
```

#### `GET /v1/wave-speed` — Pressure-wave speed in a pipe

**Parameters:**
- `fluid_density_kg_m3` (query, optional, string) — Fluid density (kg/m³, default 998) Example: `998`
- `bulk_modulus_gpa` (query, optional, string) — Fluid bulk modulus (GPa, default 2.2) Example: `2.2`
- `pipe_youngs_gpa` (query, optional, string) — Pipe Young's modulus (GPa) Example: `200`
- `pipe_diameter_mm` (query, optional, string) — Pipe inside diameter (mm) Example: `100`
- `wall_thickness_mm` (query, optional, string) — Pipe wall thickness (mm) Example: `5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/waterhammer-api/v1/wave-speed?fluid_density_kg_m3=998&bulk_modulus_gpa=2.2&pipe_youngs_gpa=200&pipe_diameter_mm=100&wall_thickness_mm=5"
```

### Meta

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

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


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