# Gas Mixture API
> Gas-mixture maths as an API, computed locally and deterministically. The partial-pressure endpoint applies Dalton's law — give a list of component partial pressures and it sums them to the total and returns each gas's mole fraction; or give a total pressure and a mole fraction to get a partial pressure; or component and total moles to get a mole fraction (and a partial pressure when a total pressure is supplied). The mole-fraction endpoint takes the moles of each component and returns every mole fraction and, with a total pressure, the partial pressures; supply the molar masses too and it adds the mass fractions and the average molar mass of the mixture. The effusion endpoint applies Graham's law, rate₁/rate₂ = √(M₂/M₁), to compare how fast two gases effuse or diffuse from their molar masses, naming the faster gas and the time ratio. Everything is computed locally and deterministically, so it is instant and private. Ideal for chemistry-education, laboratory, process and scuba app developers, gas-blending and stoichiometry tools, and STEM teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is gas-mixture maths; for the ideal-gas law of a single gas use a gas-law API and for molar mass from a formula a molar-mass 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/gasmixture-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($49/Mo) — 1,539,000 calls/Mo, 40 req/s

## Endpoints

### Gas Mixture

#### `GET /v1/effusion` — Graham effusion

**Parameters:**
- `molar_mass1` (query, required, string) — Molar mass of gas 1 (g/mol) Example: `2`
- `molar_mass2` (query, required, string) — Molar mass of gas 2 (g/mol) Example: `32`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gasmixture-api/v1/effusion?molar_mass1=2&molar_mass2=32"
```

**Response:**
```json
{
    "data": {
        "note": "Graham's law: rate₁/rate₂ = √(M₂/M₁). The lighter gas effuses (and diffuses) faster; time scales inversely with rate.",
        "inputs": {
            "molar_mass1": 2,
            "molar_mass2": 32
        },
        "faster_gas": "gas 1",
        "rate_ratio_1_over_2": 4,
        "rate_ratio_2_over_1": 0.25,
        "time_ratio_1_over_2": 0.25
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:01.522Z",
        "request_id": "1275834a-4af1-4298-b9d7-5d2aaf2cda74"
    },
    "status": "ok",
    "message": "Effusion",
    "success": true
}
```

#### `GET /v1/mole-fraction` — Mole & mass fractions

**Parameters:**
- `moles` (query, required, string) — Comma-separated component moles Example: `3,1`
- `total_pressure` (query, optional, string) — Total pressure for partials Example: `4`
- `molar_masses` (query, optional, string) — Comma-separated molar masses (g/mol) Example: `2,32`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gasmixture-api/v1/mole-fraction?moles=3%2C1&total_pressure=4&molar_masses=2%2C32"
```

**Response:**
```json
{
    "data": {
        "note": "Mole fraction = nᵢ / Σn. With molar masses, mass fractions and the average molar mass are also returned.",
        "inputs": {
            "components": 2,
            "total_moles": 4
        },
        "mass_fractions": [
            0.157895,
            0.842105
        ],
        "mole_fractions": [
            0.75,
            0.25
        ],
        "partial_pressures": [
            3,
            1
        ],
        "average_molar_mass": 9.5
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:01.617Z",
        "request_id": "8c18559f-2c45-41fb-8978-1959e2bd6ad3"
    },
    "status": "ok",
    "message": "Mole fraction",
    "success": true
}
```

#### `GET /v1/partial-pressure` — Dalton partial pressure

**Parameters:**
- `partials` (query, optional, string) — Comma-separated partial pressures Example: `0.8,0.2`
- `total_pressure` (query, optional, string) — Total pressure Example: `2`
- `mole_fraction` (query, optional, string) — Mole fraction (0–1) Example: `0.21`
- `moles` (query, optional, string) — Component moles
- `total_moles` (query, optional, string) — Total moles

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/gasmixture-api/v1/partial-pressure?partials=0.8%2C0.2&total_pressure=2&mole_fraction=0.21"
```

**Response:**
```json
{
    "data": {
        "note": "Dalton's law: the total pressure is the sum of the component partial pressures.",
        "inputs": {
            "partials": [
                0.8,
                0.2
            ]
        },
        "mole_fractions": [
            0.8,
            0.2
        ],
        "total_pressure": 1
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:01.713Z",
        "request_id": "3878501e-bc4e-442b-a3b6-464f3cf37b5f"
    },
    "status": "ok",
    "message": "Partial pressure",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Pressures in any consistent unit; amounts in moles; molar masses in g/mol. Lists are comma-separated. Ideal-gas mixtures.",
        "service": "gasmixture-api",
        "formulae": {
            "dalton": "P_total = ΣPᵢ, Pᵢ = xᵢ·P_total",
            "graham": "rate₁/rate₂ = √(M₂/M₁)",
            "mole_fraction": "xᵢ = nᵢ / Σn"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/effusion": "Graham's law effusion/diffusion rate ratio from two molar masses.",
            "GET /v1/mole-fraction": "Mole fractions, partial pressures and mass fractions from component amounts.",
            "GET /v1/partial-pressure": "Dalton's law — total from partials, partial from a mole fraction, or fraction from moles."
        },
        "description": "Gas-mixture calculator: Dalton's law of partial pressures, mole and mass fractions of a mixture, and Graham's law of effusion and diffusion."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:01.818Z",
        "request_id": "a6dfc070-6d57-46d7-9b78-038951d66bab"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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