2022-03-20 21:37:47 +03:00
|
|
|
# API documentation of Akf-forum
|
|
|
|
<img src="https://raw.githubusercontent.com/Akif9748/akf-forum/main/public/images/logo.jpg" align="right" width="300px" />
|
|
|
|
|
2022-08-27 09:53:10 +03:00
|
|
|
Akf-forum has got an API for AJAX, other clients etc.
|
2022-03-20 21:37:47 +03:00
|
|
|
|
|
|
|
## Authorization
|
|
|
|
You need this headers for send request to API:
|
2022-04-03 22:03:47 +03:00
|
|
|
```json
|
2022-03-20 21:37:47 +03:00
|
|
|
{
|
|
|
|
"username": "testUser",
|
|
|
|
"password": "testPassword"
|
|
|
|
}
|
|
|
|
```
|
2022-08-27 09:53:10 +03:00
|
|
|
But in front end, the API will works with session.
|
2022-03-20 21:37:47 +03:00
|
|
|
|
|
|
|
## How to request?
|
|
|
|
|
2022-08-11 01:11:07 +03:00
|
|
|
### Request types:
|
2022-09-01 16:28:15 +03:00
|
|
|
- GET `/api/search/users?q=query` find users.
|
|
|
|
- GET `/api/search/threads?q=query&authorID=not_required` find threads.
|
|
|
|
- GET `/api/search/messages?q=query&authorID=not_required` find messages.
|
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
- GET `/api/bans/` fetch all bans.
|
|
|
|
- GET `/api/bans/:id` fetch a ban.
|
|
|
|
- DELETE `/api/bans/:id` for unban an IP adress.
|
2022-08-31 14:44:28 +03:00
|
|
|
- POST `/api/bans?reason=flood` for ban an IP adress.
|
2022-08-29 21:32:57 +03:00
|
|
|
|
2022-08-11 03:12:40 +03:00
|
|
|
- GET `/api/users/:id` for fetch user.
|
2022-08-29 21:32:57 +03:00
|
|
|
- DELETE `/api/users/:id/` for delete user.
|
2022-08-31 14:44:28 +03:00
|
|
|
- PATCH `/api/users/:id/` for edit user.
|
2022-08-26 20:12:23 +03:00
|
|
|
- POST `/api/users/:id/undelete` for undelete user.
|
2022-08-11 03:48:35 +03:00
|
|
|
|
2022-08-11 03:12:40 +03:00
|
|
|
- GET `/api/threads/:id` for fetch thread.
|
2022-08-29 21:32:57 +03:00
|
|
|
- DELETE `/api/threads/:id/` for delete thread.
|
|
|
|
- PATCH `/api/threads/:id/` for edit thread.
|
2022-08-31 14:44:28 +03:00
|
|
|
- POST `/api/threads/:id/undelete` for undelete thread.
|
|
|
|
- GET `/api/threads/:id/messages?skip=0&limit=10` for fetch messages in thread.
|
|
|
|
- POST `/api/threads` for create thread.
|
2022-08-11 03:48:35 +03:00
|
|
|
|
2022-08-11 03:12:40 +03:00
|
|
|
- GET `/api/messages/:id` for fetch message.
|
2022-08-29 21:32:57 +03:00
|
|
|
- DELETE `/api/messages/:id/` for delete message.
|
2022-08-31 14:44:28 +03:00
|
|
|
- PATCH `/api/messages/:id/` for edit message.
|
2022-08-26 20:12:23 +03:00
|
|
|
- POST `/api/messages/:id/undelete` for undelete message.
|
2022-08-11 03:12:40 +03:00
|
|
|
- POST `/api/messages/:id/react/:type` for react to a message.
|
2022-08-31 14:44:28 +03:00
|
|
|
- POST `/api/messages` for create message.
|
2022-03-20 21:37:47 +03:00
|
|
|
|
|
|
|
### Example request:
|
2022-08-27 09:53:10 +03:00
|
|
|
GET ```/api/messages/0```
|
2022-03-20 21:37:47 +03:00
|
|
|
|
|
|
|
#### Example API Output:
|
2022-08-27 09:53:10 +03:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"_id": "63067429bc01da866fad508b",
|
|
|
|
"threadID": "0",
|
|
|
|
"author": {
|
|
|
|
"id": "0",
|
|
|
|
"name": "Akif9748",
|
|
|
|
"avatar": "https://cdn.discordapp.com/avatars/539506680140922890/abd74d10aac094fc8a5ad5c86f29fdb9.png?size=1024",
|
|
|
|
"time": "2022-08-24T18:54:55.666Z",
|
2022-03-20 21:37:47 +03:00
|
|
|
"deleted": false,
|
2022-08-27 09:53:10 +03:00
|
|
|
"admin": false,
|
|
|
|
"_id": "630673ffbc01da866fad507b",
|
|
|
|
"__v": 0
|
|
|
|
},
|
|
|
|
"content": "deneme",
|
|
|
|
"deleted": false,
|
|
|
|
"edited": false,
|
|
|
|
"time": "2022-08-24T18:55:37.744Z",
|
|
|
|
"id": "0",
|
|
|
|
"__v": 0,
|
|
|
|
"react": {
|
2022-08-28 21:14:02 +03:00
|
|
|
"like": [0],
|
2022-08-31 14:44:28 +03:00
|
|
|
"dislike": []
|
2022-08-27 09:53:10 +03:00
|
|
|
},
|
2022-08-28 21:14:02 +03:00
|
|
|
"authorID": "0"
|
2022-03-20 21:37:47 +03:00
|
|
|
}
|
2022-08-27 09:53:10 +03:00
|
|
|
```
|