# Laser Beam Optics API
> Gaussian-beam laser-optics maths as an API, computed locally and deterministically. The beam endpoint propagates a Gaussian beam from its wavelength and waist radius: the Rayleigh range z_R = π·w₀²/λ and depth of focus, the divergence half- and full-angle θ = λ/(π·w₀), and — for a given distance — the beam radius and diameter w(z) = w₀·√(1+(z/z_R)²); an optional M² beam-quality factor scales it for real beams. The focus endpoint computes the diffraction-limited focused spot of a lens, w_f = λ·f/(π·w_in), with the depth of focus and the f-number, so you can size the spot a lens will deliver. The irradiance endpoint turns a beam power and spot size into the beam area and the average and on-axis peak irradiance (power density) in W/m² and W/cm². Wavelengths are in nanometres, sizes in millimetres or micrometres, distances in metres and power in watts. Everything is computed locally and deterministically, so it is instant and private. Ideal for photonics, laser-engineering, materials-processing and optics app developers, beam-delivery and laser-safety tools, and physics education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is Gaussian-beam laser optics; for refraction use a Snell API and for thin-lens imaging a lens 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/laser-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 20,000 calls/Mo, 5 req/s
- **Pro** ($18/Mo) — 120,000 calls/Mo, 15 req/s
- **Mega** ($55/Mo) — 600,000 calls/Mo, 40 req/s

## Endpoints

### Laser

#### `GET /v1/beam` — Beam propagation

**Parameters:**
- `wavelength` (query, required, string) — Wavelength (nm) Example: `1064`
- `waist` (query, required, string) — Beam-waist radius (mm) Example: `1`
- `distance` (query, optional, string) — Distance (m) for the spot Example: `10`
- `m_squared` (query, optional, string) — Beam quality M² (≥ 1) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/laser-api/v1/beam?wavelength=1064&waist=1&distance=10&m_squared=1"
```

**Response:**
```json
{
    "data": {
        "note": "Gaussian beam: z_R = πw₀²/λ, θ = λ/(πw₀), w(z) = w₀√(1+(z/z_R)²). M² ≥ 1 scales divergence.",
        "inputs": {
            "m_squared": 1,
            "wavelength_nm": 1064,
            "waist_radius_mm": 1
        },
        "distance_m": 10,
        "beam_radius_mm": 3.531363854,
        "beam_diameter_mm": 7.062727709,
        "depth_of_focus_m": 5.905249349,
        "rayleigh_range_m": 2.952624674,
        "divergence_full_angle_deg": 0.038810066,
        "divergence_full_angle_mrad": 0.677363438,
        "divergence_half_angle_mrad": 0.338681719
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:03.487Z",
        "request_id": "82c2c0fb-8d80-4847-b30f-33c4a5eb0a3c"
    },
    "status": "ok",
    "message": "Beam propagation",
    "success": true
}
```

#### `GET /v1/focus` — Focused spot

**Parameters:**
- `wavelength` (query, required, string) — Wavelength (nm) Example: `1064`
- `focal_length` (query, required, string) — Lens focal length (mm) Example: `100`
- `input_radius` (query, required, string) — Input beam radius (mm) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/laser-api/v1/focus?wavelength=1064&focal_length=100&input_radius=2"
```

**Response:**
```json
{
    "data": {
        "note": "Diffraction-limited focal spot: w_f = λ·f/(π·w_in). A bigger input beam or shorter focal length gives a smaller spot.",
        "inputs": {
            "wavelength_nm": 1064,
            "focal_length_mm": 100,
            "input_radius_mm": 2
        },
        "f_number": 25,
        "depth_of_focus_um": 1693.408594,
        "focused_radius_um": 16.934086,
        "rayleigh_range_um": 846.704297,
        "focused_diameter_um": 33.868172
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:03.575Z",
        "request_id": "5a8341f3-fcc7-4374-a1fc-dc0bc12e7dd0"
    },
    "status": "ok",
    "message": "Focused spot",
    "success": true
}
```

#### `GET /v1/irradiance` — Irradiance

**Parameters:**
- `power` (query, required, string) — Beam power (W) Example: `1`
- `radius` (query, optional, string) — Spot radius (mm) Example: `1`
- `diameter` (query, optional, string) — Or spot diameter (mm)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/laser-api/v1/irradiance?power=1&radius=1"
```

**Response:**
```json
{
    "data": {
        "note": "Average irradiance = P/area over the 1/e² spot; a Gaussian's on-axis peak is twice the average.",
        "inputs": {
            "power_w": 1,
            "radius_mm": 1
        },
        "beam_area_m2": 3.141593e-6,
        "beam_area_cm2": 0.031415927,
        "peak_irradiance_w_cm2": 63.661977237,
        "average_irradiance_w_m2": 318309.886184,
        "average_irradiance_w_cm2": 31.830988618
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:03.671Z",
        "request_id": "325fdc0a-cc00-4095-a4be-ee83e98917f0"
    },
    "status": "ok",
    "message": "Irradiance",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Wavelength in nm, waist/radius/input in mm, focal length in mm, distance in m, power in W; spot sizes are 1/e² radii. Add M² (≥1) for real beams.",
        "service": "laser-api",
        "formulae": {
            "divergence": "θ = λ/(π·w₀)",
            "beam_radius": "w(z) = w₀·√(1+(z/z_R)²)",
            "focused_waist": "w_f = λ·f/(π·w_in)",
            "rayleigh_range": "z_R = π·w₀²/λ",
            "peak_irradiance": "I₀ = 2P/(π·w²)"
        },
        "endpoints": {
            "GET /v1/beam": "Rayleigh range, divergence and the beam radius at a distance from wavelength and waist.",
            "GET /v1/meta": "This document.",
            "GET /v1/focus": "Diffraction-limited focused spot size and depth of focus of a lens.",
            "GET /v1/irradiance": "Average and peak irradiance (power density) from power and spot size."
        },
        "description": "Gaussian-beam (laser) optics calculator: beam propagation (Rayleigh range, divergence, spot at a distance), the diffraction-limited focused spot of a lens, and beam irradiance from power and spot size."
    },
    "meta": {
        "timestamp": "2026-06-05T03:09:03.772Z",
        "request_id": "1579e7c7-f1f1-4711-a5cf-6bc1c03f4813"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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