# Interpolation API
> Interpolation maths as an API, computed locally and deterministically. The linear endpoint interpolates between two points, y = y0 + (y1 − y0)·(x − x0)/(x1 − x0), returning the value at a target x (or, given a target y, solving the x that produces it), the parameter t and whether the point lies outside the segment. The table endpoint does piecewise-linear interpolation within a table of (x, y) points supplied as comma-separated lists — it sorts the points, finds the two that bracket your query and interpolates between them, extending the nearest segment and flagging the result when you query outside the data range, ideal for calibration curves and lookup tables. The bilinear endpoint interpolates on a rectangular grid from four corner values, interpolating along x at each y-edge and then along y. Everything is computed locally and deterministically, so it is instant and private, and unlike regression it passes exactly through the supplied points. Ideal for engineering, data-visualisation, gaming, mapping and scientific-computing app developers, lookup-table and calibration tools, and numerical-methods education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is interpolation; for least-squares regression and correlation use a statistics 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/interpolation-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 300,000 calls/Mo, 20 req/s
- **Mega** ($45/Mo) — 2,000,000 calls/Mo, 60 req/s

## Endpoints

### Interpolation

#### `GET /v1/bilinear` — Bilinear interpolation

**Parameters:**
- `x1` (query, required, string) — Grid x1 Example: `0`
- `x2` (query, required, string) — Grid x2 Example: `1`
- `y1` (query, required, string) — Grid y1 Example: `0`
- `y2` (query, required, string) — Grid y2 Example: `1`
- `q11` (query, required, string) — Value at (x1,y1) Example: `0`
- `q21` (query, required, string) — Value at (x2,y1) Example: `10`
- `q12` (query, required, string) — Value at (x1,y2) Example: `20`
- `q22` (query, required, string) — Value at (x2,y2) Example: `30`
- `x` (query, required, string) — Query x Example: `0.5`
- `y` (query, required, string) — Query y Example: `0.5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/interpolation-api/v1/bilinear?x1=0&x2=1&y1=0&y2=1&q11=0&q21=10&q12=20&q22=30&x=0.5&y=0.5"
```

**Response:**
```json
{
    "data": {
        "tx": 0.5,
        "ty": 0.5,
        "note": "Bilinear interpolation: interpolate along x at each y-edge (q11→q21 and q12→q22), then along y. q11=(x1,y1), q21=(x2,y1), q12=(x1,y2), q22=(x2,y2).",
        "value": 15,
        "inputs": {
            "x": 0.5,
            "y": 0.5,
            "x1": 0,
            "x2": 1,
            "y1": 0,
            "y2": 1
        },
        "extrapolated": false
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:06.621Z",
        "request_id": "a2750d06-8868-4449-a86f-0f71c66a2d70"
    },
    "status": "ok",
    "message": "Bilinear interp",
    "success": true
}
```

#### `GET /v1/linear` — Linear interpolation

**Parameters:**
- `x0` (query, required, string) — First point x Example: `0`
- `y0` (query, required, string) — First point y Example: `0`
- `x1` (query, required, string) — Second point x Example: `10`
- `y1` (query, required, string) — Second point y Example: `100`
- `x` (query, optional, string) — Query x (returns y) Example: `3`
- `y` (query, optional, string) — Or query y (returns x)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/interpolation-api/v1/linear?x0=0&y0=0&x1=10&y1=100&x=3"
```

**Response:**
```json
{
    "data": {
        "t": 0.3,
        "x": 3,
        "y": 30,
        "note": "Linear interpolation y = y0 + (y1−y0)·(x−x0)/(x1−x0). 'extrapolated' is true when the point lies outside the segment.",
        "inputs": {
            "point0": [
                0,
                0
            ],
            "point1": [
                10,
                100
            ]
        },
        "extrapolated": false
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:06.713Z",
        "request_id": "5bef30b7-24d8-48c4-8a26-3bed2a17107e"
    },
    "status": "ok",
    "message": "Linear interp",
    "success": true
}
```

#### `GET /v1/table` — Table interpolation

**Parameters:**
- `x_values` (query, required, string) — Comma-separated x values Example: `0,10,20`
- `y_values` (query, required, string) — Comma-separated y values Example: `0,100,150`
- `x` (query, required, string) — Query x Example: `15`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/interpolation-api/v1/table?x_values=0%2C10%2C20&y_values=0%2C100%2C150&x=15"
```

**Response:**
```json
{
    "data": {
        "y": 125,
        "note": "Piecewise-linear interpolation between the two bracketing points. Outside the data range the nearest segment is extended and 'extrapolated' is true.",
        "inputs": {
            "x": 15,
            "points": 3
        },
        "segment": {
            "to": [
                20,
                150
            ],
            "from": [
                10,
                100
            ]
        },
        "extrapolated": false
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:06.833Z",
        "request_id": "f97f270f-c297-49d3-8c04-d5349bef80b0"
    },
    "status": "ok",
    "message": "Table interp",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Tables are passed as comma-separated 'x_values' and 'y_values'. 'extrapolated' flags points outside the known range. Distinct from regression — interpolation passes exactly through the given points.",
        "service": "interpolation-api",
        "formulae": {
            "linear": "y = y0 + (y1−y0)·(x−x0)/(x1−x0)",
            "bilinear": "interpolate along x at each y-edge, then along y"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/table": "Piecewise-linear interpolation within a table of points.",
            "GET /v1/linear": "Linear interpolation between two points; solve y from x or x from y.",
            "GET /v1/bilinear": "Bilinear interpolation on a rectangular grid from four corner values."
        },
        "description": "Interpolation calculator: linear interpolation/extrapolation between two points (and the inverse), piecewise-linear lookup within an (x,y) table, and bilinear interpolation on a 2D grid."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:06.918Z",
        "request_id": "e2635980-90a5-49d3-b453-b9ec6065a244"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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