Download OpenAPI specification:
This API describes the Dice Game API for the Full Fabric Frontend code interview.
The game is turn-based, strictly between two players. Players take turns attacking or defending against each-other by rolling dice; any damage dealt is decremented from the defending player's HP, until one of them reaches 0, at which point a winner is declared and the game ends.
The rules are as follows:
Below are the endpoints available to manage games, assign players, and take turns.
Returns a list of all games in descending order of creation. Includes the game's players in the response.
{- "games": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "dieSize": 1,
- "startingHP": 1,
- "startedAt": "2019-08-24T14:15:22Z",
- "winnerId": "32f1d3b9-72ed-4c11-984d-56d8283ae865",
- "players": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "hp": 0
}
]
}
]
}
Creates a new game with the default die size and starting HP, if these are not provided. A new Game has no players or turns, so these are not returned.
dieSize | integer [ 1 .. 100 ] |
startingHP | integer [ 1 .. 100 ] |
{- "dieSize": 6,
- "startingHP": 20
}
{- "game": {
- "id": "123e4567-e89b-12d3-a456-426614174000",
- "dieSize": 6,
- "startingHP": 20,
- "startedAt": null,
- "winnerId": null
}
}
Returns the details of a game, including the game's players and turns.
id required | string <uuid> |
{- "game": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "dieSize": 1,
- "startingHP": 1,
- "startedAt": "2019-08-24T14:15:22Z",
- "winnerId": "32f1d3b9-72ed-4c11-984d-56d8283ae865",
- "players": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "hp": 0
}
], - "turns": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "attackerId": "eb3989c0-d8d1-40b6-8326-11853d62ff39",
- "defenderId": "c838a1f4-6db9-4b2c-bdf3-867a98b38b2e",
- "attackRoll": 1,
- "defenseRoll": 1,
- "createdAt": "2019-08-24T14:15:22Z"
}
]
}
}
Joins a game as a player, if the game is not full. This creates a new Player instance for the caller, and returns its ID.
id required | string <uuid> |
playerName required | string The name of the player. |
{- "playerName": "string"
}
{- "game": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "dieSize": 1,
- "startingHP": 1,
- "startedAt": "2019-08-24T14:15:22Z",
- "winnerId": "32f1d3b9-72ed-4c11-984d-56d8283ae865",
- "players": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "hp": 0
}
], - "turns": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "attackerId": "eb3989c0-d8d1-40b6-8326-11853d62ff39",
- "defenderId": "c838a1f4-6db9-4b2c-bdf3-867a98b38b2e",
- "attackRoll": 1,
- "defenseRoll": 1,
- "createdAt": "2019-08-24T14:15:22Z"
}
]
}, - "playerId": "35184259-d156-4290-94ed-3a4b4f2c36f8"
}
Starts a game, selecting the attacker and defender at random. The game will have a startedAt
timestamp and a new Turn with the attacker and defender players.
id required | string <uuid> |
{- "game": {
- "id": "123e4567-e89b-12d3-a456-426614174000",
- "dieSize": 6,
- "startingHP": 20,
- "startedAt": "2025-05-30T12:00:00Z",
- "winnerId": null,
- "players": [
- {
- "id": "7720ce89-c6fc-4bd9-a970-73b903bf0316",
- "name": "Player 1",
- "hp": 20
}, - {
- "id": "c7e4f89a-c61d-4968-b4f2-4de9c8f340a4",
- "name": "Player 2",
- "hp": 20
}
], - "turns": [
- {
- "id": "ad4d88f5-9d8b-4f87-9686-8ea87e242259",
- "attackerId": "7720ce89-c6fc-4bd9-a970-73b903bf0316",
- "defenderId": "c7e4f89a-c61d-4968-b4f2-4de9c8f340a4",
- "attackRoll": null,
- "defenseRoll": null,
- "createdAt": "2025-05-30T12:00:00Z"
}
]
}
}
Rolls the die for the player, and returns the result.
If this is the last roll of the turn (both players have rolled), the game will be updated with the result of the damage dealt. If the defending player died, the winner will be declared in the Game object. Otherwise, a new Turn will be created with the attacker and defender roles switched.
id required | string <uuid> |
playerId required | string <uuid> |
{- "playerId": "35184259-d156-4290-94ed-3a4b4f2c36f8"
}
{- "roll": 1,
- "game": {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "dieSize": 1,
- "startingHP": 1,
- "startedAt": "2019-08-24T14:15:22Z",
- "winnerId": "32f1d3b9-72ed-4c11-984d-56d8283ae865",
- "players": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "name": "string",
- "hp": 0
}
], - "turns": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "attackerId": "eb3989c0-d8d1-40b6-8326-11853d62ff39",
- "defenderId": "c838a1f4-6db9-4b2c-bdf3-867a98b38b2e",
- "attackRoll": 1,
- "defenseRoll": 1,
- "createdAt": "2019-08-24T14:15:22Z"
}
]
}
}