Get message history
Get message history
https://api.sd-rtn.com/rtm/v2/history/{:appId}/userId/{:userId}/channelType/{:channelType}/channel/{:channelName}Retrieves historical messages from the specified channel.
Request
Path parameters
The App ID of your Agora project.
The user ID for the operation.
- 26 lowercase English letters:
a–z - 26 uppercase English letters:
A–Z - 10 numbers:
0–9 - Space
- Special characters:
!,#,$,%,&,(,),+,-,:,;,<,=,.,>,?,@,[,],^,_,{,},|,~
Character length must be between 1 and 64.
The type of channel to retrieve messages from.
message: Message channeluser: User channel
The name of the channel.
- 26 lowercase English letters:
a–z - 26 uppercase English letters:
A–Z - 10 numbers:
0–9 - Space
- Special characters:
!,#,$,%,&,(,),+,-,:,;,<,=,.,>,?,@,[,],^,_,{,},|,~
Character length must be between 1 and 64.
The start timestamp of the historical message query. Defaults to 0 if not specified.
The end timestamp of the historical message query. Defaults to 0 if not specified.
The maximum number of messages to return in a single query. The value must be in the range (0, 100]. Defaults to 100 if not specified.
Response
-
If the returned status code is
200, the request was successful. The response body contains the result of the request.OK
- errorCode number
The status code of the request. A value of
200indicates success. - error boolean
Indicates whether the request failed.
false: The request succeeded.true: The request failed.
- requestId string
The unique ID associated with the request.
- operation string
The specific operation performed by the request.
- reason string
A short explanation of the reason for the error.
- timestamp number
The time the request was sent, represented as a Unix timestamp in milliseconds.
- data object
The response payload. Contains the following fields:
Show propertiesHide properties
- messageList object
An array of message objects. Each object includes:
Show propertiesHide properties
- messageType string
The type of message content:
STRING: Use themessagefield directly.BINARY: The message is base64-encoded in themessagefield.
- message string
The content of the message.
- customType string
The custom message type.
- publisher string
The user ID of the message sender.
- timestamp number
The time the message was sent, as a Unix timestamp.
- count number
The total number of messages retrieved.
- newStart number
The start timestamp for the next batch of messages.
-
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.