|
1 | 1 | # 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 |
3 | 14 |
|
4 |
| -```POST /api/signup``` |
| 15 | +--- |
| 16 | + |
| 17 | +# flypen |
| 18 | + |
| 19 | +## POST /api/signup |
5 | 20 |
|
6 | 21 | Register a new user account.
|
7 | 22 |
|
8 |
| -- Request Body: |
| 23 | +POST /api/signup |
| 24 | + |
| 25 | +### Request Body |
9 | 26 |
|
10 |
| -username: Username string |
11 |
| -password: Password string |
| 27 | +| Name | Type | Description | |
| 28 | +| --- | --- | --- | |
| 29 | +| username | string | Username | |
| 30 | +| password | string | Password | |
12 | 31 |
|
13 |
| -- Response: |
| 32 | +### Responses |
14 | 33 |
|
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 | | | |
17 | 38 |
|
18 |
| -```POST /api/login``` |
| 39 | +## POST /api/login |
19 | 40 |
|
20 | 41 | Login with username and password.
|
21 | 42 |
|
22 |
| -- Request Body: |
| 43 | +POST /api/login |
23 | 44 |
|
24 |
| -username: Username string |
25 |
| -password: Password string |
| 45 | +### Request Body |
26 | 46 |
|
27 |
| -- Response: |
| 47 | +| Name | Type | Description | |
| 48 | +| --- | --- | --- | |
| 49 | +| username | string | Username | |
| 50 | +| password | string | Password | |
28 | 51 |
|
29 |
| -200: Login succeeded |
30 |
| -401: Invalid credentials |
| 52 | +### Responses |
31 | 53 |
|
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 |
33 | 60 |
|
34 | 61 | Set user avatar.
|
35 | 62 |
|
36 |
| -- Request Body: |
| 63 | +POST /api/avatar |
37 | 64 |
|
38 |
| -avatar: Avatar ID int |
| 65 | +### Request Body |
39 | 66 |
|
40 |
| -- Response: |
| 67 | +| Name | Type | Description | |
| 68 | +| --- | --- | --- | |
| 69 | +| avatar | int | Avatar ID | |
41 | 70 |
|
42 |
| -200: Login succeeded |
43 |
| -401: Invalid credentials |
| 71 | +### Responses |
44 | 72 |
|
45 |
| -## Chat |
| 73 | +| HTTP Status Code | Meaning | Description | Data schema | |
| 74 | +| --- | --- | --- | --- | |
| 75 | +| 200 | Avatar set successfully | | | |
| 76 | +| 401 | Invalid credentials | | | |
46 | 77 |
|
47 |
| -```POST /api/chat``` |
| 78 | +## POST /api/chat |
48 | 79 |
|
49 | 80 | Send a chat message.
|
50 | 81 |
|
51 |
| -- Request Body: |
| 82 | +POST /api/chat |
52 | 83 |
|
53 |
| -content: Chat message content |
54 |
| -receiver: receiver username string |
| 84 | +### Request Body |
55 | 85 |
|
56 |
| -- Response: |
| 86 | +| Name | Type | Description | |
| 87 | +| --- | --- | --- | |
| 88 | +| content | string | Chat message content | |
| 89 | +| receiver | string | Receiver username | |
57 | 90 |
|
58 |
| -200: Message sent |
59 |
| -404: User or chat room not found |
| 91 | +### Responses |
60 | 92 |
|
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 | | | |
62 | 97 |
|
63 |
| -Send a chat message. |
| 98 | +## POST /api/check |
| 99 | + |
| 100 | +Check if a user is online. |
64 | 101 |
|
65 |
| -- Response: |
| 102 | +POST /api/check |
66 | 103 |
|
67 |
| -200: Message sent |
68 |
| -404: User or chat room not found |
| 104 | +### Responses |
69 | 105 |
|
70 |
| -## Friend Management |
| 106 | +| HTTP Status Code | Meaning | Description | Data schema | |
| 107 | +| --- | --- | --- | --- | |
| 108 | +| 200 | User is online | | | |
| 109 | +| 404 | User not found | | | |
71 | 110 |
|
72 |
| -```POST /api/nfmgr``` |
| 111 | +## POST /api/nfmgr |
73 | 112 |
|
74 | 113 | Manage friend requests.
|
75 | 114 |
|
76 |
| -- Request Body: |
| 115 | +POST /api/nfmgr |
77 | 116 |
|
78 |
| -info: add string |
79 |
| -username: Recipient username |
| 117 | +### Request Body |
80 | 118 |
|
81 |
| -- Response: |
| 119 | +| Name | Type | Description | |
| 120 | +| --- | --- | --- | |
| 121 | +| info | string | "add" or "accept" | |
| 122 | +| username | string | Recipient username | |
82 | 123 |
|
83 |
| -200: Request success |
84 |
| -404: User not found |
| 124 | +### Responses |
85 | 125 |
|
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 |
87 | 132 |
|
88 | 133 | Get list of pending friend requests.
|
89 | 134 |
|
90 |
| -- Response: |
| 135 | +GET /api/newfriends |
91 | 136 |
|
92 |
| -200: Array of friend request objects |
93 |
| -401: Unauthorized |
| 137 | +### Responses |
94 | 138 |
|
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 | | | |
96 | 143 |
|
97 |
| -```GET /api/info``` |
| 144 | +## GET /api/info |
98 | 145 |
|
99 | 146 | Get user profile information.
|
100 | 147 |
|
101 |
| -- Request Header: |
| 148 | +GET /api/info |
102 | 149 |
|
103 |
| -Authorization: JWT token |
| 150 | +### Request Headers |
104 | 151 |
|
105 |
| -- Response: |
| 152 | +| Name | Type | Description | |
| 153 | +| --- | --- | --- | |
| 154 | +| Authorization | string | JWT token | |
106 | 155 |
|
107 |
| -200: User info object |
108 |
| -401: Invalid token |
| 156 | +### Responses |
109 | 157 |
|
110 |
| -File Management |
| 158 | +| HTTP Status Code | Meaning | Description | Data schema | |
| 159 | +| --- | --- | --- | --- | |
| 160 | +| 200 | User info object | | User info object | |
| 161 | +| 401 | Invalid token | | | |
111 | 162 |
|
112 |
| -```POST /api/file/save``` |
| 163 | +## POST /api/file/save |
113 | 164 |
|
114 | 165 | Save a file.
|
115 | 166 |
|
116 |
| -- Request Body: |
| 167 | +POST /api/file/save |
| 168 | + |
| 169 | +### Request Body |
117 | 170 |
|
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 | |
121 | 176 |
|
122 |
| -- Response: |
| 177 | +### Responses |
123 | 178 |
|
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 | | | |
126 | 184 |
|
127 |
| -```GET /api/file/get``` |
| 185 | +## GET /api/file/get |
128 | 186 |
|
129 | 187 | Get a file.
|
130 | 188 |
|
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 |
132 | 291 |
|
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| |
134 | 295 |
|
135 |
| -Response: |
| 296 | +### Responses Data Schema |
136 | 297 |
|
137 |
| -200: File data |
138 |
| -404: File not found |
|
0 commit comments