NAV Navbar
  • Introduction
  • API responses
  • Date format
  • Authentication
  • Common endpoints
  • API models
  • /v1/account
  • /v1/matches
  • /v1/parties
  • /v1/users
  • /v1/admin
  • Introduction

    Welcome to the League of Code API!

    This is the official specification of the online hackathon platform designed by GUL-UC3M.

    API responses

    Each API endpoint follows the JSend specification, released under a modified BSD License.

    Date format

    When sending or receiving dates from the server, note that these are stored as UTC timestamps, therefore it is up to the client to parse these dates accordingly.

    Authentication

    Authentication in the League of Code API is performed by means of JSON Web Tokens. For each authenticated endpoint, a token parameter containing the current JWT must be included in the request JSON. This token can be obtained from the /v1/account/login endpoint.

    Token missing from request [401]:

    {
        "status": "fail",
        "data": {
            "token": "Request was missing the 'token' attribute "
        }
    }
    

    Token expired [401]:

    {
        "status": "error",
        "message": "JWT was expired"
    }
    

    Token (de)coding error [500]:

    {
        "status": "error",
        "message": "JWT coding error"
    }
    

    For each authenticated endpoint, the server may reply with a 401 code if the JWT sent is not valid or a 500 code if there were coding errors while (de)coding de token.

    Common endpoints

    The following endpoints are common and independent of the API version used.

    Obtain server information

    Get certain details from the server. This includes the following:

    HTTP Request

    GET /info

    HTTP Response

    Example response:

    {
        "api": [
            "v1"
        ],
        "description": "Reference LoC server implementation",
        "version": "0.1.0"
    }
    
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Returns server information

    API models

    The relations of the database models can be seen in the next image:

    Database relations

    User

    User accounts in the platform (including administrator ones).

    Note that session management is performed by means of a JWT token obtained through the api/v1/users/login endpoint.

    User roles are registered in the user_roles relationship, and are checked on certain operations.

    Users can follow other users. Followers can see matches in which other users have participated. This is done through the followers relation (Follower model).

    Attributes

    Attribute Type Description
    id integer (Primary key) Unique ID of the user
    username string Unique username of the user
    name string (Optional) Real name of the user
    email string Unique email of the user, necessary for any communication (e.g. restoring a password)
    password string Hashed password
    points integer Total score obtained by participating in matches
    password_reset_token integer Generated on demand. This token is used to restore the password. It must be unique and 32 characters long
    token_expiration date Date(time) in which the password_reset_token expires and a new one has to be generated
    is_deleted boolean Flag indicating soft delete
    delete_date date Date in which the user was (soft) deleted

    Role

    Roles of the system.

    The roles assigned to each user are checked when performing operations such as administration tasks.

    Note that User-Role relations are stored in the user_roles relationship.

    Attributes

    Attribute Type Description
    id integer (Primary key) Unique ID of the role
    name string Unique descriptive name of the role

    Follower

    Users can follow other users, and this act is recorded in the followers table, which also contains a date(time) of when the follower started following the followee.

    Attributes

    Attribute Type Description
    follower_id integer (Primary key) Unique ID of the follower
    followee_id integer (Primary key) Unique ID of the followee
    follow_date date Date(time) in which the follower started following the followee

    Match

    Matches are programming contests created by the administrators of the platform. Each match has three main periods:

    Attribute Type Description
    id integer (Primary key) Unique ID of the match
    title string Title of the match
    short_description string Short description of the match. Ideally, it should be used to show very little information on the match as to not provide any sort of advantage to the participants until the match begins
    long_description string Long description of the match. As opposed to short_description, this one should contain the topic ofthe match and any additional details such as rules (e.g. use a specific technology or language). Should only be shown when the match starts
    start_date date Date(time) in which the match starts (long_description is visible, no more parties can be formed or participate, and submissions are accepted)
    end_date date Date(time) in which the match ends (no more submissions are accepted)
    min_members integer Minimum number of participants in a party
    max_members integer Maximum number of participants in a party
    leaderboard list[integer] Ordered list of parties taking into account their position after finishing the match
    slug string Unique slug created from the tittle of the match (useful for pretty URLs)
    is_visible boolean Whether the match has been published or not
    is_deleted boolean Flag indicating soft delete
    delete_date date Date in which the match was (soft) deleted

    MatchParticipant

    Match participants and parties are represented with through this model.

    Several things to consider:

    Attributes

    Attribute Type Description
    user_id integer (Primary key) User ID [Foreign key]
    match_id integer (Primary key) Match ID [Foreign key]
    party_owner_id integer ID of the owner of the party the user is currently in [Foreign key]

    Party

    Party marks. Contain tokens that are used to join a party.

    These tokens are created on demand when the user signs up for a match and is the owner of the party they are currently in. The token is deleted when the user joins a different party.

    Attributes

    Attribute Type Description
    owner_id integer (Primary key) Owner ID [Foreign key]
    match_id integer (Primary key) Match ID [Foreign key]
    token string Unique 32-character random token
    is_public boolean Flag used to specify whether the party can be found through the Looking For Group section. If this value is False (default), the owner
    must provide the link to join the party manually
    is_participating boolean Flag that is set when the match begins indicating whether the party is participating in the match (e.g. the party has the required number of members)

    Submission

    Submissions are the resulting projects created by the participants at the end of a match.

    Each party has one submission per match, which is created automatically when the match starts, and can only be edited by the party leader.

    Submissions can be edited until the match is closed.

    Attributes

    Attribute Type Description
    id integer (Primary key) Unique ID of the submission
    title string Short title of the project
    description string Long description of the project
    url string URL from which the project can be downloaded
    match_id integer ID of the match [Foreign key]
    party_owner_id integer ID of the leader/owner of the party (used to identify the party) [Foreign key]

    /v1/account

    The account endpoint implements functionalities related to the management of a user's own account.

    Signup

    Create a new user record in the server.

    HTTP Request

    POST /v1/account/signup

    Example request:

    {
        "username": "test_user",
        "email": "my_email@example.com",
        "password": "mypassword"
    }
    

    Parameters

    Parameter Type Description
    username string Unique username for the new user
    email string Unique email for the new user
    password string Password for the new user (will be stored encrypted)

    HTTP Response

    Example response [201]:

    {
        "status": "success",
        "data": {
            "username": "test_user"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "password": "Field was missing in request"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": "A user with the specified details already exists"
    }
    

    Example response [500]:

    {
        "status": "error",
        "message": "Error creating record"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    201 User is created correctly, returns newly created user's username
    400 Some parameters are missing (indicated in response)
    409 User with the specified username/email already exists, returns error message
    500 Server error

    Login

    Login using the provided username and password in order to obtain a JSON Web Token (necessary for most endpoints).

    HTTP Request

    POST /v1/account/login

    Example request:

    {
        "username": "test_user",
        "password": "mypassword"
        "remember-me": false
    }
    

    Parameters

    Parameter Type Description
    username string Username to use for login
    password string Password to use for login
    remember-me string Whether the session should remain active or expire

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "token": "JWT_TOKEN"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "password": "Field was missing in request"
        }
    }
    

    Example response [401]:

    {
        "status": "fail",
        "data": {
            "username": "Check field for errors",
            "password": "Check field for errors"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Credentials are valid, returns JWT
    400 Some parameters are missing (indicated in response)
    401 Credentials are not valid

    Logout

    TODO

    HTTP Request

    GET /v1/account/logout

    Get own profile

    Obtain the profile of the currently logged in user.

    HTTP Request

    GET /v1/account/profile

    Example request:

    {
        "token": "JWT_TOKEN",
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "username": "currentuser",
            "name": "Current user",
            "points": 42
        }
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Profile was found, returns shown user attributes
    404 Profile was not found (or removed)

    Update own profile

    Update profile details of the currently logged in user.

    HTTP Request

    PUT /v1/account/profile

    Example request:

    {
        "token": "JWT_TOKEN",
        "name": "New User McUser",
        "email": "newmail@example.com"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    name string New real name to show (optional)
    email string New email to use for communication with the user (required)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "name": "New User McUser"
            "email": "newmail@example.com"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "email": "Invalid email"
        }
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    Example response [500]:

    {
        "status": "error",
        "message": "Error updating record"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Profile was found, returns new details
    400 Email format was not valid
    404 Profile was not found (or removed)
    500 Server error

    Get followers

    Get users that follow the currently logged in user.

    HTTP Request

    GET /v1/account/followers

    Example request:

    {
        "token": "JWT_TOKEN",
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": [
            "friend_a",
            "friend_b",
        ]
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Logged in, returns list of followers
    401 Not logged in
    404 Profile was not found (or removed)

    Get users followed

    Get users followed by the currently logged in user.

    HTTP Request

    GET /v1/account/following

    Example request:

    {
        "token": "JWT_TOKEN",
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": [
            "friend_a",
            "friend_b",
        ]
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Logged in, returns list of followees
    401 Not logged in
    404 Profile was not found (or removed)

    Change password

    Change current password (only when the user is logged in).

    HTTP Request

    POST /v1/account/change-password

    Example request:

    {
        "token": "JWT_TOKEN",
        "current-password": "mycurrent_password",
        "new-password": "mynew_password"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    current-password string Currently set password
    new-password string New password to set

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "current-password": "Field was missing in request"
            "new-password": "Password not complex enough"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "Invalid password"
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Password changed
    400 Some parameters are missing or incomplete (indicated in response)
    401 Not logged in
    403 Current password was incorrect
    404 Profile was not found (or removed)

    Forgot password

    Generate a password reset token.

    Note that the endpoint will not specify whether the email address is valid and belongs to a user account.

    HTTP Request

    POST /v1/account/forgot-password

    Example request:

    {
        "email": "myemail@example.com"
    }
    

    Parameters

    Parameter Type Description
    email string Email of the account

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null 
    }
    

    Example response [400]:

    {
        "status": "success",
        "data": {
            "email": "Field was missing"
        } 
    }
    

    Example response [500]:

    {
        "status": "error",
        "message": "Server error"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Password reset token generated (if the email exists)
    400 Email field was missing
    500 Server error

    Validate reset password token

    Validate the token generated in /v1/account/forgot-password.

    If this token is valid, then it is possible to make a POST request with the new password.

    HTTP Request

    GET /v1/account/reset-password

    Example request:

    {
        "token": "PASSWORD_RESET_TOKEN"
    }
    

    Parameters

    Parameter Type Description
    token string Reset password token

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null 
    }
    

    Example response[404]:

    {
        "status": "error",
        "message": "Invalid token"
    }
    

    Example response [500]:

    {
        "status": "error",
        "message": "Server error"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Reset token exists
    404 Reset token was not found
    500 Server error

    Reset password

    Reset password.

    While it is possible to skip checking whether the token from v1/account/forgot-password is valid (by performing a GET request to this endpoint), it is not recommended.

    HTTP Request

    POST /v1/account/reset-password

    Example request:

    {
        "token": "PASSWORD_RESET_TOKEN"
        "password": "myresetpassword",
        "confirm-password": "myresetpassword"
    }
    

    Parameters

    Parameter Type Description
    token string Password reset token
    password string New password
    confirm-password string Password confirmation

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null 
    }
    

    Example response [400]:

        "status": "fail",
        "data": {
            "password": "Not complex enough",
            "confirm-password": "Passwords do not match"
        }
    

    Example response[404]:

    {
        "status": "error",
        "message": "Invalid token"
    }
    

    Example response [500]:

    {
        "status": "error",
        "message": "Server error"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Password has been changed
    400 Password was not complex enough or the confirmation did not match
    404 Reset token was not found
    500 Server error

    /v1/matches

    The matches endpoint implements functionalities related to code matches.

    List current matches

    Obtain a list of matches that are currently taking place or will take place in the future.

    This does not include invisible or deleted matches.

    HTTP Request

    GET /v1/matches/list

    Example request:

    {
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "title": "Test match",
                    "start-date": "2017-01-01 00:00",
                    "end-date": "2017-01-05 00:00",
                    "slug": "test-match"
                },
                {
                    "title": "Super awesome match 9000",
                    "start-date": "2017-02-01 00:00",
                    "end-date": "2017-02-05 00:00",
                    "slug": "super-awesome-match-9000"
                }
            ] 
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of matches (list may be empty if no match is found)

    List past matches

    Obtain a list of matches that have already taken place.

    This does not include invisible or deleted matches.

    HTTP Request

    GET /v1/matches/list-past

    Example request:

    {
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                {
                    "title": "Old McOld Match",
                    "start-date": "2015-01-01 00:00",
                    "end-date": "2015-01-05 00:00",
                    "slug": "old-mcold-match"
                },
                {
                    "title": "Super awesome match 8000",
                    "start-date": "2016-02-01 00:00",
                    "end-date": "2016-02-05 00:00",
                    "slug": "super-awesome-match-8000"
                }
            ] 
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of matches (list may be empty if no match is found)

    Get details of a given match

    Obtain details for the specified match (current or old).

    Depending on the starting date of the match, the server may not include the long description of the match if it has not yet started.

    HTTP Request

    GET /v1/matches/info

    {
        "match": "test-match"
    }
    

    Parameters

    Parameter Type Description
    match string Unique slug of the match to get info from

    HTTP Response

    Example response with a match that has started (or happened in the past) [200]:

    {
        "status": "success",
        "data": {
            "title": "Present match",
            "short-description": "Prepare for the future",
            "long-description": "This is a long description of the match"
            "start-date": "2017-01-01 00:00",
            "end-date": "2017-01-05 00:00",
            "min-members": 1,
            "max-members": 2,
            "slug": "present-match"
        }
    }
    

    Example response with a match that has not started [200]:

    {
        "status": "success",
        "data": {
            "title": "Future match",
            "short-description": "Prepare for the future",
            "start-date": "2019-01-01 00:00",
            "end-date": "2019-01-05 00:00",
            "min-members": 1,
            "max-members": 4,
            "slug": "future-match"
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Could not find match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Match exists, returns match details
    404 Match does not exist, is not visible or was deleted

    Get match leaderboard

    Obtain the leaderboard for a given match. This is only possible once the match has finished.

    The leaderboard consists of an ordered list of the participating parties, according to the score they have obtained in the match.

    HTTP Request

    GET /v1/matches/leaderboard

    Example request:

    {
        "match": "test-match",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    match string Unique slug of the match to get the leaderboard for
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "leader": "user32",
                    "members": ["user32", "userc"],
                    "position": 1
                },
                {
                    "leader": "userc",
                    "members": ["userc"],
                    "position": 2
                }
            ] 
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Ordered party list including the position of the party (list may be empty if the match has not finished)

    Join a match

    By joining a match, a MatchParticipant record is created for the user in the specified match. By default, the user will be in their own party, therefore the party_owner_id will be the user ID.

    In addition, a Party is also created. The party token can be used to invite other users to your own party. It is deleted once the user joins a party owned by another user.

    HTTP Request

    POST /v1/match/join

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to get info from

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "party-token": "123456789abcdefgh"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "Match slug missing"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "Match has already started"
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "match": "You are already participating in the match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User joined the match, returns party token
    400 Some parameters are missing or incomplete (indicated in response)
    401 Not logged in
    403 Match has already started
    404 Match was not found (or is invisible or removed)
    409 The user already joined the match in the past

    Leave a match

    Leave a match before it begins. This implies that the user will automatically leave any party they are in and their MatchParticipant record will be deleted.

    A party leader cannot leave until the party is empty.

    HTTP Request

    POST /v1/match/leave

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to get info from

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null 
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "Match slug missing"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "The party is not empty"
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "match": "You were not participating in the match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User left the match (and any party they were in)
    400 Some parameters are missing or incomplete (indicated in response)
    401 Not logged in
    403 The party is not empty
    404 Match was not found (or is invisible or removed)
    409 The user already left the match in the past

    List participating parties

    Obtain a list of parties participating in the specified match.

    This list is only accessible once the match has started (or finished) and all participating parties have been formed.

    HTTP Request

    GET /v1/matches/participants

    Example request:

    {
        "match": "test-match"
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    match string Unique slug of the match
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                {
                    "leader": "user1",
                    "members": ["user1", "user2", "user3", "user4"]
                },
                {
                    "leader": "user8",
                    "members": ["user8", "user9", "user11", "user24"]
                }
            ] 
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of participating parties (list may contain only one user if it is an individual party)
    404 Match was not found (or is invisible or removed)

    List parties looking for more members

    Obtain a list of parties looking for more members through the Looking For Group functionality.

    HTTP Request

    GET /v1/matches/lfg

    Example request:

    {
        "match": "test-match"
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    match string Unique slug of the match
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                {
                    "leader": "user16",
                    "members": ["user16"],
                    "party-token": "12345678"
                },
                {
                    "leader": "user48",
                    "members": ["user45", "user91"],
                    "party-token": "abcdefgh"
                }
            ] 
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of parties looking for more members
    404 Match was not found (or is invisible or removed)

    Get submission details

    Get a party's submission for the given match. This action can only be performed by any member of the party during the match and by anyone once the match is over (for historic purposes).

    HTTP Request

    GET /v1/matches/submission

    Example request during a match:

    {
        "token": "JWT_TOKEN",
        "match": "test-match"
    }
    

    Example request during a match:

    {
        "match": "test-match"
        "party": "test1"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match
    party string (Optional) username of the leader of the party

    Note: the JWT can be omitted if accessing submissions after the match, and the party parameter can be skipped if requesting the user's own party submission (both during and after the match), but it is necessary to access submissions from other parties after the match.

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "title": "Super submission 9000",
            "description": "This is an awesome submission that simply works",
            "url": "https://github.com/guluc3m"
        }
    }
    

    Example response (missing match) [403]:

    {
        "status": "fail",
        "data": {
            "match": "Match not finished"
        }
    }
    

    Example response (missing party) [404]:

    {
        "status": "fail",
        "data": {
            "party": "Party not found for the specified match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Party submission details
    403 Match not started/finished
    404 Match or party were not found (or invisible or removed)

    Edit submission

    Edit a party's submission for the given match. This action can only be performed by the party leader, which is the owner of the party in the case of teams and the user in the case of individual matches.

    The submission can only be edited until the closing date of the match.

    HTTP Request

    PUT /v1/matches/submission

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match",
        "title": "New title",
        "description": "New description",
        "url": "New URL"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match
    title string New title for the submission
    description string New description for the submission
    url string New URL for the submission

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "title": "New title",
            "description": "New description",
            "url": "New URL"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are not the party leader for this match"
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 New submission details
    401 User not logged in
    403 The user is not the party leader and cannot change the submission or the match has finished
    404 Match was not found (or is invisible or removed)

    /v1/parties

    The parties endpoint implements functionalities related to match parties.

    Join a party

    Join a party by using the invite token provided by the party leader, or found through LFG if the party is public.

    By joining a party, the Party record created for the user (technically in their own party) is deleted, and the party_owner_id of the MatchParticipant record is set to the ID of the leader of the new party.

    HTTP Request

    POST /v1/parties/join

    Example request:

    {
        "token": "JWT_TOKEN",
        "party": "123456789abcdefgh"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    party string Unique party token

    HTTP Response

    Example response [201]:

    {
        "status": "success",
        "data": {
            "members": ["usera", "userb", "userc"]
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "party": "The party cannot accept any more members"
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "party": "Party not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "party": "The party is full"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    201 Joined the party, returns names of party members
    400 Trying to join a party from a past match (or a running match)
    404 Party was not found (or invisible or removed)
    409 Party is full or already in a party

    Note that a party is full when it has a number of members equal to the max_members attribute of the match.

    Leave a party

    Leave a party. This can only be performed by non-leader members of the party and before the match starts.

    When the user leaves a party, a new Party record is created to indicate that they are in their own party, and the party_owner_id in their MatchParticipant record is set to their own ID.

    HTTP Request

    POST /v1/parties/leave

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match the party is participating in

    HTTP Response

    Example response [201]:

    {
        "status": "success",
        "data": {
            "party-token": "asdfghjkl12345"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "The match has already started"
        }
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are the leader of the party and cannot leave it"
        }
    }
    

    Example response (match not found) [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match was not found"
        }
    }
    

    Example response (not participating) [404]:

    {
        "status": "fail",
        "data": {
            "match": "You are not participating in this match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    201 Left the party, returns new party token
    400 Trying to leave a party from a past match (or a running match)
    403 Trying to leave a party while being the leader
    404 Match was not found or user not participating

    Kick member from party

    Kick another member from a party.

    By kicking them, a Party record is created for the kicked member (as they are now considered to be in their own party), and the party_owner_id attribute in their MatchParticipant record is set to their own ID.

    HTTP Request

    POST /v1/parties/kick

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match",
        "user": "member1"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match the party is participating in
    user string Username of the user to kick

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "members": ["member2", "userb"]
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "The match has already started"
        }
    }
    

    Example response (kicking oneself) [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are the leader of the party and cannot kick yourself"
        }
    }
    

    Example response (not leader) [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are not the leader of the party"
        }
    }
    

    Example response (match not found) [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match was not found"
        }
    }
    

    Example response (not participating) [404]:

    {
        "status": "fail",
        "data": {
            "match": "You are not participating in this match"
        }
    }
    

    Example response (not in party) [404]:

    {
        "status": "fail",
        "data": {
            "user": "User could not be found in your party"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Kicked member from party, returns list of current members
    400 Trying to kick from a party from a past match (or a running match)
    403 Trying to kick while not being the leader or trying to kick oneself
    404 Match was not found or user not participating, or user not in party

    Disband party

    Kicks all members of the party and generates a new token for the party leader, effectively removing the party and the invite token. The visibility of the party is set to private so it cannot be found through LFG.

    HTTP Request

    POST /v1/parties/disband

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match",
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match the party is participating in

    HTTP Response

    Example response [201]:

    {
        "status": "success",
        "data": {
            "party-token": "zxcvbnmqwerty"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "The match has already started"
        }
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are not the leader of the party"
        }
    }
    

    Example response (match not found) [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match was not found"
        }
    }
    

    Example response (not participating) [404]:

    {
        "status": "fail",
        "data": {
            "match": "You are not participating in this match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Kicked member from party, returns list of current members
    400 Trying to disband a party from a past match (or a running match)
    403 Trying to disband while not being the leader
    404 Match was not found or user not participating

    Set visibility of party in LFG

    Change the visibility of the party in the LFG section. If set to false the party will not appear in the LFG list.

    HTTP Request

    POST /v1/parties/lfg

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match",
        "lfg": true
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string The match the party is participating in
    lfg boolean Whether the party should appear in the LFG list

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "lfg": true
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "match": "The match has already started"
        }
    }
    

    Example response [403]:

    {
        "status": "fail",
        "data": {
            "match": "You are not the leader of the party"
        }
    }
    

    Example response (match not found) [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match was not found"
        }
    }
    

    Example response (not participating) [404]:

    {
        "status": "fail",
        "data": {
            "match": "You are not participating in this match"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Returns new LFG setting
    400 Trying to change the LFG setting for a party from a past match (or a running match)
    403 Trying to change LFG setting while not being the leader
    404 Match was not found or user not participating

    List parties the user is currently in

    Obtain a list of parties the user is currently a member of (for running or future matches). Does not include invisible or deleted matches.

    HTTP Request

    GET /v1/parties/list

    Example request:

    {
        "token": "JWT_TOKEN",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                {
                    "match": {
                        "title": "Test match",
                        "start-date": "2017-01-01 00:00",
                        "end-date": "2017-01-05 00:00",
                        "slug": "test-match"
                    },
                    "party": {
                        "leader": "user32",
                        "members": ["user32", "userc"],
                        "party-token": "asdfghjklqwerty"
                    }
                },
                {
                    "match": {
                        "title": "Super match",
                        "start-date": "2018-01-01 00:00",
                        "end-date": "2018-01-05 00:00",
                        "slug": "super-match"
                    },
                    "party": {
                        "leader": "userc",
                        "members": ["userc"],
                        "party-token": "1234567890asdfghjkl"
                    }
                }
            ] 
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of parties
    401 Not logged in
    404 Profile was not found (or removed)

    List parties the user has been in

    Obtain a list of parties the user has been a member of. Does not include invisible or deleted matches.

    HTTP Request

    GET /v1/parties/list-past

    Example request:

    {
        "token": "JWT_TOKEN",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 2,
            "list": [
                {
                    "match": {
                        "title": "Past match",
                        "start-date": "2016-01-01 00:00",
                        "end-date": "2016-01-05 00:00",
                        "slug": "past-match"
                    },
                    "party": {
                        "leader": "user32",
                        "members": ["user32", "userc"],
                        "party-token": "asdfghjklqwerty"
                    }
                },
                {
                    "match": {
                        "title": "Super match 7000",
                        "start-date": "2015-01-01 00:00",
                        "end-date": "2015-01-05 00:00",
                        "slug": "super-match-7000"
                    },
                    "party": {
                        "leader": "userc",
                        "members": ["userc"],
                        "party-token": "1234567890asdfghjkl"
                    }
                }
            ] 
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [404]:

    {
        "status": "error",
        "message": "User was not found"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of parties
    401 Not logged in
    404 Profile was not found (or removed)

    /v1/users

    The users endpoint implements functionalities related to users and profiles.

    Get user details

    Obtain the profile of the specified user

    HTTP Request

    GET /v1/users/profile

    Example request:

    {
        "user": "user32"
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to obtain information about

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "username": "currentuser",
            "name": "Current user",
            "points": 42
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Profile was found, returns shown user attributes
    404 Profile was not found (or removed)

    Get followers

    Get users that follow the specified user.

    HTTP Request

    GET /v1/users/followers

    Example request:

    {
        "user": "user32"
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to obtain information about

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": [
            "friend_a",
            "friend_b",
        ]
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User found, returns list of followers
    404 Profile was not found (or removed)

    Get users followed

    Get users followed by the specified user.

    HTTP Request

    GET /v1/users/following

    Example request:

    {
        "user": "user32"
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to obtain information about

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": [
            "friend_a",
            "friend_b",
        ]
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User found, returns list of followees
    404 Profile was not found (or removed)

    Follow/unfollow user

    Follow or unfollow the specified user.

    HTTP Request

    POST /v1/users/follow

    Example request:

    {
        "token": "JWT_TOKEN",
        "user": "user31",
        "follow": false
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to follow/unfollow
    token string JSON Web Token (obtained from /v1/account/login)
    follow boolean Whether to start or stop following the user

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": null
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    Example response (already following) [409]:

    {
        "status": "fail",
        "data": {
            "user": "You are already following that user"
        }
    }
    

    Example response (not following) [409]:

    {
        "status": "fail",
        "data": {
            "user": "You were not following that user"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User is followed/unfollowed
    401 Not logged in
    404 Profile was not found (or removed)
    409 The user was already being followed/unfollowed

    List matches the user is participating in

    Obtain a list of matches the user is currently participating in (currently running or future).

    HTTP Request

    GET /v1/users/matches

    Example request:

    {
        "user": "user32",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to get information about
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "title": "Test match",
                    "start-date": "2017-01-01 00:00",
                    "end-date": "2017-01-05 00:00",
                    "slug": "test-match"
                },
                {
                    "title": "Super awesome match 9000",
                    "start-date": "2017-02-01 00:00",
                    "end-date": "2017-02-05 00:00",
                    "slug": "super-awesome-match-9000"
                }
            ] 
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of matches (list may be empty if no match is found)
    404 User was not found

    List matches the user has participated in

    Obtain a list of past matches the user has participated in.

    HTTP Request

    GET /v1/users/past-matches

    Example request:

    {
        "user": "user32",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    user string Username of the user to get information about
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "title": "Past match",
                    "start-date": "2016-01-01 00:00",
                    "end-date": "2016-01-05 00:00",
                    "slug": "past-match"
                },
                {
                    "title": "Super awesome match 8000",
                    "start-date": "2015-02-01 00:00",
                    "end-date": "2015-02-05 00:00",
                    "slug": "super-awesome-match-8000"
                }
            ] 
        }
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "user": "User was not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of matches (list may be empty if no match is found)
    404 User was not found

    /v1/admin

    The admin endpoint implements functionalities related to the management of the platform.

    Create a match

    Create a new match.

    HTTP Request

    POST /v1/admin/match

    Example request:

    {
        "token": "JWT_TOKEN",
        "title": "New match title",
        "short-description": "This is a short description",
        "long-description": "This is a long description",
        "start-date": "2017-01-01 00:00",
        "end-date": "2017-01-05 00:00",
        "min-members": 1,
        "max-members": 5,
        "is-visible": false,
        "slug": "custom-slug"
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    title string Title for the match
    short-description string Short description for the match
    long-description string Long description for the match
    start-date date Starting date(time) of the match
    end-date date Ending date(time) of the match
    min-members integer Minimum number of members required in a party
    max-members integer Maximum number of members allowed in a party
    is-visible boolean Whether the match can be found when querying the matches
    slug str Optional slug to override the one generated from the title

    HTTP Response

    Example response [201]:

    {
        "status": "success",
        "data": {
            "slug": "test-match"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "start-date": "Cannot be empty"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "title": "A match with this title already exists"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    201 Match created, returns match slug
    400 Some parameters are missing or incomplete (indicated in response)
    401 Not logged in
    403 Not an administrator
    409 A match with that slug/title already exists

    Modify a match

    Modify an existing match.

    Note that changing the title also changes the slug.

    HTTP Request

    PUT /v1/admin/match

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "current-match-slug",
        "max-team": 4,
        "leaderboard": true,
        "is-visible": false
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to modify
    leaderboard boolean (Optional) Whether to show the leaderboard

    Every parameter shown in the Create a match endpoint can be used to modify the specific attribute.

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "start-date": "2017-10-10 10:00:00",
            "slug": "test-match"
        }
    }
    

    Example response [400]:

    {
        "status": "fail",
        "data": {
            "is-visible": "Invalid type"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "title": "A match with this title already exists"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Match modified, returns new match details
    400 Some parameters are missing or incomplete (indicated in response)
    401 Not logged in
    403 Not an administrator
    404 Match does not exist
    409 A match with that slug/title already exists

    Get match leaderboard

    Get the current leaderboard of the specified match.

    This endpoint does not check if the leaderboard is posted or not.

    HTTP Request

    GET /v1/admin/match-leaderboard

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "test-match",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to get the leaderboard for
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "leader": "user32",
                    "members": ["user32", "userc"],
                    "position": 1
                },
                {
                    "leader": "userc",
                    "members": ["userc"],
                    "position": 2
                }
            ] 
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Ordered party list including the position of the party

    Set match leaderboard

    Update the leaderboard of the match by setting positions for each participating party.

    Note that this only sets the position for the specified parties, and will not modify already set positions in other parties.

    HTTP Request

    PUT /v1/admin/match-leaderboard

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "current-match-slug",
        "positions": [
            {
                "party": "party-leader-1",
                "position": 2,
            },
            {
                "party": "party-leader-3",
                "position": 1,
            }
        ]
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to delete
    positions list[json] List of objects specifying the party to update and its new position

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": [
            "party-leader1", "party-leader-2"
        ]
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Match leaderboard modified, returns list of modified parties
    401 Not logged in
    403 Not an administrator
    404 Match does not exist

    Delete/Undelete a match

    Delete/Undelete a match.

    This is a soft delete and can be undone.

    HTTP Request

    PUT /v1/admin/match-delete

    Example request:

    {
        "token": "JWT_TOKEN",
        "match": "current-match-slug",
        "delete": true
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    match string Unique slug of the match to delete
    delete boolean Whether to delete (true) or undelete (false) a match

    HTTP Response

    Example response (delete) [200]:

    {
        "status": "success",
        "data": {
            "delete-date": "2017-10-10 15:50"
        }
    }
    

    Example response (undelete) [200]:

    {
        "status": "success",
        "data": {
            "match": "restored-match"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "match": "Match was already deleted"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 Match deleted/undeleted, returns deletion date (when deleting) or match slug (when undeleting)
    401 Not logged in
    403 Not an administrator
    404 Match does not exist
    409 The match was already deleted/undeleted

    List deleted matches

    Obtain a list of deleted matches.

    HTTP Request

    GET /v1/admin/deleted-matches

    Example request:

    {
        "token": "JWT_TOKEN",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 3,
            "list": [
                {
                    "title": "Test match",
                    "delete-date": "2017-01-05 00:00",
                    "slug": "test-match"
                },
                {
                    "title": "Super awesome match 9000",
                    "delete-date": "2017-02-01 00:00",
                    "slug": "super-awesome-match-9000"
                }
            ] 
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of matches
    401 Not logged in
    403 Not an administrator

    List users

    Obtain a complete list of active users.

    HTTP Request

    GET /v1/admin/users

    Example request:

    {
        "token": "JWT_TOKEN",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                "user1",
                "user2",
                "user3",
                "user4"
            ]
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of users
    401 Not logged in
    403 Not an administrator

    List deleted/banned users

    Obtain a list of banned/deleted users.

    HTTP Request

    GET /v1/admin/deleted-users

    Example request:

    {
        "token": "JWT_TOKEN",
        "page": 1
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    page integer Page number to fetch (defaults to 1)

    HTTP Response

    Example response [200]:

    {
        "status": "success",
        "data": {
            "page": 1,
            "pages": 1,
            "list": [
                {
                    "username": "user1",
                    "delete-date": "2017-01-01 10:00:00"
                },
                {
                    "username": "user2",
                    "delete-date": "2017-01-01 10:00:00"
                },
                {
                    "username": "user3",
                    "delete-date": "2017-01-01 10:00:00"
                },
                {
                    "username": "user4",
                    "delete-date": "2017-01-01 10:00:00"
                },
            ]
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 List of users
    401 Not logged in
    403 Not an administrator

    Ban/unban user

    Ban/Unban a user.

    HTTP Request

    PUT /v1/admin/user-delete

    Example request:

    {
        "token": "JWT_TOKEN",
        "user": "username-to-ban",
        "delete": true
    }
    

    Parameters

    Parameter Type Description
    token string JSON Web Token (obtained from /v1/account/login)
    user string Username of the user to ban
    delete boolean Whether to delete (true) or undelete (false) a match

    HTTP Response

    Example response (delete) [200]:

    {
        "status": "success",
        "data": {
            "delete-date": "2017-10-10 15:50"
        }
    }
    

    Example response (undelete) [200]:

    {
        "status": "success",
        "data": {
            "user": "username-to-delete"
        }
    }
    

    Example response [401]:

    {
        "status": "error",
        "message": "User not logged in"
    }
    

    Example response [403]:

    {
        "status": "error",
        "message": "You are not an administrator"
    }
    

    Example response [404]:

    {
        "status": "fail",
        "data": {
            "match": "Match not found"
        }
    }
    

    Example response [409]:

    {
        "status": "fail",
        "data": {
            "match": "Match was already deleted"
        }
    }
    

    The following HTTP codes can be returned by this endpoint:

    HTTP Code Description
    200 User deleted/undeleted, returns deletion date (when deleting) or username (when undeleting)
    401 Not logged in
    403 Not an administrator
    404 User does not exist
    409 The user was already deleted/undeleted