# Matrix API
> Linear algebra as an API: multiply matrices, analyse a matrix, and solve linear systems — all computed locally and exactly. The multiply endpoint returns the product A×B, checking that the inner dimensions match. The analyze endpoint takes any matrix and returns its transpose and rank, and for square matrices also the determinant, trace, whether it is symmetric and invertible, and the inverse when it exists — using LU decomposition with partial pivoting and Gauss-Jordan elimination for numerical stability. The solve endpoint solves a system Ax = b for a square coefficient matrix by Gaussian elimination with partial pivoting, and reports cleanly when the matrix is singular and there is no unique solution. Matrices are passed as JSON arrays of rows, for example [[1,2],[3,4]]. Everything is deterministic and instant. Ideal for data-science and machine-learning prep, computer graphics and 3D transforms, engineering and physics, computer-vision calibration, control systems, and teaching linear algebra. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. This is matrix and linear-algebra maths; for 3D rotations use a quaternion API, for vector maths use a vector API, and for statistics use a stats 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/matrix-api/..."
```

## Pricing
- **Free** (Free) — 5,935 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 15,450 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 205,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,070,000 calls/Mo, 50 req/s

## Endpoints

### Matrix

#### `GET /v1/analyze` — Analyze a matrix

**Parameters:**
- `matrix` (query, required, string) — Matrix as JSON Example: `[[1,2],[3,4]]`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/matrix-api/v1/analyze?matrix=%5B%5B1%2C2%5D%2C%5B3%2C4%5D%5D"
```

**Response:**
```json
{
    "data": {
        "rank": 2,
        "trace": 5,
        "square": true,
        "inverse": [
            [
                -2,
                1
            ],
            [
                1.5,
                -0.5
            ]
        ],
        "symmetric": false,
        "transpose": [
            [
                1,
                3
            ],
            [
                2,
                4
            ]
        ],
        "dimensions": {
            "cols": 2,
            "rows": 2
        },
        "invertible": true,
        "determinant": -2
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:15.455Z",
        "request_id": "f23e9296-abe8-46c9-a78a-356bcf5aa975"
    },
    "status": "ok",
    "message": "Analyze matrix",
    "success": true
}
```

#### `GET /v1/multiply` — Multiply two matrices

**Parameters:**
- `a` (query, required, string) — Matrix A as JSON Example: `[[1,2],[3,4]]`
- `b` (query, required, string) — Matrix B as JSON Example: `[[5,6],[7,8]]`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/matrix-api/v1/multiply?a=%5B%5B1%2C2%5D%2C%5B3%2C4%5D%5D&b=%5B%5B5%2C6%5D%2C%5B7%2C8%5D%5D"
```

**Response:**
```json
{
    "data": {
        "product": [
            [
                19,
                22
            ],
            [
                43,
                50
            ]
        ],
        "a_dimensions": {
            "cols": 2,
            "rows": 2
        },
        "b_dimensions": {
            "cols": 2,
            "rows": 2
        },
        "result_dimensions": {
            "cols": 2,
            "rows": 2
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:15.573Z",
        "request_id": "b2ba4a75-bc44-4102-9e40-f2785ad0a33b"
    },
    "status": "ok",
    "message": "Multiply matrices",
    "success": true
}
```

#### `GET /v1/solve` — Solve Ax = b

**Parameters:**
- `a` (query, required, string) — Square coefficient matrix Example: `[[2,1],[1,3]]`
- `b` (query, required, string) — Right-hand side vector Example: `[3,5]`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/matrix-api/v1/solve?a=%5B%5B2%2C1%5D%2C%5B1%2C3%5D%5D&b=%5B3%2C5%5D"
```

**Response:**
```json
{
    "data": {
        "solution": [
            0.8,
            1.4
        ],
        "dimensions": {
            "cols": 2,
            "rows": 2
        },
        "unique_solution": true
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:15.661Z",
        "request_id": "2f0d16a6-4000-43d9-8066-047d2546c6e9"
    },
    "status": "ok",
    "message": "Solve linear system",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Matrix API",
        "notes": "Matrices up to 60x60. Singular matrices return invertible=false / no unique solution rather than erroring. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/multiply",
                "params": {
                    "a": "matrix [[…]]",
                    "b": "matrix [[…]]"
                },
                "returns": "the matrix product and its dimensions"
            },
            {
                "path": "/v1/analyze",
                "params": {
                    "matrix": "matrix [[…]]"
                },
                "returns": "transpose, rank, and (square) determinant, trace, symmetry, inverse"
            },
            {
                "path": "/v1/solve",
                "params": {
                    "a": "square coefficient matrix [[…]]",
                    "b": "right-hand side vector […]"
                },
                "returns": "the solution vector x of Ax=b"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Linear algebra as an API: multiply matrices, analyse a matrix, and solve linear systems — all computed locally and exactly. The multiply endpoint returns the product A×B (checking that the inner dimensions match). The analyze endpoint takes any matrix and returns its 
…(truncated, see openapi.json for full schema)
```


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