# Combinatorics API
> Combinatorics maths as an API, computed locally and deterministically with exact arbitrary-precision integers. The factorial endpoint computes n! = 1·2·3···n (with 0! = 1) and returns it exactly as a string together with its digit count, so even very large factorials stay precise. The permutations endpoint counts ordered arrangements: without repetition nPr = n!/(n−r)! arrangements of r items chosen from n, and with repetition n^r, where each of the r positions may be any of the n items. The combinations endpoint counts unordered selections: without repetition the binomial coefficient nCr = n!/(r!·(n−r)!), and with repetition (multisets) C(n+r−1, r), where repeats are allowed. All results are computed with BigInt so they are exact no matter how large, returned as a string with the number of digits and a floating-point approximation when it fits. n and r are non-negative integers up to 100000. Everything is computed locally and deterministically, so it is instant and private. Ideal for probability, statistics, lottery, game-design, cryptography and education app developers, counting and odds tools, and discrete-maths teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is counting combinatorics; for modular arithmetic use a modular API and for descriptive statistics 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/combinatorics-api/..."
```

## Pricing
- **Free** (Free) — 4,200 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 44,000 calls/Mo, 6 req/s
- **Pro** ($13/Mo) — 222,000 calls/Mo, 15 req/s
- **Mega** ($42/Mo) — 1,310,000 calls/Mo, 40 req/s

## Endpoints

### Combinatorics

#### `GET /v1/combinations` — Combinations

**Parameters:**
- `n` (query, required, string) — Total items n Example: `10`
- `r` (query, required, string) — Chosen r Example: `3`
- `repetition` (query, optional, string) — Allow repetition (true/false) Example: `false`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/combinatorics-api/v1/combinations?n=10&r=3&repetition=false"
```

**Response:**
```json
{
    "data": {
        "note": "Combinations without repetition: the binomial coefficient nCr = n!/(r!·(n−r)!) unordered selections.",
        "inputs": {
            "n": 10,
            "r": 3,
            "repetition": false
        },
        "formula": "n! / (r!·(n − r)!)",
        "combinations": {
            "exact": "120",
            "digits": 3,
            "approximate": 120
        }
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:31.938Z",
        "request_id": "433627c2-5c4a-4e47-825a-c891aea78961"
    },
    "status": "ok",
    "message": "Combinations",
    "success": true
}
```

#### `GET /v1/factorial` — Factorial

**Parameters:**
- `n` (query, required, string) — Non-negative integer Example: `10`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/combinatorics-api/v1/factorial?n=10"
```

**Response:**
```json
{
    "data": {
        "note": "n! = 1·2·3···n (0! = 1). Returned exactly as a string; the floating-point approximation is null once it exceeds ~1.8×10^308.",
        "inputs": {
            "n": 10
        },
        "factorial": {
            "exact": "3628800",
            "digits": 7,
            "approximate": 3628800
        }
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:32.029Z",
        "request_id": "63d6cf92-61b6-4ef3-92ec-a2cb169b92c2"
    },
    "status": "ok",
    "message": "Factorial",
    "success": true
}
```

#### `GET /v1/permutations` — Permutations

**Parameters:**
- `n` (query, required, string) — Total items n Example: `10`
- `r` (query, required, string) — Chosen r Example: `3`
- `repetition` (query, optional, string) — Allow repetition (true/false) Example: `false`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/combinatorics-api/v1/permutations?n=10&r=3&repetition=false"
```

**Response:**
```json
{
    "data": {
        "note": "Permutations without repetition: nPr = n!/(n−r)! ordered arrangements of r items from n.",
        "inputs": {
            "n": 10,
            "r": 3,
            "repetition": false
        },
        "formula": "n! / (n − r)!",
        "permutations": {
            "exact": "720",
            "digits": 3,
            "approximate": 720
        }
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:32.128Z",
        "request_id": "72a4365b-f917-4e8e-bb7d-2f2a9604776c"
    },
    "status": "ok",
    "message": "Permutations",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "n and r are non-negative integers up to 100000. Results are exact (BigInt) and returned as a string with the digit count; a float approximation is included when it fits.",
        "service": "combinatorics-api",
        "formulae": {
            "combinations": "nCr = n!/(r!(n−r)!) ; with repetition C(n+r−1, r)",
            "permutations": "nPr = n!/(n−r)! ; with repetition n^r"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/factorial": "n! as an exact integer with its digit count.",
            "GET /v1/combinations": "nCr (binomial) unordered selections, with or without repetition.",
            "GET /v1/permutations": "nPr ordered arrangements, with or without repetition."
        },
        "description": "Combinatorics calculator: factorial, permutations and combinations with or without repetition, computed exactly with arbitrary-precision integers."
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:32.244Z",
        "request_id": "f571f840-2261-4745-8ddf-20657a6966a7"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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