更新 API.md

This commit is contained in:
绪山七寻 2025-05-31 18:59:23 +08:00
parent b2fea7a26e
commit 635c033047

46
API.md
View File

@ -6,8 +6,8 @@
## 认证方式 ## 认证方式
使用简单的 Token 认证(实际生产环境应使用 JWT 等更安全的方式)。 使用简单的 Token 认证(实际生产环境应使用 JWT 等更安全的方式)。
登录后返回的 Token 需在后续请求中通过 `Authorization` 头携带: 登录后返回的 Token 需在后续请求中通过 `Authorization` 头携带: `Authorization: Bearer <your_token>`
`Authorization: Bearer <your_token>`
--- ---
@ -19,23 +19,23 @@
**请求体**: **请求体**:
```json ```json
{ {
"username": "string", "username": "string",
"password": "string" "password": "string"
} }
``` ```
**成功响应**: **成功响应**:
```json ```json
{ {
"success": true, "success": true,
"message": "User registered successfully" "message": "User registered successfully"
} }
``` ```
**错误响应**: **错误响应**:
```json ```json
{ {
"success": false, "success": false,
"message": "Username already exists" "message": "Username already exists"
} }
``` ```
@ -48,26 +48,26 @@
**请求体**: **请求体**:
```json ```json
{ {
"username": "string", "username": "string",
"password": "string" "password": "string"
} }
``` ```
**成功响应**: **成功响应**:
```json ```json
{ {
"success": true, "success": true,
"message": "Login successful", "message": "Login successful",
"token": "string", "token": "string",
"user_id": "integer", "user_id": "integer",
"username": "string" "username": "string"
} }
``` ```
**错误响应**: **错误响应**:
```json ```json
{ {
"success": false, "success": false,
"message": "Invalid username or password" "message": "Invalid username or password"
} }
``` ```
@ -130,23 +130,23 @@
**请求体**: **请求体**:
```json ```json
{ {
"message_id": "integer", "message_id": "integer",
"user_id": "integer" "user_id": "integer"
} }
``` ```
**成功响应**: **成功响应**:
```json ```json
{ {
"success": true, "success": true,
"message": "Message recalled successfully" "message": "Message recalled successfully"
} }
``` ```
**错误响应**: **错误响应**:
```json ```json
{ {
"success": false, "success": false,
"message": "You can only recall your own messages" "message": "You can only recall your own messages"
} }
``` ```