Fetches the messages list.
Iterating through List Messages API:
Sample API endpoint for fetching messages after a particular timestamp -
/messages?limit=1000&fromTimestamp=1679434430&affix=appendThe endpoint mentioned above would return 1K messages starting from the mentioned timestamp in fromTimestamp.
In the API response, there would be a meta object nested with previous, current, and next properties.
You have to fetch the value of sentAt property from next object and pass it to the query parameter (fromTimestamp) for the next iteration.
"next": {
"affix": "append",
"sentAt": 1679493319,
"fromTimestamp": "1679434430",
"id": "1001273"
}
/messages?limit=1000&fromTimestamp=1679493319&affix=append
The above query parameter would fetch the next page.Further customizations can be made in the request with the help of query parameters:
-> Fetching all messages of a particular conversation (conversationId=user)
-> Fetching messages based on receiverType (receiverType=<user_or_group>)-> Fetching messages based on category (category=message)
-> Fetching messages based on types (type=text)
-> Fetching messages based on tags (tag=<tag_to_be_searched>)
-> Fetching only deleted messages (onlyDeleted=1)
-> Fetching all messages except deleted ones (hideDeleted=1)
-> Fetching all messages starting from a particular timestamp (fromTimestamp=<unix_timestamp>)
-> Fetching all message till a particular timestamp (toTimestamp=<unix_timestamp>)Few properties also support multi-valued filter:
-> /messages?categories=message,custom
-> /messages?types=text,file
-> /messages?tags=tag1,tag2
For more details please visit here
By default, the searchKey is searched only in message text. However, if you enable Conversation & Advanced Search feature, the searchKey will be searched in message text, file name, mentions & mime type of the file.
The Conversation & Advanced Search feature is only available in Advanced & Custom plans. If you're already on one of these plans, please enable the Conversation & Advanced Search feature from CometChat Dashboard (Open your app, navigate to Chats -> Settings -> General Configuration)
Feature | Basic Search | Advanced Search |
---|---|---|
Text search | ✅ | ✅ |
File name search | ❌ | ✅ |
Mentions search | ❌ | ✅ |
Mime type search | ❌ | ✅ |
Attachments | ❌ | ✅ |
Links | ❌ | ✅ |
Reactions | ❌ | ✅ |
Mentions | ❌ | ✅ |
Mentioned Uids | ❌ | ✅ |