Skip to content

Making a call

Rollful is a dice-rolling API over plain JSON and HTTP. There is no key, no signup and no account, so a call is a request and nothing else — every language can make one.

The base URL is https://api.rollful.dev, and the rolling itself is OpenDice. In JavaScript you can skip the network and use the package directly.

Send a formula, get back every die it rolled.

Terminal window
curl 'https://api.rollful.dev/v1/roll?formula=4d6kh3'

Every call answers with the same shape:

{
"formula": "4d6kh3",
"dice": [
{
"sides": 6,
"results": [5, 4, 5, 3],
"kept": [5, 5, 4],
"keptFlags": [true, true, true, false],
"total": 14
}
],
"total": 14
}

results holds every die, including the one that was dropped, and keptFlags lines up with it so an interface can dim that die rather than hide it. Reading a result walks through each field.

GET takes a formula and little else. For anything more, POST the same roll as JSON.

Terminal window
curl -X POST https://api.rollful.dev/v1/roll \
-H 'content-type: application/json' \
-d '{"formula":"1d20+7","advantage":"advantage"}'

A body may also carry bonuses, which add dice or numbers to the roll, and tags, which name the words a formula is allowed to end with. Both are described on the endpoint itself.

POST /v1/roll/batch takes up to 20 rolls and answers with the same number of results, in order. One request rather than twenty is the difference between one round trip and twenty, and the whole batch is counted against a single dice budget.

Terminal window
curl -X POST https://api.rollful.dev/v1/roll/batch \
-H 'content-type: application/json' \
-d '{"rolls":[{"formula":"4d6kh3"},{"formula":"4d6kh3"},{"formula":"4d6kh3"}]}'

The API describes itself at api.rollful.dev/openapi.json, an OpenAPI 3.1 document generated from the same schemas that validate the requests — so it cannot describe an API this one does not serve. Point a client generator at it, or import it into whatever you use to poke at HTTP.

Terminal window
curl https://api.rollful.dev/openapi.json