# Ideal Gas Law API
> Ideal-gas-law maths as an API, computed locally and deterministically. The ideal endpoint solves PV = nRT for whichever quantity you leave out: provide any three of pressure, volume, amount of substance (moles) and temperature, and it returns the fourth in several units. The combined endpoint applies the combined gas law, P₁V₁/T₁ = P₂V₂/T₂: give a first state and two quantities of the second state and it finds the missing one — handy for "what happens to the volume if I double the pressure" questions. The density endpoint computes the density of an ideal gas from the pressure, temperature and molar mass (ρ = P·M / R·T). Pressure accepts pascals, kPa, bar, atm, psi, mmHg and Torr; volume accepts m³, litres, mL and cubic feet; temperature accepts kelvin, Celsius and Fahrenheit; and the gas constant R is 8.314462618 J/(mol·K). Everything is computed in SI internally and is instant and private. Ideal for chemistry and physics education, lab and process tools, HVAC and scuba calculations, and engineering software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is ideal-gas thermodynamics; for the chemical elements and periodic-table data use an elements 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/gaslaw-api/..."
```

## Pricing
- **Free** (Free) — 12,535 calls/Mo, 2 req/s
- **Starter** ($14/Mo) — 22,150 calls/Mo, 8 req/s
- **Pro** ($34/Mo) — 271,500 calls/Mo, 20 req/s
- **Mega** ($72/Mo) — 1,400,000 calls/Mo, 50 req/s

## Endpoints

### Gas

#### `GET /v1/combined` — Combined gas law

**Parameters:**
- `p1` (query, required, string) — State 1 pressure Example: `1`
- `v1` (query, required, string) — State 1 volume Example: `1`
- `t1` (query, required, string) — State 1 temperature Example: `273`
- `p2` (query, optional, string) — State 2 pressure Example: `2`
- `v2` (query, optional, string) — State 2 volume
- `t2` (query, optional, string) — State 2 temperature Example: `273`
- `pressure_unit` (query, optional, string) — Pressure unit Example: `atm`
- `volume_unit` (query, optional, string) — Volume unit Example: `l`
- `temperature_unit` (query, optional, string) — Temp unit Example: `K`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gaslaw-api/v1/combined?p1=1&v1=1&t1=273&p2=2&t2=273&pressure_unit=atm&volume_unit=l&temperature_unit=K"
```

**Response:**
```json
{
    "data": {
        "v2": {
            "m3": 0.0005,
            "ml": 500,
            "ft3": 0.017657333,
            "litres": 0.5
        },
        "note": "Combined gas law: P₁V₁/T₁ = P₂V₂/T₂. Provide state 1 and two of state 2.",
        "input": {
            "t1_k": 273,
            "p1_pa": 101325,
            "v1_m3": 0.001
        },
        "variable": "v2",
        "solved_for": "v2"
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:13.164Z",
        "request_id": "b0368af6-3d71-493b-8460-1d03a8257076"
    },
    "status": "ok",
    "message": "Combined gas law",
    "success": true
}
```

#### `GET /v1/density` — Ideal-gas density

**Parameters:**
- `pressure` (query, required, string) — Pressure Example: `101325`
- `pressure_unit` (query, optional, string) — Unit Example: `pa`
- `temperature` (query, required, string) — Temperature Example: `288`
- `temperature_unit` (query, optional, string) — K|C|F Example: `K`
- `molar_mass` (query, required, string) — Molar mass Example: `28.96`
- `molar_mass_unit` (query, optional, string) — g|kg (default g) Example: `g`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gaslaw-api/v1/density?pressure=101325&pressure_unit=pa&temperature=288&temperature_unit=K&molar_mass=28.96&molar_mass_unit=g"
```

**Response:**
```json
{
    "data": {
        "note": "Ideal-gas density ρ = P·M / (R·T). Molar mass defaults to g/mol (air ≈ 28.96).",
        "input": {
            "pressure_pa": 101325,
            "temperature_k": 288,
            "molar_mass_kg_per_mol": 0.02896
        },
        "density_g_per_l": 1.22543,
        "density_kg_per_m3": 1.22543
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:13.253Z",
        "request_id": "ee3fbf52-6bdd-43c1-976e-4e62078085f2"
    },
    "status": "ok",
    "message": "Gas density",
    "success": true
}
```

#### `GET /v1/ideal` — Solve PV = nRT

**Parameters:**
- `pressure` (query, optional, string) — Pressure (+pressure_unit) Example: `1`
- `pressure_unit` (query, optional, string) — pa|kpa|bar|atm|psi|mmhg Example: `atm`
- `volume` (query, optional, string) — Volume (+volume_unit)
- `volume_unit` (query, optional, string) — m3|l|ml|ft3 Example: `l`
- `moles` (query, optional, string) — Amount (mol) Example: `1`
- `temperature` (query, optional, string) — Temperature (+temperature_unit) Example: `0`
- `temperature_unit` (query, optional, string) — K|C|F Example: `C`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gaslaw-api/v1/ideal?pressure=1&pressure_unit=atm&volume_unit=l&moles=1&temperature=0&temperature_unit=C"
```

**Response:**
```json
{
    "data": {
        "note": "PV = nRT, R = 8.314462618 J/(mol·K). Provide three quantities; the fourth is returned in several units.",
        "input": {
            "moles": 1,
            "volume_m3": null,
            "pressure_pa": 101325,
            "temperature_k": 273.15
        },
        "volume": {
            "m3": 0.02241397,
            "ml": 22413.97,
            "ft3": 0.79154186,
            "litres": 22.41397
        },
        "variable": "volume",
        "solved_for": "volume"
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:13.356Z",
        "request_id": "636326db-4d06-4a2a-b2cf-c4dcd8099562"
    },
    "status": "ok",
    "message": "Ideal gas law",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "note": "Computed in SI internally (Pa, m³, K, mol). R = 8.314462618 J/(mol·K).",
        "units": {
            "volume": [
                "m3",
                "l",
                "liter",
                "litre",
                "ml",
                "cm3",
                "ft3",
                "gal"
            ],
            "pressure": [
                "pa",
                "kpa",
                "mpa",
                "bar",
                "mbar",
                "atm",
                "psi",
                "mmhg",
                "torr",
                "inhg"
            ],
            "temperature": [
                "K",
                "C",
                "F"
            ]
        },
        "service": "gaslaw",
        "endpoints": {
            "/v1/ideal": "Solve PV = nRT for the missing one of pressure, volume, moles or temperature.",
            "/v1/density": "Ideal-gas density from pressure, temperature and molar mass.",
            "/v1/combined": "Combined gas law P₁V₁/T₁ = P₂V₂/T₂: solve a second-state variable."
        },
        "description": "Ideal-gas-law maths: PV = nRT (solve any variable), the combined gas law, and gas density.",
        "constant_R_j_per_mol_k": 8.314462618
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:13.456Z",
        "request_id": "8969aa7d-c145-4ea3-b72b-e647d2c70f7a"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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