curl -X POST "http://localhost:5001/channel/messagesync" \
-H "Content-Type: application/json" \
-d '{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}'
const response = await fetch('http://localhost:5001/channel/messagesync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
login_uid: 'user123',
channel_id: 'group123',
channel_type: 2,
start_message_seq: 1000,
end_message_seq: 1100,
limit: 50,
pull_mode: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}
response = requests.post('http://localhost:5001/channel/messagesync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/messagesync",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result []map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
[
{
"message_id": 123456789,
"message_seq": 1001,
"client_msg_no": "client_msg_123",
"from_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
},
{
"message_id": 123456790,
"message_seq": 1002,
"client_msg_no": "client_msg_124",
"from_uid": "user456",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995260,
"payload": "SGkgdGhlcmU="
}
]
Message Management
Sync Channel Messages
Sync historical messages from a specified channel
POST
/
channel
/
messagesync
curl -X POST "http://localhost:5001/channel/messagesync" \
-H "Content-Type: application/json" \
-d '{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}'
const response = await fetch('http://localhost:5001/channel/messagesync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
login_uid: 'user123',
channel_id: 'group123',
channel_type: 2,
start_message_seq: 1000,
end_message_seq: 1100,
limit: 50,
pull_mode: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}
response = requests.post('http://localhost:5001/channel/messagesync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/messagesync",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result []map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
[
{
"message_id": 123456789,
"message_seq": 1001,
"client_msg_no": "client_msg_123",
"from_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
},
{
"message_id": 123456790,
"message_seq": 1002,
"client_msg_no": "client_msg_124",
"from_uid": "user456",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995260,
"payload": "SGkgdGhlcmU="
}
]
Overview
Sync messages from a specified channel, supporting message retrieval by sequence number range.Request Body
Required Parameters
string
required
Current logged-in user ID
string
required
Channel ID
integer
required
Channel type (1=personal channel, 2=group channel)
Optional Parameters
integer
Starting message sequence number (inclusive)
integer
Ending message sequence number (exclusive)
integer
Maximum number of messages to return, maximum 10000
integer
Pull mode (0=pull down, 1=pull up)
curl -X POST "http://localhost:5001/channel/messagesync" \
-H "Content-Type: application/json" \
-d '{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}'
const response = await fetch('http://localhost:5001/channel/messagesync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
login_uid: 'user123',
channel_id: 'group123',
channel_type: 2,
start_message_seq: 1000,
end_message_seq: 1100,
limit: 50,
pull_mode: 0
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0
}
response = requests.post('http://localhost:5001/channel/messagesync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"login_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"start_message_seq": 1000,
"end_message_seq": 1100,
"limit": 50,
"pull_mode": 0,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/messagesync",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result []map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
[
{
"message_id": 123456789,
"message_seq": 1001,
"client_msg_no": "client_msg_123",
"from_uid": "user123",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
},
{
"message_id": 123456790,
"message_seq": 1002,
"client_msg_no": "client_msg_124",
"from_uid": "user456",
"channel_id": "group123",
"channel_type": 2,
"timestamp": 1640995260,
"payload": "SGkgdGhlcmU="
}
]
Response Fields
The response is an array of message objects, each containing:integer
required
Message ID
integer
required
Message sequence number
string
required
Client message number
string
required
Sender user ID
string
required
Channel ID
integer
required
Channel type
integer
required
Message timestamp
string
required
Base64 encoded message content
Status Codes
| Status Code | Description |
|---|---|
| 200 | Message sync successful |
| 400 | Request parameter error |
| 403 | No access permission |
| 500 | Internal server error |
Use Cases
Chat History Loading
Load Recent Messages:// Load last 50 messages
const messages = await syncChannelMessages({
login_uid: "user123",
channel_id: "group123",
channel_type: 2,
limit: 50,
pull_mode: 0
});
// Load messages before a specific sequence
const olderMessages = await syncChannelMessages({
login_uid: "user123",
channel_id: "group123",
channel_type: 2,
end_message_seq: 1000,
limit: 50,
pull_mode: 1
});
Message Search and Export
Export Chat History:async function exportChatHistory(channelId, channelType, loginUid) {
let allMessages = [];
let startSeq = 0;
const batchSize = 1000;
while (true) {
const messages = await syncChannelMessages({
login_uid: loginUid,
channel_id: channelId,
channel_type: channelType,
start_message_seq: startSeq,
limit: batchSize,
pull_mode: 0
});
if (messages.length === 0) break;
allMessages = allMessages.concat(messages);
startSeq = messages[messages.length - 1].message_seq + 1;
}
return allMessages;
}
Offline Message Sync
Sync Missed Messages:async function syncMissedMessages(channelId, channelType, loginUid, lastSeq) {
const missedMessages = await syncChannelMessages({
login_uid: loginUid,
channel_id: channelId,
channel_type: channelType,
start_message_seq: lastSeq + 1,
limit: 1000,
pull_mode: 0
});
return missedMessages;
}
Best Practices
- Reasonable Range: Avoid syncing too many messages at once
- Pagination: Use limit parameter to control return quantity
- Error Handling: Handle network errors and permission errors
- Caching Strategy: Reasonably cache synced messages
- Performance Optimization: Adjust sync frequency based on actual needs
- Permission Check: Verify user has access to the channel before syncing
- Rate Limiting: Implement rate limiting to prevent excessive API calls

