Add API DOC

zelda 2025-08-07 12:11:47 +10:00
commit a3d71928d6
1 changed files with 187 additions and 0 deletions

187
API-DOC.md Normal file

@ -0,0 +1,187 @@
# API Documentation
## 1. Get Conversations
**URL**: `/conversations`
**Method**: `GET`
**Query Parameters**: Pagination parameters (`page`, `limit`, etc.)
### Response
```json
{
"message": "Thành công!",
"status_code": 200,
"data": [
{
"id": "19:uni01_clgxpvmvgzh7647hcq6s@thread.v2",
"name": "System Bot",
"type": "group",
"created_at": "2025-08-07T01:08:44.920Z",
"updated_at": "2025-08-07T01:08:44.920Z"
}
],
"timestamp": "2025-08-07T02:01:46.592Z",
"current_page": 1,
"from": 1,
"to": 2,
"last_page": 1,
"per_page": 10,
"total": 2
}
```
---
## 2. Get Conversation by ID
**URL**: `/conversations/:id`
**Method**: `GET`
### Response
```json
{
"message": "Thành công!",
"status_code": 200,
"data": {
"id": "19:uni01_clgxpvmvgzh7647hcq6sp5itg@thread.v2",
"name": "General Discussion",
"type": "group",
"created_at": "2025-08-07T01:08:44.920Z",
"updated_at": "2025-08-07T01:08:44.920Z",
"messages": [
{
"id": "a326950b-679f-4e30-8d78-3e5bb05f464c",
"name": "TeamBot",
"message": "You're welcome! If you have any more questions or need assistance, feel free to ask.",
"time": "2025-06-19T09:31:44.000Z",
"time_raw": "1750325503714",
"date_time": "1750325503714",
"room_id": "19:uni01_clgxpvmvgzh7647hcq6sp5itg@thread.v2",
"room_name": "General Discussion",
"created_at": "2025-08-07T01:20:46.846Z",
"updated_at": "2025-08-07T01:52:12.000Z"
},
{
"id": "a9a78d1b-c564-4c75-a15e-ab872f09726e",
"name": "TeamBot",
"message": "Sample message here",
"time": "2025-06-19T09:20:45.000Z",
"time_raw": "1750324844593",
"date_time": "1750324844593",
"room_id": "19:uni01_clgxpvmvgzh7647hcq6sp5itglwcqbbmhdxbokme5battrjlvnra@thread.v2",
"room_name": "General Discussion",
"created_at": "2025-08-07T01:20:46.820Z",
"updated_at": "2025-08-07T01:52:12.000Z"
}
]
},
"timestamp": "2025-08-07T01:52:12.513Z"
}
```
---
## 3. Send Message
**URL**: `/messages/send-message`
**Method**: `POST`
### Request Body
```json
{
"conversation_id": "19:abc123@thread.v2",
"message": "Xin chào! Đây là tin nhắn mới."
}
```
| Field | Type | Required | Description |
| --------------- | ------ | -------- | ---------------------------------- |
| conversation_id | string | ✅ | ID của cuộc trò chuyện cần gửi tin |
| message | string | ✅ | Nội dung tin nhắn |
### Response
```json
{
"message": "Thành công!",
"status_code": 200,
"data": {
"conversation": {
"id": "19:@thread.v2",
"name": "System bot",
"type": "group",
"created_at": "2025-08-07T01:08:44.913Z",
"updated_at": "2025-08-07T01:08:44.913Z"
},
"data": {
"message": "Xin chào! Đây là tin nhắn mới.",
"conversation_id": "19:@thread.v2"
}
},
"timestamp": "2025-08-07T01:52:02.553Z"
}
```
---
## 4. Reply Message
**URL**: `/messages/reply-message`
**Method**: `POST`
### Request Body
```json
{
"conversation_id": "19:abc123@thread.v2",
"message": "Đây là phản hồi",
"time": 1754466808815
}
```
| Field | Type | Required | Description |
| --------------- | ------ | -------- | ----------------------------------------- |
| conversation_id | string | ✅ | ID của cuộc trò chuyện |
| message | string | ✅ | Nội dung phản hồi |
| time | number | ✅ | Timestamp (milliseconds) của tin nhắn gốc |
### Response
```json
{
"message": "Thành công!",
"status_code": 200,
"data": {
"conversation": {
"id": "19:@thread.v2",
"name": "System Bot",
"type": "group",
"created_at": "2025-08-07T01:08:44.913Z",
"updated_at": "2025-08-07T01:08:44.913Z",
"messages": [
{
"id": "595b6276-b7bc-4b9f-9b36-c424fea024ef",
"name": "Teams Bot",
"message": "heheh\n8/6/2025, 9:11 AM\n😠\n\nhello",
"time": "2025-08-06T07:53:29.000Z",
"time_raw": "1754466808815",
"date_time": "1754466808815",
"room_id": "19:@thread.v2",
"room_name": "Test",
"created_at": "2025-08-07T01:15:39.815Z",
"updated_at": "2025-08-07T01:15:39.815Z"
}
]
},
"data": {
"message": "test",
"conversation_id": "19:@thread.v2",
"time": 1754466808815
}
},
"timestamp": "2025-08-07T01:51:54.367Z"
}
```