# Tank Volume API
> Tank-gauging geometry as an API, computed locally and deterministically. The horizontal-cylinder endpoint computes the liquid volume in a partially-filled horizontal cylindrical tank from the fill height, the radius (or diameter) and the length, V = L·[r²·acos((r−h)/r) − (r−h)·√(2rh−h²)] — the non-linear relationship that makes a horizontal tank read so unintuitively, e.g. a tank filled to a quarter of its diameter holds only about 20 % of its capacity, while half height is exactly half full. The vertical-cylinder endpoint gives the straightforward V = π·r²·h for an upright tank. The sphere endpoint computes the volume in a spherical tank filled to a height h as the spherical cap V = π·h²·(3r−h)/3, exactly half the sphere at h = r. Every response returns the liquid volume in cubic metres and litres, the full capacity, and the fill percentage. All lengths are in metres. Everything is computed locally and deterministically, so it is instant and private. Ideal for industrial, fuel-station, agriculture, water-utility, chemical-storage and process app developers, tank-gauging, dipstick-to-volume and inventory tools, and IoT level sensors. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is tank volume by geometry; for flow rate through a pipe use a flow-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/tankvolume-api/..."
```

## Pricing
- **Free** (Free) — 5,500 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 54,000 calls/Mo, 6 req/s
- **Pro** ($14/Mo) — 245,000 calls/Mo, 15 req/s
- **Mega** ($43/Mo) — 1,400,000 calls/Mo, 40 req/s

## Endpoints

### Tank

#### `GET /v1/horizontal-cylinder` — Horizontal cylinder volume

**Parameters:**
- `radius` (query, optional, string) — Radius (m) Example: `1`
- `diameter` (query, optional, string) — Diameter (m)
- `length` (query, required, string) — Cylinder length (m) Example: `2`
- `fill_height` (query, required, string) — Liquid fill height (m) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tankvolume-api/v1/horizontal-cylinder?radius=1&length=2&fill_height=1"
```

**Response:**
```json
{
    "data": {
        "note": "Partially-filled horizontal cylinder: V = L·[r²·acos((r−h)/r) − (r−h)·√(2rh−h²)]. At half full (h=r) the volume is exactly half the cylinder.",
        "inputs": {
            "length": 2,
            "radius": 1,
            "fill_height": 1
        },
        "fill_percent": 50,
        "full_volume_m3": 6.28318531,
        "liquid_volume_m3": 3.14159265,
        "full_volume_liters": 6283.1853,
        "liquid_volume_liters": 3141.5927
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:27.405Z",
        "request_id": "ae64c09a-4a29-4113-9064-4993eb381ce0"
    },
    "status": "ok",
    "message": "Horizontal cylinder volume",
    "success": true
}
```

#### `GET /v1/sphere` — Spherical tank volume

**Parameters:**
- `radius` (query, optional, string) — Radius (m) Example: `1`
- `diameter` (query, optional, string) — Diameter (m)
- `fill_height` (query, required, string) — Liquid fill height (m) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tankvolume-api/v1/sphere?radius=1&fill_height=1"
```

**Response:**
```json
{
    "data": {
        "note": "Spherical tank filled to height h: V = π·h²·(3r−h)/3 (spherical cap). At h=r it is exactly half the sphere.",
        "inputs": {
            "radius": 1,
            "fill_height": 1
        },
        "fill_percent": 50,
        "full_volume_m3": 4.1887902,
        "liquid_volume_m3": 2.0943951,
        "full_volume_liters": 4188.7902,
        "liquid_volume_liters": 2094.3951
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:27.514Z",
        "request_id": "5fc6eb22-4756-4a10-8353-62bb9c9e507c"
    },
    "status": "ok",
    "message": "Spherical tank volume",
    "success": true
}
```

#### `GET /v1/vertical-cylinder` — Vertical cylinder volume

**Parameters:**
- `radius` (query, optional, string) — Radius (m) Example: `1`
- `diameter` (query, optional, string) — Diameter (m)
- `height` (query, required, string) — Total tank height (m) Example: `3`
- `fill_height` (query, required, string) — Liquid fill height (m) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tankvolume-api/v1/vertical-cylinder?radius=1&height=3&fill_height=2"
```

**Response:**
```json
{
    "data": {
        "note": "Vertical cylinder: V = π·r²·h. Liquid scales linearly with fill height.",
        "inputs": {
            "height": 3,
            "radius": 1,
            "fill_height": 2
        },
        "fill_percent": 66.666667,
        "full_volume_m3": 9.42477796,
        "liquid_volume_m3": 6.28318531,
        "full_volume_liters": 9424.778,
        "liquid_volume_liters": 6283.1853
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:27.615Z",
        "request_id": "03a44868-ea1a-4a17-8787-96adb41b0171"
    },
    "status": "ok",
    "message": "Vertical cylinder volume",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "All lengths in metres, volume in m³ and litres. Pass radius or diameter. This is tank gauging by geometry; for flow rate use a flow-rate API.",
        "service": "tankvolume-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/sphere": "Liquid volume in a spherical tank at a fill height (spherical cap).",
            "GET /v1/vertical-cylinder": "Liquid volume in a vertical cylindrical tank at a fill height.",
            "GET /v1/horizontal-cylinder": "Liquid volume in a horizontal cylindrical tank at a fill height."
        },
        "description": "Liquid volume in partially-filled tanks: horizontal cylinder, vertical cylinder and spherical tank."
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:27.727Z",
        "request_id": "128cb1d4-266c-48a8-9b0e-dbef48cc5694"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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