# How to get unread notification / topic count via API?

**URL:** <https://meta.discourse.org/t/how-to-get-unread-notification-topic-count-via-api/113927>\
**Category:** Product Support\
**Created:** [10 באפריל,‏ 2019,‏ 6:37am UTC](https://meta.discourse.org/t/how-to-get-unread-notification-topic-count-via-api/113927 "2019-04-10T06:37:50Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Uninen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uninen/32/66432_2.png) [@Uninen](https://meta.discourse.org/u/Uninen)\
**Post date:** [10 באפריל,‏ 2019,‏ 6:37am UTC](https://meta.discourse.org/t/how-to-get-unread-notification-topic-count-via-api/113927/1 "2019-04-10T06:37:50Z")

</div>

I’m running a self-hosted Discourse instance running on pretty basic Docker installation. The forum runs on a subdomain of my main site and it uses main site as SSO host. I’d like to encourage traffic between the main site and forum by showing some kind of unread forum notifications/topics number for a given user on the main site. Problem is, I haven’t figured a good way to get the data.

I tried relaxing same site cookies setting to disabled, but if I query for example `/notifications.json?recent=true` with JavaScript from the main site (when logged in on the forum), I still get `not_logged_in` error. The query works fine from browser window (when logged in).

Is there a way to change the Discourse session cookie for the top-level domain, or some other way I could query this data?

There is also possibility to query this from the backend with a Python script and API key if it helps. In any case I would still need at least a semi-decent way of syncing this data so if a user sees 10 notifications on the main site, then goes to the forum and reads/resets them, she should see the updated number on the main site, too.

I just realised that notifications are totally different than unread/new topics. Preferably I would show both for the users on the main site. Say Alice has 2 new topics, 3 unread posts and 2 unread notifications. I’d preferably show a number “7” on the main site notification tab (like on Facebook, for example)

Any tips or ideas would be appreciated 🙂

---

_[View the full topic](https://meta.discourse.org/t/how-to-get-unread-notification-topic-count-via-api/113927)._
