Get message history

Updated

Retrieves historical messages from a specified channel.

gethttps://api.sd-rtn.com/rtm/v2/history/{appId}/userId/{userId}/channelType/{channelType}/channel/{channelName}

Retrieves historical messages from the specified channel.

Path Parameters

appId#*string

The App ID of your Agora project.

userId#*string

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: !, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~

Caution

Character length must be between 1 and 64.

channelType#*string

The type of channel to retrieve messages from. message for a message channel, user for a user channel.

Allowedmessage | user
channelName#*string

The 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

start#?integer

The start timestamp of the historical message query. Defaults to 0 if not specified.

Default0Formatint64
end#?integer

The end timestamp of the historical message query. Defaults to 0 if not specified.

Default0Formatint64
messageCount#?integer

The maximum number of messages to return in a single query. The value must be in the range (0, 100]. Defaults to 100.

Default100Formatint32Range(0, 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

application/json

Response schema

200application/json

The request was successful. The response body contains the result of the request.

errorCode#optionalinteger

The status code of the request. 200 indicates success.

error#optionalboolean

Indicates whether the request failed. false if it succeeded, true if it failed.

requestId#optionalstring

The unique ID associated with the request.

operation#optionalstring

The specific operation performed by the request.

reason#optionalstring

A short explanation of the reason for the error.

timestamp#optionalinteger

The time the request was sent, as a Unix timestamp in milliseconds.

The time the request was sent, represented as a Unix timestamp in milliseconds.

data#optionalobject

The response payload.

The response payload. Contains the following fields:

defaultapplication/json

The request failed. The response body includes the error code and description.

Authorization

This endpoint requires authentication.

basicAuth

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  }}
Empty