Dice rolling API for your programs

Use the Dice Roll API for your computer and development programs.

The API allows you to roll the dice and get results in JSON.

How to use the dice roll API?

To use the API, nothing could be simpler: you just need to make a call to the API in GET as shown below.

API call: https://www.dejete.com/api?nbde=5&tpde=6

The first parameter "nbde" represents the number of dice you want to roll. The second parameter represents the number of sides you want for your dice. In the example above, we therefore roll 5 6-sided dice.

Retrieving random results

When you call the API in GET, you will get a JSON string. You just have to decode it and integrate it into your scripts or programs.

Below find an example of integration in PHP:

<?php
     $resultat = file_get_contents('https://www.dejete.com/api?nbde=5&tpde=6');
     $json = json_decode($resultat);
     foreach($json as $de)
     {
          echo $de->id.' : '.$de->value.'<br>';
     }
?>

You can therefore retrieve your results with the JSON fields "id" and "value". "id" being the number of the rolled die and "value" being the randomly generated value.