Repository navigation
API v1
Max edited this page Jun 10, 2016
·
24 revisions
Get information about an account, bound to the token provided.
| Method | Address |
|---|---|
| GET | /api/v<api_version>/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"
},
"status": "ok"
}
Create new account.
| Method | Address |
|---|---|
| POST | /api/v<api_version>/accounts/ |
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | true | Account username |
| password | string | true | Account password |
Response:
{
"result": {
"id": "575b3581aa87dd1cd0e137ab",
"token": "cQY85mgmSxZl9G3t1B5ZpbsmWWj0bMxb",
"username": "max"
},
"status": "ok"
}
Check whether an account, bound to the token given, exists.
| Method | Address |
|---|---|
| GET | /api/v<api_version>/accounts/<token>/exists |
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | true | Account token |
Response:
{
"result": true,
"status": "ok"
}
Set new role of an account with accountId to newRole. Only allowed for users with role moderator or higher.
| Method | Address |
|---|---|
| PUT | /api/v<api_version>/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"
}
Authorize the user.
| Method | Address |
|---|---|
| POST | /api/v<api_version>/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"
}