# Weir Flow API
> Weir flow maths for open-channel discharge measurement as an API, computed locally and deterministically. The rectangular endpoint computes the flow over a rectangular sharp-crested weir, Q = (2/3)·Cd·b·√(2g)·H^1.5, from the crest width and the head of water above the crest — and solves the head back from a known discharge. The vnotch endpoint computes the flow over a triangular V-notch weir, Q = (8/15)·Cd·√(2g)·tan(θ/2)·H^2.5, from the notch angle and head, the most accurate weir for small flows because the discharge varies with the head to the power 2.5. The broadcrested endpoint computes the flow over a broad-crested weir, Q = Cd·(2/3)^1.5·√g·b·H^1.5 ≈ Cd·1.705·b·H^1.5, the rugged field structure used for river gauging. Each device carries its standard discharge coefficient (rectangular 0.62, V-notch 0.58, broad-crested 0.85) which you can override, and each solves either the discharge from a measured head or the head required for a target discharge. Everything is computed locally and deterministically, so it is instant and private. Ideal for hydrology, irrigation and civil-engineering tools, flow gauging in channels and treatment plants, stormwater and water-resource apps, and fluid-mechanics education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is weir overflow discharge; for uniform open-channel flow use a Manning API and for differential-pressure pipe metering use an orifice 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/weir-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 15,000 calls/Mo, 5 req/s
- **Pro** ($24/Mo) — 90,000 calls/Mo, 15 req/s
- **Mega** ($74/Mo) — 500,000 calls/Mo, 50 req/s

## Endpoints

### Weir

#### `GET /v1/broadcrested` — Broad-crested weir

**Parameters:**
- `crest_width` (query, required, string) — Crest width b (m) Example: `2`
- `head` (query, optional, string) — Head above crest H (m) Example: `0.3`
- `discharge` (query, optional, string) — Or a known discharge (m³/s) to solve H
- `discharge_coefficient` (query, optional, string) — Cd (default 0.85) Example: `0.85`
- `gravity` (query, optional, string) — Gravity g (m/s², default 9.81) Example: `9.81`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/weir-api/v1/broadcrested?crest_width=2&head=0.3&discharge_coefficient=0.85&gravity=9.81"
```

**Response:**
```json
{
    "data": {
        "note": "Q = Cd·(2/3)^1.5·√g·b·H^1.5 ≈ Cd·1.705·b·H^1.5. Broad-crested weir; Cd≈0.85.",
        "type": "broad-crested",
        "head_m": 0.3,
        "inputs": {
            "gravity": 9.81,
            "crest_width": 2,
            "discharge_coefficient": 0.85
        },
        "solved_for": null,
        "discharge_l_s": 476.2428,
        "discharge_m3_s": 0.4762428,
        "coefficient_constant": 1.704895
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:27.884Z",
        "request_id": "f8cd3934-d373-4565-9634-d541d2ff1eb8"
    },
    "status": "ok",
    "message": "Broad-crested weir",
    "success": true
}
```

#### `GET /v1/rectangular` — Rectangular weir

**Parameters:**
- `crest_width` (query, required, string) — Crest width b (m) Example: `2`
- `head` (query, optional, string) — Head above crest H (m) Example: `0.3`
- `discharge` (query, optional, string) — Or a known discharge (m³/s) to solve H
- `discharge_coefficient` (query, optional, string) — Cd (default 0.62) Example: `0.62`
- `gravity` (query, optional, string) — Gravity g (m/s², default 9.81) Example: `9.81`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/weir-api/v1/rectangular?crest_width=2&head=0.3&discharge_coefficient=0.62&gravity=9.81"
```

**Response:**
```json
{
    "data": {
        "note": "Q = (2/3)·Cd·b·√(2g)·H^1.5. Sharp-crested suppressed weir; Cd≈0.62.",
        "type": "rectangular",
        "head_m": 0.3,
        "inputs": {
            "gravity": 9.81,
            "crest_width": 2,
            "discharge_coefficient": 0.62
        },
        "solved_for": null,
        "discharge_l_s": 601.67478,
        "discharge_m3_s": 0.60167478
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:27.998Z",
        "request_id": "d5c18d04-70d5-479d-9471-8a21cb356b6a"
    },
    "status": "ok",
    "message": "Rectangular weir",
    "success": true
}
```

#### `GET /v1/vnotch` — V-notch weir

**Parameters:**
- `angle` (query, optional, string) — Notch angle θ (degrees, default 90) Example: `90`
- `head` (query, optional, string) — Head above vertex H (m) Example: `0.2`
- `discharge` (query, optional, string) — Or a known discharge (m³/s) to solve H
- `discharge_coefficient` (query, optional, string) — Cd (default 0.58) Example: `0.58`
- `gravity` (query, optional, string) — Gravity g (m/s², default 9.81) Example: `9.81`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/weir-api/v1/vnotch?angle=90&head=0.2&discharge_coefficient=0.58&gravity=9.81"
```

**Response:**
```json
{
    "data": {
        "note": "Q = (8/15)·Cd·√(2g)·tan(θ/2)·H^2.5. Triangular notch; Cd≈0.58 for a 90° notch.",
        "type": "v-notch",
        "head_m": 0.2,
        "inputs": {
            "gravity": 9.81,
            "angle_deg": 90,
            "discharge_coefficient": 0.58
        },
        "solved_for": null,
        "discharge_l_s": 24.51045,
        "discharge_m3_s": 0.02451045
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:28.119Z",
        "request_id": "1cbd9863-dc93-42fd-b56d-d2a348908fc6"
    },
    "status": "ok",
    "message": "V-notch weir",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Lengths in metres, discharge in m³/s. Default Cd: rectangular 0.62, V-notch 0.58, broad-crested 0.85. Each endpoint solves head from discharge when 'head' is omitted.",
        "service": "weir-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/vnotch": "Triangular V-notch weir: Q = (8/15)·Cd·√(2g)·tan(θ/2)·H^2.5.",
            "GET /v1/rectangular": "Rectangular sharp-crested weir: Q = (2/3)·Cd·b·√(2g)·H^1.5.",
            "GET /v1/broadcrested": "Broad-crested weir: Q = Cd·(2/3)^1.5·√g·b·H^1.5."
        },
        "description": "Weir flow calculator for open-channel discharge measurement: rectangular, triangular V-notch and broad-crested weirs, solving discharge from head or head from discharge."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:28.197Z",
        "request_id": "6a878296-28d1-4757-b3fc-eb0169e0ca6b"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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