# Quaternion API
> 3D rotation maths as an API: convert freely between quaternions, Euler angles, axis-angle and rotation matrices, compose rotations, rotate vectors, and interpolate. The convert endpoint takes any one representation — a quaternion {w,x,y,z}, Euler angles (roll, pitch, yaw), an axis and angle, or a 3×3 matrix — and returns all four forms at once, normalized. The multiply endpoint composes two quaternions (the Hamilton product) so you can chain rotations. The rotate endpoint applies a quaternion to a 3D vector. The slerp endpoint does spherical linear interpolation between two orientations along the shortest path — the standard way to animate smooth rotations. Euler angles use the aerospace Z-Y-X (yaw-pitch-roll) intrinsic convention in degrees; quaternions follow the Hamilton convention with order w,x,y,z; matrices are row-major right-handed. Everything is computed locally and deterministically, so it is instant and private. Ideal for game and graphics engines, robotics and drones, IMU and sensor fusion, aerospace and flight dynamics, VR/AR, and 3D content tooling. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 5 endpoints. This is 3D rotation maths; for 2D geometry use a geometry API and for plain angle-unit conversion use an angle 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/quaternion-api/..."
```

## Pricing
- **Free** (Free) — 5,835 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 15,350 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 204,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,065,000 calls/Mo, 50 req/s

## Endpoints

### Quaternion

#### `GET /v1/convert` — Convert between rotation forms

**Parameters:**
- `from` (query, optional, string) — euler|quaternion|axis_angle|matrix Example: `euler`
- `roll` (query, optional, string) — roll deg (euler) Example: `0`
- `pitch` (query, optional, string) — pitch deg (euler) Example: `0`
- `yaw` (query, optional, string) — yaw deg (euler) Example: `90`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/quaternion-api/v1/convert?from=euler&roll=0&pitch=0&yaw=90"
```

**Response:**
```json
{
    "data": {
        "matrix": [
            [
                2.22044604925e-16,
                -1,
                0
            ],
            [
                1,
                2.22044604925e-16,
                0
            ],
            [
                0,
                0,
                1
            ]
        ],
        "axis_angle": {
            "axis": [
                0,
                0,
                1
            ],
            "angle_deg": 90
        },
        "quaternion": {
            "w": 0.707106781187,
            "x": 0,
            "y": 0,
            "z": 0.707106781187
        },
        "euler_zyx_deg": {
            "yaw_deg": 90,
            "roll_deg": 0,
            "pitch_deg": 0
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:15.860Z",
        "request_id": "dab0b7ef-1777-4a0f-95aa-50d4762d152e"
    },
    "status": "ok",
    "message": "Convert rotation",
    "success": true
}
```

#### `GET /v1/multiply` — Compose two quaternions

**Parameters:**
- `q1` (query, required, string) — w,x,y,z Example: `0.7071,0,0,0.7071`
- `q2` (query, required, string) — w,x,y,z Example: `0.7071,0,0,0.7071`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/quaternion-api/v1/multiply?q1=0.7071%2C0%2C0%2C0.7071&q2=0.7071%2C0%2C0%2C0.7071"
```

**Response:**
```json
{
    "data": {
        "note": "q1 ⊗ q2 (Hamilton product) — applies q2 then q1",
        "matrix": [
            [
                -1,
                0,
                0
            ],
            [
                0,
                -1,
                0
            ],
            [
                0,
                0,
                1
            ]
        ],
        "axis_angle": {
            "axis": [
                0,
                0,
                1
            ],
            "angle_deg": 180
        },
        "quaternion": {
            "w": 0,
            "x": 0,
            "y": 0,
            "z": 1
        },
        "euler_zyx_deg": {
            "yaw_deg": 180,
            "roll_deg": 0,
            "pitch_deg": 0
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:15.957Z",
        "request_id": "88f7b8c3-369a-4937-8ca0-2e129bebc0f0"
    },
    "status": "ok",
    "message": "Multiply quaternions",
    "success": true
}
```

#### `GET /v1/rotate` — Rotate a 3D vector

**Parameters:**
- `q` (query, required, string) — w,x,y,z Example: `0.7071,0,0,0.7071`
- `vector` (query, required, string) — x,y,z Example: `1,0,0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/quaternion-api/v1/rotate?q=0.7071%2C0%2C0%2C0.7071&vector=1%2C0%2C0"
```

**Response:**
```json
{
    "data": {
        "input_vector": [
            1,
            0,
            0
        ],
        "rotated_vector": [
            0,
            1,
            0
        ]
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.058Z",
        "request_id": "89e1a5c1-faa8-444c-b2d5-891cdd838782"
    },
    "status": "ok",
    "message": "Rotate vector",
    "success": true
}
```

#### `GET /v1/slerp` — Spherical interpolation

**Parameters:**
- `q1` (query, required, string) — w,x,y,z Example: `1,0,0,0`
- `q2` (query, required, string) — w,x,y,z Example: `0.7071,0,0,0.7071`
- `t` (query, required, string) — 0..1 Example: `0.5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/quaternion-api/v1/slerp?q1=1%2C0%2C0%2C0&q2=0.7071%2C0%2C0%2C0.7071&t=0.5"
```

**Response:**
```json
{
    "data": {
        "t": 0.5,
        "matrix": [
            [
                0.707106781187,
                -0.707106781187,
                0
            ],
            [
                0.707106781187,
                0.707106781187,
                0
            ],
            [
                0,
                0,
                1
            ]
        ],
        "axis_angle": {
            "axis": [
                0,
                0,
                1
            ],
            "angle_deg": 45
        },
        "quaternion": {
            "w": 0.923879532511,
            "x": 0,
            "y": 0,
            "z": 0.382683432365
        },
        "euler_zyx_deg": {
            "yaw_deg": 45,
            "roll_deg": 0,
            "pitch_deg": 0
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.157Z",
        "request_id": "6778bf06-b0cb-48c6-a65d-2cc41314a715"
    },
    "status": "ok",
    "message": "Slerp",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Quaternion API",
        "notes": "All quaternions are normalized to unit length on output. Euler extraction clamps at the ±90° pitch gimbal point. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/convert",
                "params": {
                    "from": "euler | quaternion | axis_angle | matrix (auto-detected)",
                    "matrix": "9 numbers row-major",
                    "w,x,y,z": "for quaternion",
                    "axis,angle": "for axis-angle",
                    "roll,pitch,yaw": "for euler (deg)"
                },
                "returns": "quaternion, euler, axis-angle and matrix"
            },
            {
                "path": "/v1/multiply",
                "params": {
                    "q1": "w,x,y,z",
                    "q2": "w,x,y,z"
                },
                "returns": "the composed rotation in all forms"
            },
            {
                "path": "/v1/rotate",
                "params": {
                    "q": "w,x,y,z (or w,x,y,z fields)",
                    "vector": "x,y,z"
                },
                "returns": "the rotated vector"
            },
            {
                "path": "/v1/slerp",
                "params": {
                    "t": "0..1",
                    "q1": "w,x,y,z",
                    "q2": "w,x,y,z"
                },
                "returns": "the interpolated orienta
…(truncated, see openapi.json for full schema)
```


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