# Statistics API
> Run statistics on a list of numbers without a spreadsheet or a stats package. The describe endpoint returns a full summary of a dataset — count, sum, min, max, range, mean, median, mode, the first and third quartiles and interquartile range, population and sample variance and standard deviation, coefficient of variation, geometric and harmonic means, skewness and kurtosis. Get any percentile of a dataset, the Pearson correlation coefficient (and r²) between two equal-length series, and a simple linear regression (slope, intercept, r² and the line equation). Input is a raw array of numbers (JSON or a comma-separated list) — no CSV, no headers. Perfect for analytics, A/B test summaries, sensor and metrics data, dashboards and quick exploratory analysis. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 5 endpoints. Distinct from the mathjs expression engine and from CSV per-column summaries.

## 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/stats-api/..."
```

## Pricing
- **Free** (Free) — 1,020 calls/Mo, 2 req/s
- **Starter** ($2/Mo) — 8,700 calls/Mo, 8 req/s
- **Pro** ($22/Mo) — 138,000 calls/Mo, 20 req/s
- **Mega** ($58/Mo) — 710,000 calls/Mo, 50 req/s

## Endpoints

### Statistics

#### `GET /v1/correlation` — Pearson correlation

**Parameters:**
- `x` (query, required, string) — First series Example: `1,2,3,4,5`
- `y` (query, required, string) — Second series (same length) Example: `2,4,6,8,10`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stats-api/v1/correlation?x=1%2C2%2C3%2C4%2C5&y=2%2C4%2C6%2C8%2C10"
```

**Response:**
```json
{
    "data": {
        "n": 5,
        "pearson_r": 1,
        "r_squared": 1
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:48.820Z",
        "request_id": "4a9c1bbf-03e9-496f-b776-ec5569afb93d"
    },
    "status": "ok",
    "message": "Pearson correlation",
    "success": true
}
```

#### `GET /v1/describe` — Descriptive statistics

**Parameters:**
- `numbers` (query, required, string) — JSON array or comma list Example: `2,4,4,4,5,5,7,9`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stats-api/v1/describe?numbers=2%2C4%2C4%2C4%2C5%2C5%2C7%2C9"
```

**Response:**
```json
{
    "data": {
        "q1": 4,
        "q3": 5.5,
        "iqr": 1.5,
        "max": 9,
        "min": 2,
        "sum": 40,
        "mean": 5,
        "mode": 4,
        "count": 8,
        "range": 7,
        "median": 4.5,
        "kurtosis": 0.940625,
        "skewness": 0.81848755,
        "harmonic_mean": 4.20175073,
        "sample_stddev": 2.13808994,
        "geometric_mean": 4.6032156,
        "sample_variance": 4.57142857,
        "population_stddev": 2,
        "population_variance": 4,
        "coefficient_of_variation": 0.42761799
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:48.928Z",
        "request_id": "ead2f6c9-1b16-42d0-be10-041398bb95b8"
    },
    "status": "ok",
    "message": "Descriptive statistics",
    "success": true
}
```

#### `GET /v1/percentile` — Percentile of a dataset

**Parameters:**
- `numbers` (query, required, string) — JSON array or comma list Example: `1,2,3,4,5,6,7,8,9,10`
- `p` (query, required, string) — Percentile 0-100 Example: `90`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stats-api/v1/percentile?numbers=1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10&p=90"
```

**Response:**
```json
{
    "data": {
        "p": 90,
        "count": 10,
        "value": 9.1
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:49.035Z",
        "request_id": "175966e6-b1f6-44b0-b9cd-16644e10e564"
    },
    "status": "ok",
    "message": "Percentile of a dataset",
    "success": true
}
```

#### `GET /v1/regression` — Linear regression

**Parameters:**
- `x` (query, required, string) — X series Example: `1,2,3,4,5`
- `y` (query, required, string) — Y series (same length) Example: `2,4,5,4,5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stats-api/v1/regression?x=1%2C2%2C3%2C4%2C5&y=2%2C4%2C5%2C4%2C5"
```

**Response:**
```json
{
    "data": {
        "n": 5,
        "slope": 0.6,
        "equation": "y = 0.6x + 2.2",
        "intercept": 2.2,
        "r_squared": 0.6
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:49.139Z",
        "request_id": "4452ca73-f667-434d-8781-cfcf14b89839"
    },
    "status": "ok",
    "message": "Linear regression",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Statistics API",
        "notes": "Sample statistics (variance/stddev) need n≥2, skewness n≥3, kurtosis n≥4; geometric/harmonic mean need all-positive values (null otherwise). Operates on raw number arrays, not CSV.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/describe",
                "params": {
                    "numbers": "JSON array or comma list (required)"
                },
                "returns": "full descriptive summary"
            },
            {
                "path": "/v1/percentile",
                "params": {
                    "p": "0-100 (required)",
                    "numbers": "array (required)"
                },
                "returns": "the p-th percentile"
            },
            {
                "path": "/v1/correlation",
                "params": {
                    "x": "array (required)",
                    "y": "array, same length (required)"
                },
                "returns": "Pearson r and r²"
            },
            {
                "path": "/v1/regression",
                "params": {
                    "x": "array (required)",
                    "y": "array, same length (required)"
                },
                "returns": "slope, intercept, r², equation"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        
…(truncated, see openapi.json for full schema)
```


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