# Dice Roller API

> Dice Roller is a dice API that simulates RPG dice rolls using standard notation like 3d6 or 2d20 with optional modifiers. It outputs the individual die outcomes, die count, and the sum of all rolls.

**Endpoint:** `GET https://api.apiverve.com/v1/diceroller`  
**Category:** Games  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/diceroller

## Overview

Dice Roller works by parsing dice notation (e.g., 3d6+5), simulating random dice rolls, and calculating totals with modifiers. Returns individual roll results, with statistics and theoretical probability ranges on paid plans.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/diceroller?dice=3d6&modifier=5" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `dice` | string | No | Dice notation in XdY format (e.g., 3d6, 2d20, default: 1d6); d20 means one die, d% means d100, spaces are ignored, an inline modifier like 3d6+5 is added to modifier, and a keep/drop suffix (kh, kl, dh, dl followed by a count, e.g. 4d6kh3 or 2d20kh1 for advantage) counts only the kept dice; several groups joined with + (e.g. 1d8+1d6 or 2d6+1d4+3) are rolled and summed. default 1d6. length 0-20 |
| `modifier` | integer | No | Modifier to add to the total (can be negative, -10000 to 10000). default 0. range -10000-10000 |

## Response fields

- `dice_notation` — string · The dice notation used for this roll request
- `num_dice` — number · Total count of individual dice rolled
- `num_sides` — number · Number of sides on each die rolled; with mixed dice such as 1d8+1d6, the largest (each group's own is in groups)
- `modifier` — number · Modifier value added to final total
- `rolls` — array · Array containing individual result values for each die
- `total` — number · Sum of the dice rolls before the modifier is applied (only the kept dice when a keep/drop rule is used)
- `total_with_modifier` — number · Final total after applying the modifier value · (premium)
- `min_roll` — number · Lowest individual die value in this roll · (premium)
- `max_roll` — number · Highest individual die value in this roll · (premium)
- `average_roll` — number · Calculated mean value of all individual rolls · (premium)
- `theoretical_min` — number · Lowest possible sum without any modifiers applied · (premium)
- `theoretical_max` — number · Highest possible sum without any modifiers applied · (premium)
- `theoretical_average` — number · Expected mean value based on probability distribution · (premium)
- `expression` — string · Complete expression including dice notation and modifier

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "dice_notation": "3d6",
    "num_dice": 3,
    "num_sides": 6,
    "modifier": 5,
    "rolls": [
      6,
      4,
      4
    ],
    "total": 14,
    "total_with_modifier": 19,
    "min_roll": 4,
    "max_roll": 6,
    "average_roll": 4.67,
    "theoretical_min": 3,
    "theoretical_max": 18,
    "theoretical_average": 10.5,
    "expression": "3d6+5"
  }
}
```

## Use cases

- **RPG Gaming** — Roll dice for tabletop RPGs, D&D sessions, and role-playing game mechanics
- **Game Development** — Implement dice rolling mechanics in digital games and gaming applications
- **Probability** — Demonstrate probability concepts and dice statistics for educational purposes
- **Simulations** — Generate random numbers with dice distributions for simulations and testing

## SDKs

- **npm** — `npm install @apiverve/diceroller` (https://www.npmjs.com/package/@apiverve/diceroller)
- **NuGet** — `dotnet add package APIVerve.API.DiceRoller` (https://www.nuget.org/packages/APIVerve.API.DiceRoller)
- **Source** — https://github.com/apiverve/diceroller-api

## More

- Full reference: https://docs.apiverve.com/ref/diceroller
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
