# Electrolysis API
> Faraday-law electrolysis maths as an API, computed locally and deterministically. The mass endpoint applies Faraday's first law of electrolysis, m = (Q·M)/(n·F) = (I·t·M)/(n·F), to give the mass of a substance deposited at a cathode or dissolved at an anode from the charge passed — or the current and time — the molar mass and the valence (electrons transferred per ion), with the Faraday constant 96485 C/mol. The charge endpoint inverts it to give the charge Q = (m·n·F)/M and, with a current, the plating time needed to deposit a target mass — the core sizing calculation for electroplating and anodising. The gas-volume endpoint computes the volume of gas evolved during electrolysis, moles = Q/(n·F) and volume = moles × 22.414 L/mol at STP, using the electrons per gas molecule (two for hydrogen, four for oxygen in water electrolysis). Molar mass is in g/mol, current in amperes, time in seconds, charge in coulombs and mass in grams. Everything is computed locally and deterministically, so it is instant and private. Ideal for electroplating, anodising, battery, hydrogen-production and chemistry-education app developers, plating-time and gas-yield tools, and electrochemistry teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is electrolysis (Faraday's laws); for cell potential and the Nernst equation use an electrochemistry Nernst 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/electrolysis-api/..."
```

## Pricing
- **Free** (Free) — 3,600 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 34,000 calls/Mo, 6 req/s
- **Pro** ($15/Mo) — 216,000 calls/Mo, 15 req/s
- **Mega** ($47/Mo) — 1,285,000 calls/Mo, 40 req/s

## Endpoints

### Electrolysis

#### `GET /v1/charge` — Required charge & time

**Parameters:**
- `molar_mass` (query, required, string) — Molar mass (g/mol) Example: `63.55`
- `electrons` (query, required, string) — Electrons n Example: `2`
- `mass` (query, required, string) — Target mass (g) Example: `2.371`
- `current` (query, optional, string) — Current (A) for time Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/electrolysis-api/v1/charge?molar_mass=63.55&electrons=2&mass=2.371&current=2"
```

**Response:**
```json
{
    "data": {
        "note": "Charge needed: Q = (m·n·F)/M. Divide by the current to get the plating time.",
        "moles": 0.0373092054,
        "inputs": {
            "mass_g": 2.371,
            "electrons": 2,
            "molar_mass": 63.55
        },
        "time_s": 3599.7911,
        "time_min": 59.996518,
        "current_a": 2,
        "required_charge_c": 7199.5821
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:24.751Z",
        "request_id": "c68b77fa-61f5-4ccc-8479-c97216af524e"
    },
    "status": "ok",
    "message": "Required charge",
    "success": true
}
```

#### `GET /v1/gas-volume` — Evolved gas volume

**Parameters:**
- `electrons` (query, required, string) — Electrons per gas molecule Example: `2`
- `current` (query, optional, string) — Current (A) Example: `2`
- `time` (query, optional, string) — Time (s) Example: `3600`
- `charge` (query, optional, string) — Or charge (C)
- `molar_volume` (query, optional, string) — Molar volume (L/mol) Example: `22.414`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/electrolysis-api/v1/gas-volume?electrons=2&current=2&time=3600&molar_volume=22.414"
```

**Response:**
```json
{
    "data": {
        "note": "Gas evolved: moles = Q/(n·F), volume = moles · molar volume (22.414 L/mol at STP). Water electrolysis gives 2 electrons per H₂ and 4 per O₂.",
        "moles": 0.0373113708,
        "inputs": {
            "time_s": 3600,
            "charge_c": 7200,
            "current_a": 2,
            "electrons": 2,
            "molar_volume_l": 22.414
        },
        "volume_ml": 836.29706,
        "volume_liters": 0.83629706
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:24.861Z",
        "request_id": "cf5314f0-8d6e-476f-9fab-5fb4121f8fa8"
    },
    "status": "ok",
    "message": "Gas volume",
    "success": true
}
```

#### `GET /v1/mass` — Deposited mass

**Parameters:**
- `molar_mass` (query, required, string) — Molar mass (g/mol) Example: `63.55`
- `electrons` (query, required, string) — Electrons n (valence) Example: `2`
- `current` (query, optional, string) — Current (A) Example: `2`
- `time` (query, optional, string) — Time (s) Example: `3600`
- `charge` (query, optional, string) — Or charge (C)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/electrolysis-api/v1/mass?molar_mass=63.55&electrons=2&current=2&time=3600"
```

**Response:**
```json
{
    "data": {
        "note": "Faraday's first law: m = (Q·M)/(n·F) = (I·t·M)/(n·F). The mass deposited or dissolved is proportional to the charge passed.",
        "moles": 0.0373113708,
        "inputs": {
            "time_s": 3600,
            "charge_c": 7200,
            "current_a": 2,
            "electrons": 2,
            "molar_mass": 63.55
        },
        "deposited_mass_g": 2.37113761
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:24.934Z",
        "request_id": "10fadb92-de55-42e6-a816-861def554d7c"
    },
    "status": "ok",
    "message": "Deposited mass",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Molar mass in g/mol, electrons n the valence (or per gas molecule), current in A, time in s, charge in C. Faraday constant 96485 C/mol.",
        "service": "electrolysis-api",
        "formulae": {
            "mass": "m = (Q·M)/(n·F)",
            "charge": "Q = (m·n·F)/M",
            "gas_volume": "V = (Q/(n·F)) · 22.414 L/mol"
        },
        "constants": {
            "faraday_c_mol": 96485.33212,
            "molar_volume_stp_l": 22.413969
        },
        "endpoints": {
            "GET /v1/mass": "Deposited mass from charge (or current and time), molar mass and valence.",
            "GET /v1/meta": "This document.",
            "GET /v1/charge": "Charge and plating time needed to deposit a target mass.",
            "GET /v1/gas-volume": "Volume of gas evolved from the charge and electrons per molecule."
        },
        "description": "Faraday's-law electrolysis calculator: mass deposited or dissolved, the charge and time required for a target mass, and the volume of gas evolved."
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:25.012Z",
        "request_id": "be349b3b-8029-4614-818d-a1f65279b058"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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