Pagination of Unread messages of a user group channels

How to fetch a unread messages of the group channels of a user with limit and offset?

Can someone post a api query how it can be done?

Thanks in Advance.

Hi @BCH - thank you for reaching out to Sendbird!

Are you looking to retrieve the messages that the specific user has not read or the messages sent by the user that are unread?

Seems like you are looking for previous message query. It doesn’t have a filter to fetch the unread messages only.

Understanding your use case will help suggest other solutions. Are you open to using Platform API or JS SDK only?

1 Like

Hi @taha.saghir ,

Thanks for your response.

Our use case is One user is part of multiple group channels and has unread messages from other users in the group channels.

Lets a User A is part of 100 group channels and has messages sent by other users in all hundred group channels.

I want to query using send bird platform api to pull the unread message count from the group channels.

Want pull first 20 group channels which has highest unread messages and pull the next 20 when the user moves from the page to page.

We are using this GET https://api-{application_id}{user_id}/my_group_channels?limit=20&query_type=OR&unread_filter=unread_message"

how to fetch the next 20?

Let me know if any other info is needed

Hi @BCH,

Please refer to the next property in the service response.

The value that can be used in the token parameter to retrieve the next page in the result set.

Thanks @taha.saghir … I will verify it

Hi @taha.saghir ,

I have checked the api and working fine.


is working to move forward.

Lets say I fetch 10 per page, after fetching next 10 - how should I go back to fetch first 10 again?

You can do that by removing the token param or leaving it blank.

Thanks @taha.saghir … What I meant was is there anything like before parameter like next .

I think we need to store the next value for every fetch query, before and after need to be fetched based on that.

One more question - Is there any api that I can make the Mark all messages read in the channel for a user?

Hi @BCH - there is no API level iterator to go back, you will have to manage it on your end.

Here is the API to mark all messages read.

Thank you for your responses @taha.saghir . This info is really helpful.

Hi @taha.saghir ,

Hopefully this is my last doubt in this thread. :slightly_smiling_face:

How to sort by the unread messages descending order in the my_group_channels api ?

Anytime @BCH, here to help!

my_group_channels API is to list the channels. To get the message, use the list messages API. Please refer to the reverse parameter.

Hi @taha.saghir ,

Thanks for your response.

To get the message, use the list messages API. Please refer to the reverse parameter.

  1. Here the url is expecting channelurl but i want the unread messages of all the channels that user is part of and in unread count descending order.

  2. Here is the API to mark all messages read. How many channel_urls i can pass in the request body?

Hi @BCH – sorry for the delay in getting back to you.

Here are the responses:

  1. There is no such API. It will require customization on your end to get the consolidated list of unread messages that you need. Please review the unread items APIs, if these could be of any help to you.
  2. Technically, there is no limit to the number of URLs you can pass. You may get hit by the http request body character limit – that I’m not sure if there is any.

Thank you for your response @taha.saghir