# Diffraction & Interference API
> Wave-optics diffraction and interference as an API, computed locally and deterministically. The double-slit endpoint applies Young's two-slit interference, d·sinθ = m·λ: from a wavelength and the slit separation it returns the angle of the m-th bright fringe and, given the screen distance, the fringe spacing Δy = λ·L/d and the position of any maximum — the classic experiment that proved light is a wave. The grating endpoint handles a diffraction grating, d·sinθ = m·λ with d = 1/lines: from a wavelength and the grating density (lines per millimetre) it gives the diffraction angle of each order and the maximum observable order ⌊d/λ⌋, flagging orders that do not exist. The single-slit endpoint computes single-slit diffraction, a·sinθ = m·λ for the dark fringes (minima), and, given the screen distance, the width of the bright central maximum 2·λ·L/a. Wavelengths may be entered in metres, nanometres or micrometres. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics and optics-education tools, spectroscopy and grating design, laser and photonics apps, and laboratory software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is wave-optics diffraction; for thin-lens imaging use a lens API and for Snell's-law refraction use a Snell 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/diffraction-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** ($45/Mo) — 600,000 calls/Mo, 40 req/s

## Endpoints

### Diffraction

#### `GET /v1/double-slit` — Young's double-slit interference

**Parameters:**
- `wavelength_nm` (query, required, string) — Wavelength (nm) Example: `500`
- `slit_separation` (query, required, string) — Slit separation d (m) Example: `0.0001`
- `screen_distance` (query, optional, string) — Screen distance L (m) Example: `2`
- `order` (query, optional, string) — Fringe order m (default 1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/diffraction-api/v1/double-slit?wavelength_nm=500&slit_separation=0.0001&screen_distance=2&order=1"
```

**Response:**
```json
{
    "data": {
        "order": 1,
        "formula": "d·sinθ = m·λ (bright fringes); fringe spacing Δy = λ·L/d.",
        "bright_fringe": {
            "angle_deg": 0.28648,
            "angle_rad": 0.00500002,
            "sin_theta": 0.005
        },
        "wavelength_nm": 500,
        "fringe_spacing_m": 0.01,
        "fringe_position_m": 0.01,
        "fringe_spacing_mm": 10,
        "screen_distance_m": 2,
        "slit_separation_m": 0.0001
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:46.597Z",
        "request_id": "45d768a8-641c-4bcd-a45e-0f580f799d12"
    },
    "status": "ok",
    "message": "Young's double-slit interference",
    "success": true
}
```

#### `GET /v1/grating` — Diffraction grating

**Parameters:**
- `wavelength_nm` (query, required, string) — Wavelength (nm) Example: `500`
- `lines_per_mm` (query, optional, string) — Grating density (lines/mm) Example: `600`
- `grating_spacing` (query, optional, string) — Or spacing d (m)
- `order` (query, optional, string) — Order m (default 1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/diffraction-api/v1/grating?wavelength_nm=500&lines_per_mm=600&order=1"
```

**Response:**
```json
{
    "data": {
        "order": 1,
        "formula": "d·sinθ = m·λ; maximum order m = ⌊d/λ⌋.",
        "diffraction": {
            "angle_deg": 17.457603,
            "angle_rad": 0.30469265,
            "sin_theta": 0.3
        },
        "lines_per_mm": 600,
        "maximum_order": 3,
        "wavelength_nm": 500,
        "grating_spacing_m": 1.666667e-6,
        "grating_spacing_nm": 1666.6667
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:46.702Z",
        "request_id": "cfd7b840-0f04-4963-8f70-09909127f425"
    },
    "status": "ok",
    "message": "Diffraction grating",
    "success": true
}
```

#### `GET /v1/single-slit` — Single-slit diffraction

**Parameters:**
- `wavelength_nm` (query, required, string) — Wavelength (nm) Example: `600`
- `slit_width` (query, required, string) — Slit width a (m) Example: `0.00005`
- `screen_distance` (query, optional, string) — Screen distance L (m) Example: `2`
- `order` (query, optional, string) — Minimum number m (default 1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/diffraction-api/v1/single-slit?wavelength_nm=600&slit_width=0.00005&screen_distance=2&order=1"
```

**Response:**
```json
{
    "data": {
        "order": 1,
        "formula": "a·sinθ = m·λ (minima); central-maximum width = 2·λ·L/a.",
        "minimum": {
            "angle_deg": 0.687566,
            "angle_rad": 0.01200029,
            "sin_theta": 0.012
        },
        "slit_width_m": 5.0e-5,
        "wavelength_nm": 600,
        "screen_distance_m": 2,
        "central_max_width_m": 0.048,
        "central_max_width_mm": 48,
        "central_max_half_width_m": 0.024
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:46.801Z",
        "request_id": "957109a9-acfe-4cf5-9530-8423a7dc160a"
    },
    "status": "ok",
    "message": "Single-slit diffraction",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "diffraction",
        "note": "Wave-optics diffraction & interference — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/double-slit",
            "/v1/grating",
            "/v1/single-slit",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:46.898Z",
        "request_id": "6e51634c-a24d-481c-9372-b2e2b5f0cb9e"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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