Minesweeper
This is a description of the “Minesweeper Clone” API.
Game API¶
Resource¶
POST/games
Create a new game
- difficulty
number
(required) Example: 1Permitted values are:
-
0
(Easy - 8x8, 10 mines) -
1
(Intermediate - 16x16, 40 mines) -
2
(Expert - 24x24, 99 mines)
-
201
Headers
Content-Type: application/json
Body
{
"id": 1,
"board": [
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
],
"state": "new",
"mines": 10
}
Resource¶
GET/games/{id}
Retrieve an already created game.
The state
will be one of "new"
, "playing"
, "won"
, or "lost"
.
Cell values:
-
(empty space) An unrevealed cell
-
_
An empty revealed cell -
F
An unrevealed flagged cell -
*
A cell with a bomb in it (only show after a game is won or lost) -
@
A flagged cell with a bomb in it (only show after a game is won or lost) -
1
-8
The number of neighboring cells that contain a mine.
- id
number
(required) Example: 1The unique ID for the game
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"board": [
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
"1",
"2",
"1",
"F",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"2",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"1",
" ",
" "
],
[
" ",
" ",
"1",
"_",
"_",
"2",
" ",
" "
],
[
" ",
" ",
" ",
"1",
"1",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
],
"state": "new",
"mines": 9
}
Resource¶
POST/games/{id}/check
- id
number
(required) Example: 1The unique ID for the game
- row
number
(required) Example: 5The horizontal row the player is checking (zero based index).
- col
number
(required) Example: 7The vertical column the player is checking (zero based index).
Headers
Content-Type: application/json
Body
{
"row": 4,
"col": 3
}
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"board": [
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
"1",
"2",
"1",
"F",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"2",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"1",
" ",
" "
],
[
" ",
" ",
"1",
"_",
"_",
"2",
" ",
" "
],
[
" ",
" ",
" ",
"1",
"1",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
],
"state": "playing",
"mines": 9
}
Resource¶
POST/games/{id}/flag
- id
number
(required) Example: 1The unique ID for the game
- row
number
(required) Example: 5The horizontal row the player is flagging (zero based index).
- col
number
(required) Example: 5The vertical column the player is flagging (zero based index).
Headers
Content-Type: application/json
Body
{
"row": 5,
"col": 5
}
200
Headers
Content-Type: application/json
Body
{
"id": 1,
"board": [
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
"1",
"2",
"1",
"F",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"2",
" ",
" "
],
[
" ",
"1",
"_",
"_",
"_",
"1",
" ",
" "
],
[
" ",
" ",
"1",
"_",
"_",
"2",
" ",
" "
],
[
" ",
" ",
" ",
"1",
"1",
"F",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
[
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
],
"state": "playing",
"mines": 8
}