Skip to main content

Overview

Queries message history in the same way as the client history API. Use this API from your application server to retrieve a specified user's message history in a specified conversation.

Request

Authentication: Add authentication headers to the request. See Authentication.

Method GET

Rate limit 100 requests/second

Endpoint https://API domain/apigateway/hismsgs/query

Content-Type application/json

Request Parameters

ParameterData TypeRequiredDescription
from_idstringNoFor a private chat, the ID of one participant. Maximum length: 32 characters.
target_idstringYesFor a private chat, the ID of the other participant; for a group chat, the group ID. Maximum length: 32 characters.
channel_typeintYesConversation type. 1: private chat; 2: group chat.
startintYesStarting timestamp for the message history query.
countintNoNumber of records per page. Default: 20. Maximum: 50.
orderintNoQuery order. 0: descending by time (default); 1: ascending by time.

Request Example

GET /apigateway/hismsgs/query?from_id=xxx&target_id=xxx&channel_type=1&start=xxxx&count=xx HTTP/1.1
appkey: appkey
signature: 2e639ae3600a4sdff61fb88b76f485b
nonce: nonce
timestamp: 1672568121910
Content-Type: application/json

Response Example

{
"code":0,
"msg":"sucess",
"data":{
"msgs":[
{
"sender_id":"xxx",
"receiver_id":"xxx",
"channel_type":1,
"msg_id":"xxxxx",
"msg_time":1321122121223,
"msg_type":"xxx",
"msg_content":"xxxxxx"
}
],
"is_finished":false
}
}