Skip to content

Commit 205d162

Browse files
Update API.md
1 parent 522dcaa commit 205d162

File tree

1 file changed

+227
-68
lines changed

1 file changed

+227
-68
lines changed

API.md

Lines changed: 227 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,297 @@
11
# API Documentation
2-
## User Management
2+
---
3+
title: flypen v1.0.0
4+
language_tabs:
5+
- shell: Zsh
6+
- http: HTTP
7+
- javascript: JavaScript
8+
toc_footers: []
9+
includes: []
10+
search: true
11+
code_clipboard: true
12+
highlight_theme: darkula
13+
headingLevel: 2
314

4-
```POST /api/signup```
15+
---
16+
17+
# flypen
18+
19+
## POST /api/signup
520

621
Register a new user account.
722

8-
- Request Body:
23+
POST /api/signup
24+
25+
### Request Body
926

10-
username: Username string
11-
password: Password string
27+
| Name | Type | Description |
28+
| --- | --- | --- |
29+
| username | string | Username |
30+
| password | string | Password |
1231

13-
- Response:
32+
### Responses
1433

15-
201: User created successfully
16-
409: Username already exists
34+
| HTTP Status Code | Meaning | Description | Data schema |
35+
| --- | --- | --- | --- |
36+
| 201 | User created successfully | | |
37+
| 409 | Username already exists | | |
1738

18-
```POST /api/login```
39+
## POST /api/login
1940

2041
Login with username and password.
2142

22-
- Request Body:
43+
POST /api/login
2344

24-
username: Username string
25-
password: Password string
45+
### Request Body
2646

27-
- Response:
47+
| Name | Type | Description |
48+
| --- | --- | --- |
49+
| username | string | Username |
50+
| password | string | Password |
2851

29-
200: Login succeeded
30-
401: Invalid credentials
52+
### Responses
3153

32-
```POST /api/avatar```
54+
| HTTP Status Code | Meaning | Description | Data schema |
55+
| --- | --- | --- | --- |
56+
| 200 | Login succeeded | | |
57+
| 401 | Invalid credentials | | |
58+
59+
## POST /api/avatar
3360

3461
Set user avatar.
3562

36-
- Request Body:
63+
POST /api/avatar
3764

38-
avatar: Avatar ID int
65+
### Request Body
3966

40-
- Response:
67+
| Name | Type | Description |
68+
| --- | --- | --- |
69+
| avatar | int | Avatar ID |
4170

42-
200: Login succeeded
43-
401: Invalid credentials
71+
### Responses
4472

45-
## Chat
73+
| HTTP Status Code | Meaning | Description | Data schema |
74+
| --- | --- | --- | --- |
75+
| 200 | Avatar set successfully | | |
76+
| 401 | Invalid credentials | | |
4677

47-
```POST /api/chat```
78+
## POST /api/chat
4879

4980
Send a chat message.
5081

51-
- Request Body:
82+
POST /api/chat
5283

53-
content: Chat message content
54-
receiver: receiver username string
84+
### Request Body
5585

56-
- Response:
86+
| Name | Type | Description |
87+
| --- | --- | --- |
88+
| content | string | Chat message content |
89+
| receiver | string | Receiver username |
5790

58-
200: Message sent
59-
404: User or chat room not found
91+
### Responses
6092

61-
```POST /api/check```
93+
| HTTP Status Code | Meaning | Description | Data schema |
94+
| --- | --- | --- | --- |
95+
| 200 | Message sent | | |
96+
| 404 | User or chat room not found | | |
6297

63-
Send a chat message.
98+
## POST /api/check
99+
100+
Check if a user is online.
64101

65-
- Response:
102+
POST /api/check
66103

67-
200: Message sent
68-
404: User or chat room not found
104+
### Responses
69105

70-
## Friend Management
106+
| HTTP Status Code | Meaning | Description | Data schema |
107+
| --- | --- | --- | --- |
108+
| 200 | User is online | | |
109+
| 404 | User not found | | |
71110

72-
```POST /api/nfmgr```
111+
## POST /api/nfmgr
73112

74113
Manage friend requests.
75114

76-
- Request Body:
115+
POST /api/nfmgr
77116

78-
info: add string
79-
username: Recipient username
117+
### Request Body
80118

81-
- Response:
119+
| Name | Type | Description |
120+
| --- | --- | --- |
121+
| info | string | "add" or "accept" |
122+
| username | string | Recipient username |
82123

83-
200: Request success
84-
404: User not found
124+
### Responses
85125

86-
```GET /api/newfriends```
126+
| HTTP Status Code | Meaning | Description | Data schema |
127+
| --- | --- | --- | --- |
128+
| 200 | Request success | | |
129+
| 404 | User not found | | |
130+
131+
## GET /api/newfriends
87132

