# Thin Lens & Mirror API
> Thin-lens and mirror imaging optics as an API, computed locally and deterministically. The lens endpoint applies the thin-lens equation, 1/f = 1/do + 1/di, and solves for whichever of the focal length, object distance or image distance you leave out, then returns the magnification m = −di/do and the full description of the image — real or virtual, upright or inverted, enlarged, reduced or the same size — and whether the lens is converging (convex, f > 0) or diverging (concave, f < 0). The mirror endpoint does the same for a spherical mirror, taking the focal length or the radius of curvature (f = R/2), classifying it as concave or convex and describing the image. The power endpoint converts between focal length in metres and optical power in diopters, D = 1/f, and combines several thin lenses placed in contact by adding their powers, D_total = ΣD, returning the combined focal length. Distances use whatever consistent unit you supply. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics and optics-education tools, lens and optical-system design, eyewear and vision apps, and photography learning. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is geometric-optics imaging; for Snell's-law refraction angles use a Snell API and for camera depth of field and field of view use a photography 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/lens-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,501,000 calls/Mo, 40 req/s

## Endpoints

### Optics

#### `GET /v1/lens` — Thin-lens equation

**Parameters:**
- `focal_length` (query, optional, string) — Focal length f (+ converging, − diverging) Example: `10`
- `object_distance` (query, optional, string) — Object distance do Example: `30`
- `image_distance` (query, optional, string) — Image distance di (provide two of three)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lens-api/v1/lens?focal_length=10&object_distance=30"
```

**Response:**
```json
{
    "data": {
        "note": "Real images form on the far side of the lens (di > 0); virtual images on the same side as the object.",
        "formula": "1/f = 1/do + 1/di; m = −di/do.",
        "lens_type": "converging (convex)",
        "image_size": "reduced",
        "image_type": "real",
        "focal_length": 10,
        "magnification": -0.5,
        "image_distance": 15,
        "object_distance": 30,
        "image_orientation": "inverted"
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:47.018Z",
        "request_id": "3f79f6fd-f59d-401b-aae7-39b914b6a074"
    },
    "status": "ok",
    "message": "Thin-lens equation",
    "success": true
}
```

#### `GET /v1/mirror` — Mirror equation

**Parameters:**
- `focal_length` (query, optional, string) — Focal length f (+ concave, − convex) Example: `10`
- `radius_of_curvature` (query, optional, string) — Or radius of curvature R (f = R/2) Example: `20`
- `object_distance` (query, optional, string) — Object distance do Example: `30`
- `image_distance` (query, optional, string) — Image distance di

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lens-api/v1/mirror?focal_length=10&radius_of_curvature=20&object_distance=30"
```

**Response:**
```json
{
    "data": {
        "note": "Real images form in front of the mirror (di > 0); virtual images behind it.",
        "formula": "1/f = 1/do + 1/di; f = R/2; m = −di/do.",
        "image_size": "reduced",
        "image_type": "real",
        "mirror_type": "concave (converging)",
        "focal_length": 10,
        "magnification": -0.5,
        "image_distance": 15,
        "object_distance": 30,
        "image_orientation": "inverted",
        "radius_of_curvature": 20
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:47.068Z",
        "request_id": "01e3a1b2-1a11-48f4-b4bb-b967a4e27369"
    },
    "status": "ok",
    "message": "Mirror equation",
    "success": true
}
```

#### `GET /v1/power` — Lens power / diopters

**Parameters:**
- `focal_length_m` (query, optional, string) — Focal length in metres → power Example: `0.1`
- `power` (query, optional, string) — Or power in diopters → focal length
- `powers` (query, optional, string) — Or combine lenses in contact (e.g. 5,3)
- `focal_lengths_m` (query, optional, string) — Or combine focal lengths in metres

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lens-api/v1/power?focal_length_m=0.1"
```

**Response:**
```json
{
    "data": {
        "mode": "focal_to_power",
        "formula": "D = 1/f (f in metres).",
        "focal_length_m": 0.1,
        "power_diopters": 10
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:47.142Z",
        "request_id": "c6cc9210-616d-4e48-a0d9-37c05762d500"
    },
    "status": "ok",
    "message": "Lens power / diopters",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "lens",
        "note": "Thin-lens / mirror imaging (geometric optics) — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/lens",
            "/v1/mirror",
            "/v1/power",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:47.229Z",
        "request_id": "230e8839-de8e-4340-9303-05aed91c022a"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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