# Beer-Lambert Spectroscopy API
> Beer–Lambert spectroscopy maths as an API, computed locally and deterministically. The beer-lambert endpoint applies the law A = ε·c·l, where absorbance equals the molar absorptivity times the concentration times the optical path length: give any three of the four and it solves for the fourth (the path length defaults to the standard 1 cm cuvette when omitted), and it always reports the matching transmittance and percent transmittance. The transmittance endpoint converts between absorbance and transmittance in both directions, A = −log₁₀(T) and T = 10^(−A), and accepts a fraction or a percentage. The calibration endpoint reads a concentration off a linear calibration curve, A = slope·c + intercept, solving for the concentration from a measured absorbance or for the expected absorbance from a concentration. Units are whatever you supply consistently — for molar absorptivity in M⁻¹cm⁻¹, a path length in cm and absorbance dimensionless, the concentration comes out in molar. Everything is computed locally and deterministically, so it is instant and private. Ideal for analytical-chemistry and lab tools, spectrophotometer and assay apps, biotech and education software, and quality-control calculators. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is Beer–Lambert spectroscopy; for solution dilution and molarity use a dilution API and for chemical compound data use a chemistry 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/beerlambert-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 25,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 150,000 calls/Mo, 15 req/s
- **Mega** ($49/Mo) — 750,000 calls/Mo, 40 req/s

## Endpoints

### Spectroscopy

#### `GET /v1/beer-lambert` — A = ε·c·l solver

**Parameters:**
- `absorbance` (query, optional, string) — Absorbance A
- `molar_absorptivity` (query, optional, string) — Molar absorptivity ε Example: `6220`
- `concentration` (query, optional, string) — Concentration c Example: `0.0001`
- `path_length` (query, optional, string) — Path length l (default 1 cm) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/beerlambert-api/v1/beer-lambert?molar_absorptivity=6220&concentration=0.0001&path_length=1"
```

**Response:**
```json
{
    "data": {
        "note": "A = ε·c·l.",
        "absorbance": 0.622,
        "solved_for": "absorbance",
        "path_length": 1,
        "concentration": 0.0001,
        "transmittance": 0.23878113,
        "molar_absorptivity": 6220,
        "percent_transmittance": 23.878113
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:58.045Z",
        "request_id": "762920ab-fb41-40ff-9083-6eb3decff34d"
    },
    "status": "ok",
    "message": "A = ε·c·l solver",
    "success": true
}
```

#### `GET /v1/calibration` — Linear calibration concentration

**Parameters:**
- `slope` (query, required, string) — Calibration slope Example: `5000`
- `intercept` (query, optional, string) — Intercept (default 0) Example: `0.02`
- `absorbance` (query, optional, string) — Measured absorbance (to get c) Example: `0.52`
- `concentration` (query, optional, string) — Or concentration (to get A)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/beerlambert-api/v1/calibration?slope=5000&intercept=0.02&absorbance=0.52"
```

**Response:**
```json
{
    "data": {
        "mode": "absorbance_to_concentration",
        "note": "c = (A − intercept) / slope.",
        "slope": 5000,
        "intercept": 0.02,
        "absorbance": 0.52,
        "concentration": 0.0001
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:58.142Z",
        "request_id": "dbeed38b-f850-4091-87b1-4ff8d151f4d2"
    },
    "status": "ok",
    "message": "Linear calibration concentration",
    "success": true
}
```

#### `GET /v1/transmittance` — Absorbance ↔ transmittance

**Parameters:**
- `absorbance` (query, optional, string) — Absorbance A Example: `1`
- `transmittance` (query, optional, string) — Or transmittance T (0-1)
- `percent_transmittance` (query, optional, string) — Or %T

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/beerlambert-api/v1/transmittance?absorbance=1"
```

**Response:**
```json
{
    "data": {
        "mode": "absorbance_to_transmittance",
        "absorbance": 1,
        "transmittance": 0.1,
        "percent_transmittance": 10
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:58.238Z",
        "request_id": "0f89f4af-cc1e-4ce4-9a59-3e8980b6fb2c"
    },
    "status": "ok",
    "message": "Absorbance <-> transmittance",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "beerlambert",
        "note": "Beer–Lambert spectroscopy maths — computed locally and deterministically, no key, no third-party service. Path length defaults to 1 cm; units are whatever you supply (consistently).",
        "endpoints": [
            "/v1/beer-lambert",
            "/v1/transmittance",
            "/v1/calibration",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:58.316Z",
        "request_id": "f614a14c-eea4-495b-97a2-06483c138a94"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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