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