Skip to content
🎲 Heroku app to roll some dice
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docker
protos
scripts
spec
src
tests
www
.gitignore
.scrutinizer.yml
.travis.yml
Dockerfile
LICENSE
Procfile
README.md
compile_protos.sh
composer.json
composer.lock
docker-compose-test.yml
docker-compose.yml
heroku.yml
phpspec.yml
psalm.xml
run_tests.sh
watch.sh

README.md

DiceApi

Build Status Scrutinizer Code Quality

This is a semi joking api to simulate a pile of dice being thrown. The idea is fully inspired by/stolen from deckofcardsapi.com. If you find any bugs or have feature requests, the project can be found on github at DiceApi on GitHub or send me a tweet @MeadSteve.

Rolling

Roll a single dice

GET http://roll.diceapi.com/json/d6

Response:

{
  "success":true,
  "dice":[
    {"value":2,"name":"d6"}
  ]
}

Roll multiple dice

GET http://roll.diceapi.com/json/d6/d20

Response:

{
  "success":true,
  "dice":[
    {"value":2,"name":"d6"},
    {"value":18,"name":"d20"}
  ]
}

Roll batches of dice

GET http://roll.diceapi.com/json/2d6/d4

Response:

{
  "success":true,
  "dice":[
    {"value":2,"name":"d6"},
    {"value":4,"name":"d6"},
    {"value":3,"name":"d4"}
  ]
}

Response types

By default the API assumes you want an html response. You have other options though:

text/html

This response type currently only supports d6 and d20 rolls.

curl --header "Accept: text/html" http://roll.diceapi.com/d6

GET http://roll.diceapi.com/html/d6

Response:

<img src="http://roll.diceapi.com/images/poorly-drawn/d6/4.png" />

dice with 4 spots

application/json

curl --header "Accept: application/json" http://roll.diceapi.com/d6

GET http://roll.diceapi.com/json/d6

You can’t perform that action at this time.