Skip to content
Max edited this page Jul 16, 2016 · 24 revisions

API methods description

getAccount

Get information about the account, bound to the token provided.

Method Address
GET /api/v1/accounts/<token>
Parameter Type Required Description
token string true Authorization token of the account

Response:

{
    "result": {
        "firstName": null,
        "lastName": null,
        "patronymic": null,
        "role": "ghost",
        "studyGroup": null,
        "tgId": null,
        "username": "max",
        "id": "575b3581aa87dd1cd0e137ab"
    },
    "status": "ok"
}

listAccounts

List accounts of ghost and student roles. Only accessible to users with role moderator.

Method Address
GET /api/v1/accounts/<token>/listAccounts
Parameter Type Required Description
token string true Authorization token of a moderator account

Response:

   {
    "result": [
        {
            "firstName": null,
            "id": "575b53fbaa87dd30d6963e5d",
            "lastName": null,
            "role": "ghost",
            "username": "andr"
        },
        {
            "firstName": null,
            "id": "575b3581aa87dd1cd0e137ab",
            "lastName": null,
            "role": "student",
            "username": "max"
        }
    ],
    "status": "ok"
}

createAccount

Create new account.

Method Address
POST /api/v1/accounts/
Parameter Type Required Description
username string true Account username. Consists of [3, 32] alphanumeric characters(English alphabet + digits) + underscore('_') - case insensitive
password string true Account password. Consists of [8, 64] characters

Response:

{
  "result": {
    "id": "575b3581aa87dd1cd0e137ab",
    "token": "cQY85mgmSxZl9G3t1B5ZpbsmWWj0bMxb",
    "username": "max"
  },
  "status": "ok"
}

exists

Check whether the account, bound to the token given, exists.

Method Address
GET /api/v1/accounts/<token>/exists
Parameter Type Required Description
token string true Account token

Response:

{
    "result": true,
    "status": "ok"
}

updateRole

Set new role of the account with accountId to newRole. Only accessible to users with role moderator.

Method Address
PUT /api/v1/accounts/<token>/updateRole
Parameter Type Required Description
token string true Moderator account token
accountId string true Id of an account to be updated with new role
newRole string true New role to provide the account with. Can only be ghost or student

Response:

{
    "status": "ok"
}

auth

Authorize the user.

Method Address
POST /api/v1/accounts/auth
Parameter Type Required Description
username string true Username of an account
password string true Password of an account

Response:

{
    "result": {
        "id": "575b3581aa87dd1cd0e137ab",
        "token": "cQY85mgmSxZl9G3t1B5ZpbsmWWj0bMxb",
        "username": "max"
    },
    "status": "ok"
}

Clone this wiki locally