# Statistics Calculator API
> Descriptive-statistics maths as an API, computed locally and deterministically. The descriptive endpoint summarises a list of numbers — the count, sum, mean, median, mode, minimum, maximum and range, the population and sample variance and standard deviation, and the quartiles Q1/Q2/Q3 with the interquartile range by Tukey's method. The correlation endpoint computes the Pearson correlation coefficient r between two equal-length series — from −1 (perfect inverse) through 0 (none) to +1 (perfect direct) — along with R² and the covariance. The regression endpoint fits a least-squares line y = a + b·x, returning the slope, intercept and R², the equation, and an optional prediction for a given x. Data is accepted as a JSON array or a comma-separated list. Everything is computed locally and deterministically, so it is instant and private. Ideal for data-analysis, dashboard, research and education app developers, reporting and BI tools, and spreadsheet replacements. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is descriptive statistics; for probability distributions and combinatorics use a probability 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/statistics-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($19/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($59/Mo) — 1,500,000 calls/Mo, 40 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,5,4,5`

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

**Response:**
```json
{
    "data": {
        "note": "Pearson r = Σ(x−x̄)(y−ȳ) / √(Σ(x−x̄)²·Σ(y−ȳ)²), ranging from −1 (perfect inverse) to +1 (perfect direct).",
        "inputs": {
            "count": 5
        },
        "pearson_r": 0.774597,
        "r_squared": 0.6,
        "covariance_sample": 1.5,
        "covariance_population": 1.2
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:14.865Z",
        "request_id": "f9b0d955-cf09-4362-9e70-5e7eba06e272"
    },
    "status": "ok",
    "message": "Pearson correlation",
    "success": true
}
```

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

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

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

**Response:**
```json
{
    "data": {
        "q1": 4,
        "q3": 6,
        "iqr": 2,
        "max": 9,
        "min": 2,
        "sum": 40,
        "mean": 5,
        "mode": [
            4
        ],
        "note": "Population divides by n, sample by n−1. Quartiles by Tukey's method. Mode is null when all values are unique.",
        "range": 7,
        "inputs": {
            "count": 8
        },
        "median": 4.5,
        "q2_median": 4.5,
        "stddev_sample": 2.13809,
        "variance_sample": 4.571429,
        "stddev_population": 2,
        "variance_population": 4
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:14.976Z",
        "request_id": "d7340679-d55e-4b90-aefd-7d0497d416eb"
    },
    "status": "ok",
    "message": "Descriptive stats",
    "success": true
}
```

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

**Parameters:**
- `x` (query, required, string) — Independent series Example: `1,2,3,4,5`
- `y` (query, required, string) — Dependent series Example: `2,4,5,4,5`
- `predict_x` (query, optional, string) — Predict y at this x Example: `6`

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

**Response:**
```json
{
    "data": {
        "note": "Least-squares line y = a + b·x with b = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)². Pass 'predict_x' to predict y.",
        "slope": 0.6,
        "inputs": {
            "count": 5
        },
        "equation": "y = 2.2 + 0.6x",
        "intercept": 2.2,
        "r_squared": 0.6,
        "predicted_y": 5.8
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:15.090Z",
        "request_id": "67e890e0-d913-41b0-b08e-8e5575beca73"
    },
    "status": "ok",
    "message": "Linear regression",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Data as a JSON array or comma-separated list. Quartiles use Tukey's method. For x/y endpoints the two lists must be the same length.",
        "service": "statistics-api",
        "formulae": {
            "variance": "population /n, sample /(n−1)",
            "regression": "slope = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²,  intercept = ȳ − slope·x̄",
            "correlation": "r = Σ(x−x̄)(y−ȳ) / √(Σ(x−x̄)²·Σ(y−ȳ)²)"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/regression": "Least-squares linear regression (slope, intercept, R²) with optional prediction.",
            "GET /v1/correlation": "Pearson correlation and covariance between two equal-length series.",
            "GET /v1/descriptive": "Mean, median, mode, variance, standard deviation and quartiles for a list of numbers."
        },
        "description": "Descriptive-statistics calculator: summary statistics for a dataset, Pearson correlation, and simple linear regression."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:15.170Z",
        "request_id": "98503cb4-4f91-49ff-8bbb-ee3bd2f08e36"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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