# API To Retrieve Unread Count For More Then One Room At A Time

**URL:** <https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427>\
**Category:** Feature Requests (historic archive)\
**Created:** [November 9, 2018, 8:17pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427 "2018-11-09T20:17:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidLevi](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/davidlevi/32/678_2.png) [@davidLevi](https://forums.rocket.chat/u/davidLevi)\
**Post date:** [November 9, 2018, 8:17pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/1 "2018-11-09T20:17:28Z")

</div>

I’ve seen this feature, or similar, requested in a lot of places, but for some reason they keep getting closed and pointed elsewhere stating that it is achievable via various methods. After some thorough investigation it _seems_ that there is no easy way to do this without creating multiple requests.

Scenario: I want to show a list of all the DMs for a given user and have a notification icon if the DM has unread messages.

For now I need to call:  
**/dm.list** : once  
**/dm.counters** : for each DM returned, so if a user has 10 DMs open, thats 10 additional API requests that need to be handled. I’m sure you can see how this can get out of hand very quickly.

I tried using the **lastMessage** feature in **/dm.list** , but there is no way to indicate if the message is unread or not.

I’m not sure what the solution is, but possibly one of the following.

- In the API Request **/dm.list** and an unread counter for each dm returned (Optimal)
- In the API Request **/dm.counters** , allow us to retrieve counters via **array of roomIds** , and _not just one_ (Most Viable)
- In the API Request **/dm.list** with adding **lastMessage** , indicate weather the message is unread or not. (Will get the job done)

Maybe I’m doing it wrong, but if this is in fact unachievable right now, I believe it to be a vital part of the REST API

Thanks,

---

<div class="post-metadata">

**Author:** ![bradley.hilton](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/bradley.hilton/32/30_2.png) [@bradley.hilton](https://forums.rocket.chat/u/bradley.hilton)\
**Post date:** [November 29, 2018, 5:35am UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/2 "2018-11-29T05:35:08Z")

</div>

What you actually want to do is use the subscriptions api. As each user has a subscription to the rooms which they are part of, thus all of the unread information resides on that user’s subscription object for a particular room.

[https://rocket.chat/docs/developer-guides/rest-api/subscriptions/get/](https://rocket.chat/docs/developer-guides/rest-api/subscriptions/get/)

---

<div class="post-metadata">

**Author:** ![reyalpsirc](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@reyalpsirc](https://forums.rocket.chat/u/reyalpsirc)\
**Post date:** [December 3, 2018, 12:52pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/4 "2018-12-03T12:52:22Z")

</div>

@bradley.hilton I just tried the subscription.get method but it doesn’t seem to be working well…  
All I noticed is that if an user added a message to a channel of another user, the unread would not change but, if the user mentions the other one, the **unread and userMentions** would both change…

How can we get the non mentioned unread messages?

---

<div class="post-metadata">

**Author:** ![bradley.hilton](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/bradley.hilton/32/30_2.png) [@bradley.hilton](https://forums.rocket.chat/u/bradley.hilton)\
**Post date:** [December 5, 2018, 3:24pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/5 "2018-12-05T15:24:21Z")

</div>

Great question, either @rodrigo.nascimento or @diego.sampaio should be able to help you with that.

---

<div class="post-metadata">

**Author:** ![reyalpsirc](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@reyalpsirc](https://forums.rocket.chat/u/reyalpsirc)\
**Post date:** [December 5, 2018, 4:34pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/6 "2018-12-05T16:34:49Z")

</div>

I also noticed [this issue on Github](https://github.com/RocketChat/Rocket.Chat/issues/10592) but it is closed and only says that was resolved on the chat (but does not say how)

---

<div class="post-metadata">

**Author:** ![reyalpsirc](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@reyalpsirc](https://forums.rocket.chat/u/reyalpsirc)\
**Post date:** [December 5, 2018, 4:56pm UTC](https://forums.rocket.chat/t/api-to-retrieve-unread-count-for-more-then-one-room-at-a-time/2427/7 "2018-12-05T16:56:00Z")

</div>

Thanks to @diego.sampaio, I just found out that the unreads count is controlled through the Administration on General =\> Unread Count 🙂
