Skip to content

Latest commit

 

History

History
554 lines (366 loc) · 14.3 KB

tournament.md

File metadata and controls

554 lines (366 loc) · 14.3 KB

Tournament API documentation


/tournament

Create / retrieve tournament

Retrieve list of available public tournament

GET /tournament

Parameters

Query

name value type description type
page Integer the current page Optional
page-size Integer the number of items per page, defaults to 10, maximum 50 Optional
display-private none display private tournament Optional
display-completed none display completed tournament Optional

Responses

http code content-type response
200 application/json {"public-tournaments": [tournament1, ...]}
401 application/json {"errors":["AAA", ...]}

Create a new tournament

POST /tournament

Parameters

Body

  • Tournament name must be between 3 and 20 characters and can only contain alnum and space
  • Players must be between 2 and 16 (optional, default = 16 players)
  • Nickname for the tournament (optional)
  • A boolean that specifies if tournament is private
  • A password for the tournament (if is-private is true)
{
    "name": "World Championship",
    "max-players": 16,
    "is-private": true,
    "password": "Password1%"
    "nickname": "Player"
}

Responses

http code content-type response
201 application/json {"id": 1, "name": "Tournament", ...}
400 / 401 application/json {"errors": ["AAA", "BBB", "..."]}

Delete all tournaments created by the user (with status created)

DELETE /tournament

Parameters

None

Responses

http code content-type response
200 application/json {"message": "tournaments created by this user have been deleted"}
401 application/json {"errors": ["error message", ...]}

/tournament/self

Manage user's tournaments

Get your active tournaments

GET /tournament/self/ongoing

Parameters

None

Responses

http code content-type response
201 application/json {"nb_active_tournaments": 2, "active_tournaments": [...]}
400 / 401 application/json {"errors": ["AAA", "BBB", "..."]}

/tournament/{id}

Manage a tournament

Retrieve details of specific tournament

GET /tournament/{id}

Parameters

None

Responses

Body

{
      "id": 1,
      "name": "Tournament",
      "max-players": 16,
      "nb-players": 1,
      "players": [
         {
            "nickname": "Player",
            "user_id": 2
          }
      ],
      "is-private": true,
      "status": "created",
      "admin": "edelage",
http code content-type response
200 application/json {"id": 1, "name": "Tournament", ...}
404 application/json {"errors": ["error message", ...]}

Delete a tournament

DELETE /tournament/{id}

Parameters

None

Responses

http code content-type response
200 application/json {"message": "tournament successfully deleted"}
400 / 401 / 403 / 404 application/json {"errors": ["error message", ...]}

Update tournament settings

PATCH /tournament/{id}

Parameters

Body

  • Tournament name must be between 3 and 20 characters and can only contain alnum and space (optional)
  • Players must be between 2 and 16 (optional)
  • A boolean that specifies if tournament is private (optional)
  • A password for the tournament (optional)
{
  "name": "World Championship",
  "max-players": 16,
  "is-private": true,
  "password": "Password1%"
}

Responses

http code content-type response
200 application/json {"id": 1, "name": "Tournament", ...}
400 / 403 application/json {"errors": ["AAA", "BBB", "..."]}

Start a tournament

PATCH /tournament/{id}/start

Parameters

None

Responses

http code content-type response
200 application/json {"message": "..."}
400 application/json {"errors": ["AAA", "BBB", "..."]}

/tournament/{id}/players

Manage players of a tournament

Retrieve the list of players for a tournament

GET /tournament/{id}/players

Responses

Body

  {
      "max-players": 16,
      "players": [
          {
              "nickname": "Player",
              "user_id": 2
          }     
      ] 
  }
http code content-type response
200 application/json {"players": [{"nickname": "Player", ...}, ...]}
404 application/json {"errors": ["AAA", ...]}

Add a player to a specific tournament

POST /tournament/{id}/players

Parameters

Body

  • Nickname for the tournament
  • The tournament password (if tournament is private)
{
    "nickname": "Player"
}

Responses

http code content-type response
201 application/json {"id": 1, "nickname": "Player", "user_id": 2}
400 / 403 / 404 application/json {"errors": ["AAA", "BBB", "..."]}

Leave a tournament

DELETE /tournament/{id}/players

Request

None

Responses

http code content-type response
200 application/json {"players": [{"nickname": "Player", ...}, ...]}
404 application/json {"errors": ["AAA", ...]}

/tournament/player

Anonymizes a user's nicknames

POST /tournament/player/anonymize

Request

Body

  • The user id to anonymize
{
   "user_id": 1
}

Responses

http code content-type response
200 application/json {"message": "player successfully anonymized"}

/tournament/{tournament_id}/player/{user_id}

Kick a player from a tournament

DELETE /tournament/{tournament_id}/player/{user_id}

Request

None

Responses

http code content-type response
200 application/json {"message": "You kicked the player with id {user_id}"}
400 application/json {"errors": ["AAA", "BBB", "..."]}

/tournament/{id}/matches

Manage matches of a tournament

Retrieve the list of matches for a tournament

GET /tournament/{id}/matches

Parameters

None

Responses

Example:

{
 "nb-matches": 14,
  "matches": [
      {
          "id": 1,
          "status": "Finished",
          "player1": "Player1",
          "player2": "Player2",
          "player_1_score": 2,
          "player_2_score": 1,
          "winner": "Player1"
      },
      {
          ...
      }
]
}

Generate matches for a tournament

POST /tournament/{id}/matches/generate

Parameters

Body

  • Randomly generate matches (optional, default = false)
{
  "random": true
}

Responses

http code content-type response
200 application/json {"nb-matches": 14, "matches": [...]}
404 application/json {"errors": ["AAA", ...]}

/tournament/{id}/match

Manage match of a tournament

Retrieve details of a match

GET /tournament/{id}/match/{match-id}

Parameters

None

Responses

Example:

{
  "id": 1,
  "status": "Finished",
  "player1": "Player1",
  "player2": "Player2",
  "player_1_score": 2,
  "player_2_score": 1,
  "winner": "Player1"
}
http code content-type response
200 application/json {"id": 1, "status": "In-progress", ...}
404 application/json {"errors": ["AAA", ...]}

Start a match

POST /tournament/{id}/match/start

Parameters

Body

  • The first player (user_id)
  • The second player (user_id)
{
  "player1": 1,
  "player2": 2
}

Responses

http code content-type response
200 application/json {"id": 1, "status": "In-progress", ...}
400 application/json {"errors": ["AAA", "BBB", "..."]}

Add one point to a player

POST /tournament/{id}/match/add-point

Parameters

Body

  • The player to add a point (user_id)
{
  "player": 1
}

Responses

http code content-type response
200 application/json {"id": 1, "status": "In-progress", ...}
400 application/json {"errors": ["AAA", "BBB", "..."]}

End a match

POST /tournament/{id}/match/end

Parameters

Body

  • Winner of the match (user_id)
{
  "winner": 2
}

Responses

http code content-type response
200 application/json {"id": 1, "status": "Finished", ...}
400 application/json {"errors": ["AAA", "BBB", "..."]}

/tournament/delete-inactive/

Delete inactive tournaments

DELETE /tournament/delete-inactive/

Parameters

None

Responses

http code content-type response
200 application/json {'message': 'Tournament deleted'}
404 application/json {"errors": ["AAA", ...]}