# Vector API
> A 2D, 3D and n-dimensional vector maths toolkit. The op endpoint performs the operation you ask for on one or two vectors: add and subtract, scale by a factor, negate, the dot product, the cross product (a vector in 3D, the scalar z-component in 2D), the magnitude (length), the unit (normalized) vector, the Euclidean distance and the angle between two vectors (in both radians and degrees), linear interpolation (lerp) between two vectors, and the projection of one vector onto another. The info endpoint analyses a single vector — its dimension, magnitude, unit vector and, for 2D, its heading angle from the x-axis. Vectors are just comma-separated components like 3,4 or 1,2,3, and operations work in any dimension up to 32 (cross product is 2D/3D only). Everything is exact local maths, so it is instant and deterministic. Ideal for game and physics engines, graphics and WebGL/canvas, robotics and navigation, data-visualisation, simulations and engineering tools. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This does vector algebra; for plane-angle unit conversion use the Angle API and for shape area/perimeter use the Geometry 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/vector-api/..."
```

## Pricing
- **Free** (Free) — 1,935 calls/Mo, 2 req/s
- **Starter** ($3/Mo) — 11,450 calls/Mo, 8 req/s
- **Pro** ($23/Mo) — 165,500 calls/Mo, 20 req/s
- **Mega** ($61/Mo) — 870,000 calls/Mo, 50 req/s

## Endpoints

### Vector

#### `GET /v1/info` — Analyse a vector

**Parameters:**
- `a` (query, required, string) — The vector, e.g. 3,4 Example: `3,4`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/vector-api/v1/info?a=3%2C4"
```

**Response:**
```json
{
    "data": {
        "unit": [
            0.6,
            0.8
        ],
        "vector": [
            3,
            4
        ],
        "heading": {
            "degrees": 53.130102354,
            "radians": 0.927295218
        },
        "is_zero": false,
        "dimension": 2,
        "magnitude": 5
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:05.539Z",
        "request_id": "5d9df3b7-e12a-4d54-b44c-74f815c213b9"
    },
    "status": "ok",
    "message": "Analyse a vector",
    "success": true
}
```

#### `GET /v1/op` — Vector operation

**Parameters:**
- `op` (query, required, string) — add, subtract, scale, dot, cross, magnitude, normalize, distance, angle, lerp, negate, project Example: `cross`
- `a` (query, required, string) — First vector, e.g. 1,0,0 Example: `1,0,0`
- `b` (query, optional, string) — Second vector (binary ops) Example: `0,1,0`
- `scalar` (query, optional, string) — Factor for scale
- `t` (query, optional, string) — Interpolation amount for lerp (0..1)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/vector-api/v1/op?op=cross&a=1%2C0%2C0&b=0%2C1%2C0"
```

**Response:**
```json
{
    "data": {
        "a": [
            1,
            0,
            0
        ],
        "b": [
            0,
            1,
            0
        ],
        "op": "cross",
        "result": [
            0,
            0,
            1
        ]
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:05.654Z",
        "request_id": "32fa58a5-e2fd-4f20-b29c-0ea2d5227873"
    },
    "status": "ok",
    "message": "Vector operation",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Vector API",
        "notes": "Binary ops require both vectors to have the same dimension. The cross product returns a vector for 3D and the scalar z-component for 2D. Angles are returned in both radians and degrees. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/op",
                "params": {
                    "a": "first vector, e.g. 3,4",
                    "b": "second vector (for binary ops)",
                    "t": "interpolation amount for lerp (0..1)",
                    "op": "add, subtract, scale, dot, cross, magnitude, normalize, distance, angle, lerp, negate, project",
                    "scalar": "the factor for scale"
                },
                "returns": "the resulting vector or scalar"
            },
            {
                "path": "/v1/info",
                "params": {
                    "a": "the vector, e.g. 3,4,0"
                },
                "returns": "dimension, magnitude, unit vector and (2D) heading angle"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "2D, 3D and n-dimensional vector maths. The op endpoint adds, subtracts, scales, negates, takes the dot and cross product, the magnitude, the unit (normalized) vector, the distance and the angle between two vectors, linearly interpolates (l
…(truncated, see openapi.json for full schema)
```


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