Update API DOC
parent
a3d71928d6
commit
432eab9b22
95
API-DOC.md
95
API-DOC.md
|
|
@ -185,3 +185,98 @@
|
|||
"timestamp": "2025-08-07T01:51:54.367Z"
|
||||
}
|
||||
```
|
||||
|
||||
## 5. Get Messages
|
||||
|
||||
**URL**: `/messages`
|
||||
**Method**: `GET`
|
||||
**Description**: Lấy danh sách tin nhắn, hỗ trợ phân trang, sort, search và filter theo conversation.
|
||||
|
||||
---
|
||||
|
||||
### Query Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|---------|------|-------------|
|
||||
| `page` | number | Trang hiện tại |
|
||||
| `limit` | number | Số bản ghi mỗi trang |
|
||||
| `sortBy` | string | Sắp xếp, ví dụ: `time_raw:DESC` |
|
||||
| `search` | string | Tìm kiếm theo nội dung message |
|
||||
| `filter.conversation.id` | string | Lọc theo ID của conversation |
|
||||
|
||||
---
|
||||
|
||||
### Filter format
|
||||
|
||||
```
|
||||
filter.<column>=$<operator>:<value>
|
||||
```
|
||||
|
||||
#### Filter theo conversation
|
||||
|
||||
```http
|
||||
GET /messages?filter.conversation.id=$eq:19:abc123@thread.v2
|
||||
```
|
||||
|
||||
#### Filter nhiều conversation
|
||||
|
||||
```http
|
||||
GET /messages?filter.conversation.id=$in:19:abc@thread.v2,19:def@thread.v2
|
||||
```
|
||||
|
||||
#### Không thuộc conversation nào
|
||||
|
||||
```http
|
||||
GET /messages?filter.conversation.id=$isnull
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Supported Operators
|
||||
|
||||
| Operator | Meaning |
|
||||
|--------|--------|
|
||||
| `$eq` | Bằng |
|
||||
| `$ne` | Khác |
|
||||
| `$in` | Trong danh sách |
|
||||
| `$notin` | Không trong danh sách |
|
||||
| `$gt` | Lớn hơn |
|
||||
| `$gte` | Lớn hơn hoặc bằng |
|
||||
| `$lt` | Nhỏ hơn |
|
||||
| `$lte` | Nhỏ hơn hoặc bằng |
|
||||
| `$ilike` | Tìm kiếm text (không phân biệt hoa thường) |
|
||||
| `$isnull` | Null |
|
||||
|
||||
---
|
||||
|
||||
### Example Request
|
||||
|
||||
```http
|
||||
GET /messages?page=1&limit=10&sortBy=time_raw:DESC&filter.conversation.id=$eq:19:abc123@thread.v2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"message": "Thành công!",
|
||||
"status_code": 200,
|
||||
"data": [
|
||||
{
|
||||
"id": "a326950b-679f-4e30-8d78-3e5bb05f464c",
|
||||
"name": "TeamBot",
|
||||
"message": "Sample message",
|
||||
"time": "2025-06-19T09:31:44.000Z",
|
||||
"time_raw": "1750325503714",
|
||||
"room_id": "19:abc123@thread.v2",
|
||||
"created_at": "2025-08-07T01:20:46.846Z",
|
||||
"updated_at": "2025-08-07T01:52:12.000Z"
|
||||
}
|
||||
],
|
||||
"current_page": 1,
|
||||
"per_page": 10,
|
||||
"total": 1
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue