Skip to content

Latest commit

 

History

History
681 lines (512 loc) · 8.3 KB

API_Documentation.md

File metadata and controls

681 lines (512 loc) · 8.3 KB

This documentation is automatically generated.

Output schemas only represent data and not the full output; see output examples and the JSend specification.

/api/auth/login/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "username", 
        "password"
    ], 
    "type": "object", 
    "properties": {
        "username": {
            "type": "string"
        }, 
        "password": {
            "type": "string"
        }
    }
}

Output Schema

{
    "type": "object", 
    "properties": {
        "username": {
            "type": "string"
        }
    }
}

Notes

POST the required credentials to get back a cookie

  • username: Username
  • password: Password

GET

Input Schema

null

Output Schema

{
    "type": "string"
}

Notes

GET to check if authenticated.

Should be obvious from status code (403 vs. 200).



/api/auth/logout/?

Content-Type: application/json

DELETE

Input Schema

null

Output Schema

{
    "type": "string"
}

Notes

DELETE to clear cookie for current user.



/api/game/creategame/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "nbpp"
    ], 
    "type": "object", 
    "properties": {
        "nbpp": {
            "type": "number"
        }
    }
}

Output Schema

{
    "type": "object", 
    "properties": {
        "game_id": {
            "type": "string"
        }
    }
}

Notes

POST the required parameter to create a new game; only the owner of a room can make this request

  • nbpp: Number of balls per player


/api/game/endgame/?

Content-Type: application/json

DELETE

Input Schema

null

Output Schema

{
    "type": "string"
}

Output Example

"Game 12345678910 was completed; Guy was the winner."

Notes

DELETE to end the game; this endpoint should only be triggered if GameState indicates there is a winner.



/api/game/gamestate/?

Content-Type: application/json

GET

Input Schema

null

Output Schema

{
    "type": "object", 
    "properties": {
        "winner": {
            "type": [
                "string", 
                "null"
            ]
        }, 
        "balls_on_table": {
            "type": "array"
        }
    }
}

Output Example

{
    "winner": "Guy", 
    "balls_on_table": [
        2, 
        5, 
        9, 
        6
    ]
}

Notes

GET to receive state of current_game

winner: Potential winner of the game, or empty string balls_on_table: Array of balls still on the table



/api/game/leavegame/?

Content-Type: application/json

DELETE

Input Schema

null

Output Schema

{
    "required": [
        "game_id"
    ], 
    "type": "object", 
    "properties": {
        "game_id": {
            "type": "string"
        }
    }
}

Notes

DELETE to remove yourself from current game



/api/game/listplayers/?

Content-Type: application/json

GET

Input Schema

null

Output Schema

{
    "required": [
        "gamemaster", 
        "players"
    ], 
    "type": "object", 
    "properties": {
        "players": {
            "type": "array"
        }, 
        "gamemaster": {
            "type": [
                "string", 
                "null"
            ]
        }
    }
}

Output Example

{
    "players": [
        "Stark", 
        "Stannis", 
        "Baratheon", 
        "Tyrell", 
        "Lannister"
    ], 
    "gamemaster": "Stark"
}

Notes

GET to receive list of players in current game

  • players array includes ALL players (including gamemaster)
  • gamemaster field is useful for highlighting the gamemaster in the UI


/api/game/toggleball/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "ball"
    ], 
    "type": "object", 
    "properties": {
        "ball": {
            "type": "number"
        }
    }
}

Output Schema

{
    "required": [
        "game_id"
    ], 
    "type": "object", 
    "properties": {
        "game_id": {
            "type": "string"
        }, 
        "message": {
            "type": "string"
        }
    }
}

Notes

POST the required parameters to register the pocketing/unpocketing of a ball

  • ball: The ball that was pocketed/unpocketed


/api/player/player/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "username", 
        "password"
    ], 
    "type": "object", 
    "properties": {
        "username": {
            "type": "string"
        }, 
        "password": {
            "type": "string"
        }
    }
}

Output Schema

{
    "type": "object", 
    "properties": {
        "username": {
            "type": "string"
        }
    }
}

Notes

POST the required parameters to permanently register a new player

  • username: Username of the player
  • password: Password for future logins

GET

Input Schema

null

Output Schema

{
    "type": "object", 
    "properties": {
        "current_room": {
            "type": "string"
        }, 
        "orig_balls": {
            "type": "array"
        }, 
        "current_game_id": {
            "type": "string"
        }, 
        "name": {
            "type": "string"
        }, 
        "balls": {
            "type": "array"
        }
    }
}

Notes

GET to retrieve player info



/api/room/createroom/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "roomname"
    ], 
    "type": "object", 
    "properties": {
        "roomname": {
            "type": "string"
        }, 
        "password": {
            "type": "string"
        }
    }
}

Output Schema

{
    "type": "object", 
    "properties": {
        "roomname": {
            "type": "string"
        }
    }
}

Notes

POST the required parameters to create a new room

  • name: Name of the room
  • password: (Optional) Password to the room if you wish to keep entry restricted to players who know the password


/api/room/joinroom/?

Content-Type: application/json

POST

Input Schema

{
    "required": [
        "name"
    ], 
    "type": "object", 
    "properties": {
        "password": {
            "type": "string"
        }, 
        "name": {
            "type": "string"
        }
    }
}

Output Schema

{
    "type": "object", 
    "properties": {
        "name": {
            "type": "string"
        }
    }
}

Notes

POST the required parameters to create a new room

  • name: Name of the room
  • password: (Optional) Password to the room if it has one


/api/room/leaveroom/?

Content-Type: application/json

DELETE

Input Schema

null

Output Schema

{
    "type": "string"
}

Notes

DELETE to leave current room. If the room owner leaves, the room will be deleted.



/api/room/listplayers/?

Content-Type: application/json

GET

Input Schema

null

Output Schema

{
    "required": [
        "owner", 
        "players"
    ], 
    "type": "object", 
    "properties": {
        "owner": {
            "type": "string"
        }, 
        "players": {
            "type": "array"
        }
    }
}

Output Example

{
    "owner": "Stark", 
    "players": [
        "Stark", 
        "Stannis", 
        "Baratheon", 
        "Tyrell", 
        "Lannister"
    ]
}

Notes

GET to receive list of players in current room

  • players array includes ALL players (including owner)
  • owner field is useful for highlighting the room owner in the UI


/api/room/listrooms/?

Content-Type: application/json

GET

Input Schema

null

Output Schema

{
    "type": "array"
}

Output Example

[
    {
        "pwd_req": true, 
        "name": "Curve"
    }, 
    {
        "pwd_req": false, 
        "name": "Cue"
    }
]

Notes

GET to receive list of rooms