Author

Karol

Dice Api

Because sometimes life needs a little more randomness 🎲😄

April 26, 2025

Image

📜 Description

Roll the dice — and let the backend do the magic!
The Dice API simulates rolling a dice (or multiple dice) and returns random results.
You can customize the number of dice and sides for each roll!

Simple, fun, and a perfect first step into API development.


📚 Requirements

  • Build an API endpoint (e.g., /api/v1/dice) that returns random dice rolls.
  • Support optional query parameters:
    • sides — number of sides per die (default: 6)
    • dice — number of dice to roll (default: 1)

🛠️ Example Usage

Request

GET /api/v1/dice

or with parameters:

GET /api/v1/dice?sides=20&dice=3

Response

{
  "sides": 20,
  "dice": 3,
  "results": [7, 13, 2]
}

🎯 Rules

  • If no parameters are passed, roll one 6-sided dice by default.
  • Limit sides and dice to a reasonable max (e.g., no more than 100).
  • Results must be random on every request.

Live Preview:

Login to see content