# Special Relativity API
> Special-relativity maths as an API, computed locally and deterministically. The lorentz endpoint computes the Lorentz factor γ = 1/√(1 − β²) from a velocity (in m/s, km/s or as a fraction of the speed of light β), and — given a proper time or a proper length — the dilated time Δt = γ·Δt₀ that a stationary observer measures and the contracted length L = L₀/γ. The energy endpoint computes the rest energy E₀ = mc², the total energy E = γmc², the kinetic energy KE = (γ − 1)mc² and the relativistic momentum p = γmv of a mass moving at a given speed, reporting the energies in both joules and electronvolts. The mass-energy endpoint applies Einstein's E = mc² to convert between mass and energy in either direction, in joules, electronvolts, megaelectronvolts and kilowatt-hours. The speed of light is exactly 299,792,458 m/s. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics-education, simulation, astronomy and science-communication app developers, relativity and particle-physics tools, and STEM teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is special relativity; for everyday SUVAT motion use a kinematics API and for orbital mechanics an orbital 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/relativity-api/..."
```

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

## Endpoints

### Relativity

#### `GET /v1/energy` — Relativistic energy

**Parameters:**
- `mass` (query, required, string) — Rest mass (kg) Example: `1`
- `beta` (query, optional, string) — Speed as a fraction of c Example: `0.8`
- `velocity` (query, optional, string) — Or velocity (m/s)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/relativity-api/v1/energy?mass=1&beta=0.8"
```

**Response:**
```json
{
    "data": {
        "note": "E₀ = mc² (rest), E = γmc² (total), KE = (γ−1)mc², p = γmv. At β = 0 this reduces to the rest energy.",
        "inputs": {
            "beta": 0.8,
            "mass_kg": 1,
            "lorentz_factor": 1.666666666667
        },
        "rest_energy_j": 89875517900000000,
        "rest_energy_ev": 5.6095886e+35,
        "total_energy_j": 149792530000000000,
        "kinetic_energy_j": 59917011900000000,
        "kinetic_energy_ev": 3.73972574e+35,
        "relativistic_momentum_kg_ms": 399723277
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:05.278Z",
        "request_id": "4b31538d-9ac0-4085-b13c-718a9701f3d6"
    },
    "status": "ok",
    "message": "Relativistic energy",
    "success": true
}
```

#### `GET /v1/lorentz` — Lorentz factor

**Parameters:**
- `beta` (query, optional, string) — Speed as a fraction of c (0–1) Example: `0.8`
- `velocity` (query, optional, string) — Or velocity (m/s)
- `velocity_kms` (query, optional, string) — Or velocity (km/s)
- `proper_time` (query, optional, string) — Proper time (s) for dilation Example: `1`
- `proper_length` (query, optional, string) — Proper length (m) for contraction Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/relativity-api/v1/lorentz?beta=0.8&proper_time=1&proper_length=1"
```

**Response:**
```json
{
    "data": {
        "beta": 0.8,
        "note": "γ = 1/√(1−β²). Moving clocks run slow (Δt = γ·Δt₀); moving lengths contract (L = L₀/γ).",
        "inputs": {
            "beta": 0.8,
            "velocity_ms": 239833966.4
        },
        "velocity_ms": 239833966.4,
        "percent_of_c": 80,
        "proper_time_s": 1,
        "dilated_time_s": 1.666666667,
        "lorentz_factor": 1.666666666667,
        "proper_length_m": 1,
        "contracted_length_m": 0.6
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:05.369Z",
        "request_id": "5c1b9385-9cfc-43dd-9a2a-f95369750444"
    },
    "status": "ok",
    "message": "Lorentz factor",
    "success": true
}
```

#### `GET /v1/mass-energy` — E = mc²

**Parameters:**
- `mass` (query, optional, string) — Mass (kg) Example: `1`
- `energy` (query, optional, string) — Or energy (J)
- `energy_ev` (query, optional, string) — Or energy (eV)

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

**Response:**
```json
{
    "data": {
        "note": "E = mc² with c = 299,792,458 m/s. 1 kg ⇄ 8.98755×10¹⁶ J ≈ 24.97 billion kWh.",
        "inputs": {
            "source": "mass"
        },
        "mass_kg": 1,
        "energy_j": 89875517900000000,
        "energy_ev": 5.6095886e+35,
        "energy_kwh": 24965421600,
        "energy_mev": 5.6095885999999995e+29
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:05.459Z",
        "request_id": "87be3687-6ee8-45b5-a9e9-ea0d88655760"
    },
    "status": "ok",
    "message": "Mass-energy",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "c = 299,792,458 m/s. Velocity via 'velocity' (m/s), 'velocity_kms', or 'beta' (v/c); β must be < 1. Energies reported in J, eV and kWh.",
        "service": "relativity-api",
        "formulae": {
            "energy": "E = γmc², KE = (γ−1)mc², p = γmv",
            "lorentz": "γ = 1/√(1 − β²), β = v/c",
            "mass_energy": "E = mc²",
            "time_dilation": "Δt = γ·Δt₀",
            "length_contraction": "L = L₀/γ"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/energy": "Rest, total and kinetic energy and relativistic momentum from mass and velocity.",
            "GET /v1/lorentz": "Lorentz factor from a velocity, with optional time dilation and length contraction.",
            "GET /v1/mass-energy": "Convert between mass and energy via E = mc²."
        },
        "description": "Special-relativity calculator: Lorentz factor with time dilation and length contraction, relativistic energy and momentum, and mass–energy equivalence (E = mc²)."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:05.561Z",
        "request_id": "07c7910f-9ae7-4ad9-a6cc-27924805dfce"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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