88133
Get list of pending friend requests.
89134

90-
- Response:
135+
GET /api/newfriends
91136

92-
200: Array of friend request objects
93-
401: Unauthorized
137+
### Responses
94138

95-
User Info
139+
| HTTP Status Code | Meaning | Description | Data schema |
140+
| --- | --- | --- | --- |
141+
| 200 | Array of friend request objects | | Array of friend request objects |
142+
| 401 | Unauthorized | | |
96143

97-
```GET /api/info```
144+
## GET /api/info
98145

99146
Get user profile information.
100147

101-
- Request Header:
148+
GET /api/info
102149

103-
Authorization: JWT token
150+
### Request Headers
104151

105-
- Response:
152+
| Name | Type | Description |
153+
| --- | --- | --- |
154+
| Authorization | string | JWT token |
106155

107-
200: User info object
108-
401: Invalid token
156+
### Responses
109157

110-
File Management
158+
| HTTP Status Code | Meaning | Description | Data schema |
159+
| --- | --- | --- | --- |
160+
| 200 | User info object | | User info object |
161+
| 401 | Invalid token | | |
111162

112-
```POST /api/file/save```
163+
## POST /api/file/save
113164

114165
Save a file.
115166

116-
- Request Body:
167+
POST /api/file/save
168+
169+
### Request Body
117170

118-
file: File data
119-
path: File path
120-
filename: Filename
171+
| Name | Type | Description |
172+
| --- | --- | --- |
173+
| file | binary | File data |
174+
| path | string | File path |
175+
| filename | string | Filename |
121176

122-
- Response:
177+
### Responses
123178

124-
201: File saved
125-
500: Error saving file
179+
| HTTP Status Code | Meaning | Description | Data schema |
180+
| --- | --- | --- | --- |
181+
| 201 | File saved | | |
182+
| 400 | Invalid request | | |
183+
| 500 | Error saving file | | |
126184

127-
```GET /api/file/get```
185+
## GET /api/file/get
128186

129187
Get a file.
130188

131-
- Request Parameter:
189+
GET /api/file/get
190+
191+
### Request Parameters
192+
193+
| Name | Type | Description |
194+
| --- | --- | --- |
195+
| filePath | string | Path of file on server |
196+
197+
### Responses
198+
199+
| HTTP Status Code | Meaning | Description | Data schema |
200+
| --- | --- | --- | --- |
201+
| 200 | File data | | File data |
202+
| 404 | File not found | | |
203+
204+
## POST upload
205+
206+
POST /api/upload
207+
208+
> Body Parameters
209+
210+
```yaml
211+
image: string
212+
213+
```
214+
215+
### Params
216+
217+
|Name|Location|Type|Required|Description|
218+
|---|---|---|---|---|
219+
|body|body|object| no |none|
220+
|» image|body|string(binary)| yes |none|
221+
222+
223+
### Responses
224+
225+
|HTTP Status Code |Meaning|Description|Data schema|
226+
|---|---|---|---|
227+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Success|Inline|
228+
229+
### Responses Data Schema
230+
231+
232+
## POST commands
233+
234+
POST /api/commands
235+
236+
> Body Parameters
237+
238+
```json
239+
{
240+
"commands": "1",
241+
"params": [
242+
"",
243+
""
244+
]
245+
}
246+
```
247+
248+
### Params
249+
250+
|Name|Location|Type|Required|Description|
251+
|---|---|---|---|---|
252+
|body|body|object| no |none|
253+
|» commands|body|string| yes |none|
254+
|» params|body|[string]| yes |none|
255+
256+
> Response Examples
257+
258+
> 200 Response
259+
260+
```json
261+
{}
262+
```
263+
264+
### Responses
265+
266+
|HTTP Status Code |Meaning|Description|Data schema|
267+
|---|---|---|---|
268+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Success|Inline|
269+
270+
### Responses Data Schema
271+
272+
## POST lock
273+
274+
POST /api/file/lock
275+
276+
### Params
277+
278+
|Name|Location|Type|Required|Description|
279+
|---|---|---|---|---|
280+
|filename|query|string| yes |none|
281+
282+
> Response Examples
283+
284+
> 200 Response
285+
286+
```json
287+
{}
288+
```
289+
290+
### Responses
132291

133-
filePath: Path of file on server
292+
|HTTP Status Code |Meaning|Description|Data schema|
293+
|---|---|---|---|
294+
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Success|Inline|
134295

135-
Response:
296+
### Responses Data Schema
136297

137-
200: File data
138-
404: File not found

0 commit comments

Comments
 (0)