List, add or delete boards
GET /boards
Status | Response |
200 OK |
Returns a list of boards with name and number of posts on board.
[
{
"name": "Lobby",
"posts": 0
},
{
"name": "Tech",
"posts": 3
}
] |
curl -i http://127.0.0.1:5000/boards -X GET
POST /boards
Parameter | Description |
body |
{
"name": "string",
"token": "string"
} |
Status | Response |
---|---|
204 NO CONTENT | Successfully added board. No additional action needed. |
400 BAD REQUEST | Board name contains invalid characters. |
409 CONFLICT | Board with designed name already exists. |
curl -i http://127.0.0.1:5000/boards -X POST -H 'Content-Type: application/json' -d '{"name":"ShrekIsLove", "token":"S4mpl3T0k3n"}'
DELETE /boards
Parameter | Description |
body |
{
"name": "string",
"token": "string"
} |
Status | Response |
---|---|
204 NO CONTENT | Successfully deleted board. No additional action needed. |
404 NOT FOUND | Board with designed name does not exists. |
curl -i http://127.0.0.1:5000/boards -X DELETE -H 'Content-Type: application/json' -d '{"name":"ShrekIsLove", "token":"S4mpl3T0k3n"}'
Get posts from board, add or delete posts on board.
GET /boards/<board>
Parameter | Description |
---|---|
board | Name of board to operate with |
Status | Response |
200 OK |
Returns a list of posts on a board with title, contents, author and ID of post.
[
{
"title": "Test number 1",
"contents": "Rokjsbj",
"author": "Administrator",
"id": 0
},
{
"title": "Test number 5874",
"contents": "vkhdbjs bk",
"author": "Administrator",
"id": 1
},
{
"title": "LOLZ",
"contents": "No contents",
"author": "Administrator",
"id": 2
}
] |
404 NOT FOUND | Board with designed name does not exist. |
curl -i http://127.0.0.1:5000/boards/Tech -X GET
POST /boards/<board>
Parameter | Description |
board | Name of board to operate with |
body |
{
"title": "string",
"contents": "string",
"token": "string"
} |
Status | Response |
---|---|
204 NO CONTENT | Successfully added post. No additional action needed. |
404 NOT FOUND | Board with designed name does not exist. |
curl -i http://127.0.0.1:5000/boards/Tech -X POST -H 'Content-Type: application/json' -d '{"title": "Test", "contents": "Random article", "token":"S4mpl3T0k3n"}'
DELETE /boards/<board>
Parameter | Description |
board | Name of board to operate with |
body |
{
"id": 0,
"token": "string"
} |
Status | Response |
---|---|
204 NO CONTENT | Successfully deleted post. No additional action needed. |
404 NOT FOUND | Board with designed name or post with designed ID does not exist. |
curl -i http://127.0.0.1:5000/boards/Tech -X DELETE -H 'Content-Type: application/json' -d '{"id": 3, "token":"S4mpl3T0k3n"}'
POST /auth/login
Parameter | Description |
body |
{
"username": "string",
"password": "string"
} |
Status | Response |
200 OK |
Returns a token for the user to use.
{
"token": "aXQD7WHV3wI"
} |
401 UNAUTHORIZED | Designed user credentials either do not exist or are disabled. |
curl -i http://127.0.0.1:5000/auth/login -X POST -H 'Content-Type: application/json' -d '{"username":"guest1", "password":"qwerty"}'
POST /auth/logout
Parameter | Description |
body |
{
"token": "string"
} |
Status | Description |
---|---|
204 NO CONTENT | Successfully logged user out. No additional action needed. |
498 INVALID TOKEN (unofficial) | Token provided does not exist. There is nothing to log out. |
curl -i http://127.0.0.1:5000/auth/logout -X POST -H 'Content-Type: application/json' -d '{"token":"<add_token_here>"}'
Insertion of a token is required.
POST /auth/logout_all
Parameter | Description |
body |
{
"token": "string"
} |
Status | Response |
200 OK |
Returns a number of tokens logged out.
{
"number": 3
} |
curl -i http://127.0.0.1:5000/auth/logout_all -X POST -H 'Content-Type: application/json' -d '{"token":"<add_token_here>"}'
Insertion of a token is required.
POST /auth/register
Parameter | Description |
body |
{
"username": "string",
"password": "string"
} |
Status | Description |
---|---|
204 NO CONTENT | Successfully registered user. You can now log in. |
409 CONFLICT | User with designed username already exists. |
curl -i http://127.0.0.1:5000/auth/register -X POST -H 'Content-Type: application/json' -d '{"username":"test", "password":"somepasswd"}'
POST /auth/chpasswd
Parameter | Description |
body |
{
"username": "string",
"old_password": "string",
"new_password": "string"
} |
Status | Description |
---|---|
204 NO CONTENT | Successfully changed password. No additional action needed. |
401 UNAUTHORIZED | Designed user credentials do not exist. |
curl -i http://127.0.0.1:5000/auth/chpasswd -X POST -H 'Content-Type: application/json' -d '{"username":"test", "old_password":"somepasswd", "new_password":"anotherpasswd"}'
POST /auth/unregister
Parameter | Description |
body |
{
"username": "string",
"password": "string"
} |
Status | Description |
---|---|
204 NO CONTENT | Successfully changed password. No additional action needed. |
401 UNAUTHORIZED | Designed user credentials do not exist. |
curl -i http://127.0.0.1:5000/auth/unregister -X POST -H 'Content-Type: application/json' -d '{"username":"test", "password":"anotherpasswd"}'
The following error descriptions supplement the errors in specific cases.
Status | Description |
---|---|
400 BAD REQUEST | The request was malformed. This is most commonly caused by missing parameters. |
404 NOT FOUND | Requested endpoint does not exist. |
405 METHOD NOT ALLOWED | HTTP method requested is not permitted at designed endpoint. |
500 INTERNAL SERVER ERROR | Error occured in the server code. Please notify the administrator in case this happens. |
Status | Description |
---|---|
401 UNAUTHORIZED | Authorization token was not provided. |
415 UNSUPPORTED MEDIA TYPE | Request must be JSON, and was not. |
440 LOGIN TIMEOUT (unofficial) | Token provided is expired. You need to re-login. |
498 INVALID TOKEN (unofficial) | Token provided is invalid. You need to re-login. |