# Viscosity API
> Fluid-viscosity physics as an API, computed locally and deterministically. The sutherland endpoint gives the dynamic viscosity of a gas at any temperature from Sutherland’s law, μ(T) = μ_ref·(T/T_ref)^1.5·(T_ref+S)/(T+S), with built-in constants for air, nitrogen, oxygen, carbon dioxide, hydrogen, helium and argon (or your own μ_ref, T_ref and S) — air comes out at about 1.72×10⁻⁵ Pa·s at 0 °C, 1.84×10⁻⁵ at 25 °C and 2.17×10⁻⁵ at 100 °C, returned in Pa·s, micro-Pa·s and centipoise. The kinematic endpoint converts between dynamic viscosity μ and kinematic viscosity ν through the density, ν = μ/ρ and μ = ν·ρ, so water at 1.002 cP and 998 kg/m³ becomes about 1.004 cSt. The convert endpoint handles viscosity units both ways — dynamic between Pa·s, centipoise and poise (1 Pa·s = 1000 cP = 10 P) and kinematic between m²/s, centistokes and stokes (1 m²/s = 10⁶ cSt = 10⁴ St). Temperatures are in °C or kelvin. Everything is computed locally and deterministically, so it is instant and private. Ideal for fluid-mechanics, CFD, process-engineering, lubrication, HVAC and chemical-engineering app developers, viscosity-correlation and unit-conversion tools, and simulation software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This computes viscosity; for the Reynolds number that uses it use a Reynolds 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/viscosity-api/..."
```

## Pricing
- **Free** (Free) — 4,300 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 42,000 calls/Mo, 6 req/s
- **Pro** ($18/Mo) — 200,000 calls/Mo, 15 req/s
- **Mega** ($56/Mo) — 1,170,000 calls/Mo, 40 req/s

## Endpoints

### Viscosity

#### `GET /v1/convert` — Viscosity unit conversion

**Parameters:**
- `value` (query, required, string) — Value to convert Example: `1`
- `from` (query, required, string) — pa_s, cp, p (dynamic) or m2_s, cst, st (kinematic) Example: `pa_s`
- `to` (query, required, string) — Target unit Example: `cp`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/viscosity-api/v1/convert?value=1&from=pa_s&to=cp"
```

**Response:**
```json
{
    "data": {
        "kind": "dynamic",
        "note": "Dynamic: 1 Pa·s = 1000 cP = 10 P. Kinematic: 1 m²/s = 10⁶ cSt = 10⁴ St. Water at 20 °C ≈ 1 cP and ≈ 1 cSt.",
        "inputs": {
            "to": "cp",
            "from": "pa_s",
            "value": 1
        },
        "result": 1000
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:28.944Z",
        "request_id": "03f93be3-26ea-4273-ab5d-25be1d41e4ea"
    },
    "status": "ok",
    "message": "Viscosity unit conversion",
    "success": true
}
```

#### `GET /v1/kinematic` — Dynamic/kinematic conversion

**Parameters:**
- `density` (query, required, string) — Density ρ (kg/m³) Example: `998.2`
- `dynamic` (query, optional, string) — Dynamic viscosity μ (Pa·s) Example: `0.001002`
- `kinematic` (query, optional, string) — Kinematic viscosity ν (m²/s)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/viscosity-api/v1/kinematic?density=998.2&dynamic=0.001002"
```

**Response:**
```json
{
    "data": {
        "note": "ν = μ/ρ. 1 m²/s = 10⁶ cSt.",
        "inputs": {
            "density": 998.2,
            "dynamic_pa_s": 0.001002
        },
        "kinematic_cst": 1.0038069,
        "kinematic_m2_s": 1.0038069e-6
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:29.064Z",
        "request_id": "735f5e9c-ac54-4809-9fea-bed16d7d854a"
    },
    "status": "ok",
    "message": "Dynamic/kinematic conversion",
    "success": true
}
```

#### `GET /v1/sutherland` — Gas viscosity (Sutherland)

**Parameters:**
- `temperature` (query, optional, string) — Temperature (°C) Example: `25`
- `temperature_k` (query, optional, string) — Temperature (K)
- `gas` (query, optional, string) — air, nitrogen, oxygen, co2, hydrogen, helium, argon Example: `air`
- `mu_ref` (query, optional, string) — Custom reference viscosity (Pa·s)
- `t_ref` (query, optional, string) — Custom reference temperature (K)
- `s` (query, optional, string) — Custom Sutherland constant S (K)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/viscosity-api/v1/sutherland?temperature=25&gas=air"
```

**Response:**
```json
{
    "data": {
        "note": "Sutherland's law: μ(T) = μ_ref·(T/T_ref)^1.5·(T_ref+S)/(T+S). Air at 25 °C ≈ 1.84×10⁻⁵ Pa·s. Pass gas (air, nitrogen, oxygen, co2, hydrogen, helium, argon) or custom mu_ref + t_ref + s.",
        "inputs": {
            "gas": "air",
            "temperature_k": 298.15
        },
        "dynamic_viscosity_cp": 0.018371494,
        "sutherland_constants": {
            "s_k": 110.4,
            "t_ref_k": 273.15,
            "mu_ref_pa_s": 1.716e-5
        },
        "dynamic_viscosity_pa_s": 1.8371494e-5,
        "dynamic_viscosity_micropa_s": 18.371494
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:29.166Z",
        "request_id": "ff05f75a-54c6-4bca-99a3-a6b22157e5e6"
    },
    "status": "ok",
    "message": "Gas viscosity (Sutherland)",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "gases": [
            "air",
            "nitrogen",
            "oxygen",
            "co2",
            "hydrogen",
            "helium",
            "argon"
        ],
        "notes": "Sutherland uses kelvin. Dynamic units Pa·s, cP, P; kinematic m²/s, cSt, St. This computes viscosity; for the Reynolds number from it use a Reynolds API.",
        "service": "viscosity-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/convert": "Viscosity unit conversion (Pa·s/cP/Poise or m²/s/cSt/Stokes).",
            "GET /v1/kinematic": "Convert between dynamic (μ) and kinematic (ν) viscosity using density.",
            "GET /v1/sutherland": "Gas dynamic viscosity at a temperature (Sutherland's law)."
        },
        "description": "Fluid viscosity: Sutherland's law for gases, dynamic↔kinematic conversion via density, and viscosity unit conversion."
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:29.268Z",
        "request_id": "7b733784-ef90-4c25-bf57-e5a871bfa20e"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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