# Dice Probability API
> Tabletop dice-probability maths as an API, computed locally and deterministically and exactly — the odds behind the rolls, not the rolls themselves. The advantage endpoint gives the D&D-style chances of beating a target on a d20 (or any die) rolling normally, with advantage (roll twice, keep the higher) or with disadvantage (keep the lower): needing an 11+ is 50 % normally, 75 % with advantage and 25 % with disadvantage, and it reports the average roll — advantage lifts a d20 from 10.5 to about 13.8. The pool endpoint handles success-counting systems (World of Darkness, Shadowrun): for a pool of dice that succeed on a face at or above a threshold it gives the chance per die, the expected number of successes and the exact binomial probability of getting exactly, or at least, a target number — six d10s succeeding on 7+ average 2.4 successes with a 45.6 % chance of three or more. The exploding endpoint gives the mean of an exploding ("acing", open-ended) die that re-rolls and adds on its maximum face — a d6 averages 4.2 instead of 3.5. Everything is computed locally and deterministically, so it is instant and private. Ideal for tabletop, virtual-tabletop, game-design and TTRPG app developers, odds-and-probability helpers, and game-master tools. Pure local computation — no key, no third-party service, instant. Exact maths, no simulation. Live, nothing stored. 3 compute endpoints. For random rolls use a dice-roller 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/dicepool-api/..."
```

## Pricing
- **Free** (Free) — 6,350 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 58,000 calls/Mo, 6 req/s
- **Pro** ($11/Mo) — 238,500 calls/Mo, 15 req/s
- **Mega** ($36/Mo) — 1,370,000 calls/Mo, 40 req/s

## Endpoints

### Dice

#### `GET /v1/advantage` — Advantage / disadvantage odds

**Parameters:**
- `target` (query, required, string) — Target to meet or beat Example: `11`
- `sides` (query, optional, string) — Die sides (default 20) Example: `20`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dicepool-api/v1/advantage?target=11&sides=20"
```

**Response:**
```json
{
    "data": {
        "note": "P(success) = faces ≥ target ÷ sides. Advantage = 1 − (1−p)² (roll twice, keep higher); disadvantage = p². On a d20 advantage adds roughly +3.3 to the average roll.",
        "inputs": {
            "sides": 20,
            "target": 11
        },
        "average_roll": 10.5,
        "average_with_advantage": 13.825,
        "normal_success_percent": 50,
        "advantage_success_percent": 75,
        "average_with_disadvantage": 7.175,
        "disadvantage_success_percent": 25
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:06.897Z",
        "request_id": "306cc059-30c6-4788-b0d7-1ee0fac3dea8"
    },
    "status": "ok",
    "message": "Advantage odds",
    "success": true
}
```

#### `GET /v1/exploding` — Exploding die expectation

**Parameters:**
- `sides` (query, required, string) — Die sides Example: `6`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dicepool-api/v1/exploding?sides=6"
```

**Response:**
```json
{
    "data": {
        "note": "An exploding die re-rolls and adds on its maximum face. Mean = ((sides+1)/2) × sides/(sides−1): a d6 averages 4.2 (vs 3.5), a d10 about 6.11.",
        "inputs": {
            "sides": 6
        },
        "average_normal": 3.5,
        "average_exploding": 4.2,
        "explode_chance_percent": 16.6667
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:06.995Z",
        "request_id": "80f841dd-bce7-44a6-9b0f-3d9bd13e61c6"
    },
    "status": "ok",
    "message": "Exploding dice",
    "success": true
}
```

#### `GET /v1/pool` — Dice-pool success odds

**Parameters:**
- `dice` (query, required, string) — Number of dice Example: `6`
- `success_threshold` (query, required, string) — Face ≥ this is a success Example: `7`
- `sides` (query, optional, string) — Die sides (default 10) Example: `10`
- `target_successes` (query, optional, string) — Target successes (default 1) Example: `3`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dicepool-api/v1/pool?dice=6&success_threshold=7&sides=10&target_successes=3"
```

**Response:**
```json
{
    "data": {
        "note": "Each die succeeds with probability (faces ≥ threshold)/sides; the number of successes is binomial. Expected successes = dice × that chance. Useful for World of Darkness, Shadowrun and other pool systems.",
        "inputs": {
            "dice": 6,
            "sides": 10,
            "target_successes": 3,
            "success_threshold": 7
        },
        "expected_successes": 2.4,
        "probability_exactly_percent": 27.648,
        "probability_at_least_percent": 45.568,
        "success_chance_per_die_percent": 40
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:07.099Z",
        "request_id": "6a7c350b-8656-41f0-baee-07f2d0e311da"
    },
    "status": "ok",
    "message": "Dice pool",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Exact probabilities (no simulation). Advantage rolls two and keeps the higher; pools count successes (face ≥ threshold); exploding dice re-roll on the max face. For random rolls use a dice-roller API.",
        "service": "dicepool-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/pool": "Success-count probabilities for a pool of dice with a success threshold.",
            "GET /v1/advantage": "Normal/advantage/disadvantage success odds and average rolls vs a target.",
            "GET /v1/exploding": "Average of an exploding (acing) die vs a normal one."
        },
        "description": "Tabletop dice probability: D&D advantage/disadvantage odds, dice-pool success probabilities, and exploding-dice expectation."
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:07.193Z",
        "request_id": "e65e0674-e8d1-4965-9b9b-cb6bc67302d4"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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