Get message history
Updated
Retrieves historical messages from a specified channel.
https://api.agora.io/dev/v2/project/rtm/v2/history/{appId}/userId/{userId}/channelType/{channelType}/channel/{channelName}Retrieves historical messages from the specified channel.
Path Parameters
appIdstringThe App ID of your Agora project.
userIdstringThe user ID for the operation.
- 26 lowercase English letters: a-z
- 26 uppercase English letters: A-Z
- 10 numbers: 0-9
- Space
- Special characters: !, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~
Caution
Character length must be between 1 and 64.
channelTypestringThe type of channel to retrieve messages from. message for a message channel, user for a user channel.
channelNamestringThe name of the channel.
- 26 lowercase English letters: a-z
- 26 uppercase English letters: A-Z
- 10 numbers: 0-9
- Space
- Special characters: !, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~
Caution
Character length must be between 1 and 64.
Query Parameters
startintegerThe start timestamp of the historical message query. Defaults to 0 if not specified.
endintegerThe end timestamp of the historical message query. Defaults to 0 if not specified.
messageCountintegerThe maximum number of messages to return in a single query. The value must be in the range (0, 100]. Defaults to 100.
Response
-
If the returned status code is
200, the request was successful. The response body contains the result of the request. -
If the returned status code is not
200, the request failed. The response body includes the error code and description. Refer to status codes to understand the possible reasons for failure.
Response Body
The request was successful. The response body contains the result of the request.
errorCodeintegerThe status code of the request. 200 indicates success.
errorbooleanIndicates whether the request failed. false if it succeeded, true if it failed.
requestIdstringThe unique ID associated with the request.
operationstringThe specific operation performed by the request.
reasonstringA short explanation of the reason for the error.
timestampintegerThe time the request was sent, as a Unix timestamp in milliseconds.
The time the request was sent, represented as a Unix timestamp in milliseconds.
dataobjectThe response payload.
The response payload. Contains the following fields:
messageListarray<object>An array of message objects.
messageTypestringThe type of message content. STRING uses the message field directly; BINARY is base64-encoded in the message field.
messagestringThe content of the message.
customTypestringThe custom message type.
publisherstringThe user ID of the message sender.
timestampintegerThe time the message was sent, as a Unix timestamp.
countintegerThe total number of messages retrieved.
newStartintegerThe start timestamp for the next batch of messages.
Request examples
curl -L 'https://api.sd-rtn.com/rtm/v2/history/{appId}/userId/Tony/channelType/message/channel/chatroom?start=17809876 & end = 1781000 & messageCount = 100' \ -H 'Accept: application/json'Response example
{ "errorCode": 200, "error": false, "requestId": "1121_1234231", "operation": "getMessage", "reason": "", "timestamp": 1234567, "data": { "messageList": [ { "messageType": "STRING", "message": "Hello, how are you?", "customType": "text", "publisher": "Tony", "timestamp": 1234567890 } ], "count": 1, "newStart": 1234567892 }}