Recent chats

To retreive the users recent chat data you can use the below API.

info

{api-base-url} can be obtained from the MirrorFly console.

HTTP request#

curl -X GET "https://{api-base-url}/api/v1/chat/recent?messageTime=xxxx&byTopic=true&topicId=xxxx&exclude=xxxx&page=1&size=10"
-H "accept: */*"
-H "Authorization: :AuthToken"

Request Params#

ParamDataTypeRequiredDescription
messageTimeLongNoIf messageTime is provided, the API will fetch chats after the given epoch timestamp else fetches most recent chats in desc order
byTopicBooleanNoFlag to enable topic based search default value is false
topicIdStringNoTopicId to filter the record
excludeArray of StringNoTo exclude specific types of messages Eg: exclude = notification
pageNumberNoPage number to get the particular page data default value is 1
sizeNumberNoNumber of chats per page default value is 10

Note : Topics can be created from here Create Topic

Responses#

If successful, this action returns recent chats list in the response body.

{
"status": 200,
"data": {
"chatList": [
{
"chatType": "samplechattype", // String - Possible values are singlechat, groupchat
"messageType": "samplemessagetype", // String - Message type such as text, image, file, audio, video, contact, location, notification
"messageId": "xxxxxx", // String - Unique id of this message - auto genereted
"message": "samplemessage", // String - Actual message text or notification code
"sentTime": "dd/mm/yyyy hh:mm:ss", // String - Message sent time
"epochTimestamp": 0, // Number - sentTime as epoch timestamp
"deliveryStatus": 0, // Number - Message delivery status
"archiveStatus": 0, // Number - Message archive status
"fromUser": "99xxxxxx22", // String - Sender userid
"fromUserName": "sampleusername", // String - Sender nickname
"fromUserImage": "sampleimage", // String - Sender image
"fromUserThumbImage": "samplethumbimage", // String - Sender thumbimage
"toUser": "99xxxxxx00", // String - Receiver userid
"toUserName": "sampleusername", // String - Receiver nickname
"toUserImage": "receiedImsage", // String - Receiver image
"toUserThumbImage": "receivedThumImage", // String - Receiver thumbimage
"participant": "99xxxxxx00", // String - Participant userid or groupid of chat
"participantName": "samplename", // String - Participant nickname
"participantImage":"", // String - Participant image
"participantThumbImage":"", // String - Participant thumbimage
"jid": "99xxxxxx11", // String - Jid of the logged-in user
"adminBlocked": 0, // Number - participant block status
"recallStatus": 0, // Number - If the message deleted for all
"unread": 0, // Number - unread messages count
"media":{
"androidHeight": 0, // Number - android height
"androidWidth": 0, // Number - android width
"audioType": "", // String - audio file upload or recording
"caption": "", // String - caption for uploaded video
"duration": 0, // Number - duration of audio or video
"fileKey": "", // String - key to encrypt/decrypt for uploaded file
"fileName": "samplefilename", // String - name of the uploaded file
"fileSize": 0, // Number - uploaded file size
"fileUrl": "xxxxxx", // String - token of the uploaded file to cloud
"isDownloaded": 0,// Number - isDownloaded
"isUploading": 0,// Number - isUploading
"localPath": "",// String - localPath
"msgId": "xxxxxx", // String - Unique id of this message
"originalHeight": 0, // Number - original height
"originalWidth": 0, // Number - original width
"thumbImage": "sampleImage",// String - uploaded image/video thumb image
"webHeight": 0, // Number - web height
"webWidth": 0, // Number - web height
"isLargeFile": false // Boolean - large file or not
},
"location": {
"latitude": "",// String - location latitude
"longitude": "",// String - location longitude
"mid": "",// String - mid
"locationResolvedKey": ""// String - locationResolvedKey
},
"contact": {
"contactResolvedKey": "",// String - contactResolvedKey
"mid": "",// String - mid
"name": "samplename",// String - contact name
"phoneNumber": [
"99xxxxxx11"// String - contact number
]
},
"mentionedUsersIds": [
"99xxxxxx00" // String - mentioned users, applicable to group chat only
],
"id": 0, //Number - unique id for this record
"messageTime": 0, // Number - sentTime as epoch timestamp
"topicId": "xxxxxx" // String - topicId
}
],
"totalPages": 1, // Number - Total pages based on the size
"totalRecords": 1 // Number - Total chats for the logged-in user
},
"message": "Data retrieved successfully"
}

Error#

In the case of an error, an error object like below is returned.

When the token passed in Headers is expired

{
"status": 401,
"message": "Token Expired"
}

In the case of a Bad Request, an error message is returned

{
"status": 400,
"message": "Error Message"
}