Skip to content

Latest commit

 

History

History
250 lines (192 loc) · 3.13 KB

API.md

File metadata and controls

250 lines (192 loc) · 3.13 KB

Game API

Create user

Request

// POST /api/users/
{
  "username": string,
  "password": string,
}

Response

{
  "id": int,
  ...
}

Authenticate

Request

// POST /api-token-auth/`
{
  "username": string,
  "password": string,
}

Response

On success:

{
  "id": int,
  "token": string,
  "image": string, // relative path from web server to image url
}

If a user with that username doesn't exist, the response is 404 Not Found.

If a user with that username exists, but the password was wrong, the response is 400 Bad Request.

Start game

Request

// POST /api/games/
{
  "tokens": string[],
}

Response

{
  "id": int,
  "token": string,
  "shuffle_indices": int[],
  "start_datetime": datetime_string,
  ...
}

Update game

Request

// POST /api/games/<game_id>/update_state/
// Authorization: GameToken <game_token>
{
  "official": bool,
  "cards": card[], // see below
  "has_ended": bool,
  "description": string, // only at end of game
  "dnf": bool,
}

card type definition:

{
  "value": int,
  "suit": string,
  "start_delta_ms": int,

  // Should only be given if value == 14 and
  // player has started chugging:
  "chug_start_start_delta_ms": int,

  // Should only be given if value == 14 and
  // player has finished chugging:
  "chug_end_start_delta_ms": int,
}

Response

{
}

Resumable games

Request

// GET /api/games/resumable/
// Authorization: Token <user_token>
{
}

Response

[{
  "id": int,
  "players": [{
    "id": int,
    "username": string,
    ...
  },
  ...,
},
...
]

Resume game

Request

// POST /api/games/<game_id>/resume/
// Authorization: Token <user_token>
{
}

Response

{
  "token": string,
  ...
}

## Update game image

### Request

// POST /api/games/<game_id>/update_image/ // Authorization: GameToken <game_token> // multipart/form-data with image field containing image


### Response
```javascript
{}

Delete game image

Request

// POST /api/games/<game_id>/delete_image/
// Authorization: GameToken <game_token>

Response

{
}

Get list of ranked users for face cards

Request

// GET /api/ranked_cards/
{
}

Response

{
  "{suit}-{value}": { // example: S-12
    "user_id": int,
    "user_username": string,
    "user_image": string,
    "ranking_name": string,
    "ranking_value": string,
  },
}

Player stats

Get stats for a user

Request

// GET /api/stats/<user_id>/
{
}

Response

[
    {
        "season_number": int,
        "total_games": int,
        "total_time_played_seconds": float,
        "total_sips": int,
        "best_game": int,
        "worst_game": int,
        "best_game_sips": int?,
        "worst_game_sips": int?,
        "total_chugs": int,
        "fastest_chug": int?,
        "fastest_chug_duration_ms": int?,
        "average_chug_time_seconds": float?,
    },
    ...
]