# 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:** Support
**Created:** [April 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:** 12

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [April 10, 2019, 5:48pm UTC](https://meta.discourse.org/t/how-to-get-unread-notification-topic-count-via-api/113927/12 "2019-04-10T17:48:31Z")

</div>

> [@Uninen](#):
>
> how does one fetch the necessary data (using the api? which endpoints? what kind of api key / authentication we need?)

Using the API.

The endpoint `https://example.com/notifications?username=Falco` which can be discovered using [Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) and navigating to a user profile Notification page.

You will need to pass an Admin API Key to be able to query notifications from any user.

> [@Uninen](#):
>
> what would be a smart way of doing these queries (in realtime? periodically?) and how would the updating/dismissing work if we store something in cache or db.

Depends on your app.

A good default is:

- When you are rendering a new page in your main app, you will know your current user.

- Translate your app user id to a Discourse user id (and cache this for a long period)

- Query the notifications endpoint in Discourse (cache for a short period)

- Render your app page with the Discourse Notifications

For Dismissing, a click to dismiss will need to hit your backend and then you issue a `PUT` to `https:/example.com/notifications/mark-read`. That needs to clear your app notifications cache for the user.

Advanced stuff would include listening to new notifications in a Discourse plugin (or a PR to core that adds a Notification webhook. That would allow your main app to keep an websocket or server-sent events and update notifications in real time.

---

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