ROLZ
Dice Room   More

If you want to use the Online Dice Roller capabilities in your app, you can use the official API to do that. Here's how it works!

Dice Room Data

A JSON feed of your dice room log is available at
https://rolz.org/api/roomlog?room=lobby
^ you can replace "lobby" with your room name. The data will typically look like this:
{
  "room": {
    "key": "4261",
    "name": "lobby",
    "created": "1289487891",
    "data": {
      "motd": "This is the lobby where you can meet up and/or try out the dice rooms.",
      "motd_from": "udo"
    }
  },
  "items": [
    {
      "type": "txtmsg",
      "from": "Nanana",
      "text": "test",
      "key": "716707",
      "h_time": "2015-03-23 21:14 UTC",
      "time": "1427145274",
      "room_id": "4261"
    }
  ]
}
There are several kinds of messages, as indicated by the "type" field: txtmsg, dicemsg, timeinfo, and srvmsg. Numerical timestamps are given in Unix time, all times are UTC.

Dice Room Client API

Tools like Greasemonkey and Tampermonkey allow people to customize the functionality of their websites. The Rolz.org dice rooms have JavaScript hooks you can use for that purpose:
  • document.onMessage: by setting this variable to your own handler function you can listen in on all room messages that are coming from the server.
    Example: document.onMessage = function(msg) { console.log(msg) }
  • document.onMessageRender: If you define this you can modify the message HTML before it's put into the document. This is the place where you would insert link or image HTML. document.onMessageRender(html, msg) expects that you return the HTML should be rendered on the screen.
    Example: document.onMessageRender = function(html, msg) { return('!'+html); }
  • document.isActive: this is a variable you can read from your script to determine if the window or tab containing Rolz is currently active or in the background.

REST API

Access to the REST API is available via the base URL
https://rolz.org/api/?
To get back a roll result, just append the die code to the URL:
https://rolz.org/api/?6d6
This example gets you the result of 6D6 in an extended stringlist text format like this:
result=11
details= [ 1+1+2+3+1+3 ] 
code=6d6
illustration=<span class="dc_dice_a">6</span><span class="dc_dice_d">D6</span>
timestamp=1248210819
You can also choose from the available result formats explicitly:
https://rolz.org/api/?6d6.json
^ returns a JSON array containing the result (you probably want this one).
https://rolz.org/api/?6d6.txt
^ delivers in the extended text list format.
https://rolz.org/api/?6d6.simple
^ gets you just the result number.
https://rolz.org/api/?6d6.xml
^ returns an XML document containing the result.

Downloads

C# Dice Code Parser

A long time ago, I wrote a rudimentary C# Dice Code Parser class. You can download it here.