Get message history

Updated

Retrieves historical messages from a specified channel.

GET
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

appIdstring
Required

The App ID of your Agora project.

userIdstring
Required

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.

channelTypestring
Required

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

channelNamestring
Required

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

startinteger

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

endinteger

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

messageCountinteger

The 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.

errorCodeinteger

The status code of the request. 200 indicates success.

errorboolean

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

requestIdstring

The unique ID associated with the request.

operationstring

The specific operation performed by the request.

reasonstring

A short explanation of the reason for the error.

timestampinteger

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.

dataobject

The response payload.

The response payload. Contains the following fields:

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