2022-03-20 21:37:47 +03:00
|
|
|
# API documentation of Akf-forum
|
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
|
2022-09-21 22:42:08 +03:00
|
|
|
You need this header for send request to API:
|
2022-04-03 22:03:47 +03:00
|
|
|
```json
|
2022-03-20 21:37:47 +03:00
|
|
|
{
|
2022-09-21 22:42:08 +03:00
|
|
|
"authorization": "Basic <base64 encoded username:password>"
|
2022-03-20 21:37:47 +03:00
|
|
|
}
|
|
|
|
```
|
2022-09-21 22:42:08 +03:00
|
|
|
|
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
|
|
|
|
2022-09-17 16:27:01 +03:00
|
|
|
## Default Limits:
|
2022-09-17 00:27:38 +03:00
|
|
|
- 3 - 25 char for username, password and category name
|
|
|
|
- 256 char for user about and desp of category
|
|
|
|
- 5 - 128 char for thread titles.
|
|
|
|
- 5 - 1024 char for messages.
|
|
|
|
|
2022-09-17 16:44:04 +03:00
|
|
|
You can change them in config.json.
|
2022-03-20 21:37:47 +03:00
|
|
|
|
2022-09-17 16:44:04 +03:00
|
|
|
## How to request?
|
2022-08-11 01:11:07 +03:00
|
|
|
### Request types:
|
2022-09-17 16:44:04 +03:00
|
|
|
#### `/api/me`
|
2022-09-09 21:40:02 +03:00
|
|
|
- GET `/api/me` to get your account.
|
|
|
|
|
2022-10-09 22:57:46 +03:00
|
|
|
#### `/api/config`
|
|
|
|
- GET `/` to reach config file.
|
|
|
|
- PUT `/` to edit config file.
|
|
|
|
|
2022-09-17 16:44:04 +03:00
|
|
|
#### `/api/bans`
|
|
|
|
- GET `/` fetch all bans.
|
|
|
|
- GET `/:ip` fetch a ban.
|
|
|
|
- DELETE `/:ip` for unban an IP adress.
|
|
|
|
- POST `/?reason=flood` for ban an IP adress.
|
|
|
|
|
|
|
|
#### `/api/categories`
|
|
|
|
- GET `/` fetch all categories.
|
|
|
|
- GET `/:id` fetch a category
|
|
|
|
- PATCH `/:id` for update a category.
|
|
|
|
- DELETE `/:id` for delete a category.
|
|
|
|
- POST `/` for create a category.
|
|
|
|
|
|
|
|
#### `/api/messages`
|
|
|
|
- GET `/:id` for fetch message.
|
|
|
|
- DELETE `/:id` for delete message.
|
|
|
|
- PATCH `/:id` for edit message.
|
|
|
|
- POST `/:id/react/:type` for react to a message.
|
|
|
|
- POST `/` for create message.
|
|
|
|
|
|
|
|
#### `/api/search` use `?limit=&skip=` for skip and limit
|
|
|
|
- GET `/users?q=query` find users.
|
|
|
|
- GET `/threads?q=query&authorID=not_required` find threads.
|
|
|
|
- GET `/messages?q=query&authorID=not_required` find messages.
|
|
|
|
|
|
|
|
#### `/api/threads`
|
|
|
|
- GET `/:id` for fetch thread.
|
|
|
|
- DELETE `/:id` for delete thread.
|
|
|
|
- PATCH `/:id` for edit thread.
|
|
|
|
- GET `/:id/messages?skip=0&limit=10` for fetch messages in thread.
|
|
|
|
- POST `/` for create thread.
|
|
|
|
|
|
|
|
#### `/api/users`
|
|
|
|
- GET `/:id` for fetch user.
|
|
|
|
- DELETE `/:id` for delete user.
|
|
|
|
- PATCH `/:id` for edit user.
|
|
|
|
- PUT `/:id` for add profile photo to user.
|
2022-09-23 23:10:13 +03:00
|
|
|
- POST `/:id/ban` for ban all ips of user.
|
2022-09-09 17:13:37 +03:00
|
|
|
|
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-09-24 00:15:17 +03:00
|
|
|
```js
|
2022-08-27 09:53:10 +03:00
|
|
|
{
|
2022-09-24 00:15:17 +03:00
|
|
|
"react": {
|
|
|
|
"like": [],
|
|
|
|
"dislike": ["0"]
|
|
|
|
},
|
|
|
|
"_id": "6325c216faa938c4cfc43075",
|
2022-08-27 09:53:10 +03:00
|
|
|
"author": {
|
2022-09-24 00:15:17 +03:00
|
|
|
"_id": "632e028ca4ba362ebbb75a43",
|
2022-08-27 09:53:10 +03:00
|
|
|
"name": "Akif9748",
|
2022-09-24 00:15:17 +03:00
|
|
|
"avatar": "/images/avatars/0.jpg",
|
2022-03-20 21:37:47 +03:00
|
|
|
"deleted": false,
|
2022-09-24 00:15:17 +03:00
|
|
|
"edited": true,
|
|
|
|
"about": "# Owner",
|
|
|
|
"admin": true,
|
|
|
|
"theme": "black",
|
|
|
|
"hideLastSeen": false,
|
|
|
|
"time": "2022-09-23T19:01:32.610Z",
|
|
|
|
"id": "0",
|
|
|
|
"__v": 0,
|
|
|
|
"discordID": "539506680140922890"
|
2022-08-27 09:53:10 +03:00
|
|
|
},
|
2022-09-24 00:15:17 +03:00
|
|
|
"threadID": "0",
|
|
|
|
"content": "This is a thread opened via API, yes",
|
2022-08-27 09:53:10 +03:00
|
|
|
"deleted": false,
|
2022-09-24 00:15:17 +03:00
|
|
|
"edited": true,
|
|
|
|
"time": "2022-09-17T12:48:22.378Z",
|
2022-08-27 09:53:10 +03:00
|
|
|
"id": "0",
|
2022-09-24 00:15:17 +03:00
|
|
|
"__v": 4,
|
|
|
|
"oldContents": []
|
2022-03-20 21:37:47 +03:00
|
|
|
}
|
2022-08-27 09:53:10 +03:00
|
|
|
```
|