# Topic views doesn't update on rest API requests

**URL:** https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474
**Category:** Feature
**Tags:** rest-api
**Created:** [December 19, 2024, 9:56pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474 "2024-12-19T21:56:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jandres](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jandres/32/130933_2.png) [@jandres](https://meta.discourse.org/u/jandres)
#### Post date: [December 19, 2024, 9:56pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/1 "2024-12-19T21:56:05Z")

</div>

In last Version 3.4.0.beta4-dev I noted that topic views doesn’t update when using rest API requests. Even putting headers like`Discourse-Visible, X-Requested-With` or even more

> ‘Discourse-Visible’: ‘true’,  
> ‘Discourse-Logged-In’ : ‘true’,  
> ‘Discourse-Present’: ‘true’,  
> ‘Discourse-Track-View’: ‘true’,  
> ‘Discourse-Track-View-Topic-Id’: 2214

I don’t know if this is a bug or is something that is programmed like that. But in previous version this behaviour didn’t happen

I would be very grateful if you could help me with this issue.

Thank you very much

---

<div class="post-metadata">

### Author: ![jandres](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jandres/32/130933_2.png) [@jandres](https://meta.discourse.org/u/jandres)
#### Post date: [March 24, 2025, 8:46pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/2 "2025-03-24T20:46:38Z")

</div>

Is this something that just happening to me ?

I would really appreciate any help you can give me with this problem. I’ve tried several things without success. I think I’ve set all the possible headers I’ve seen in the reverse engineering I’ve done, and the views still aren’t updating. I think there must be a header I’m missing.

By the way I’m using admin API keys instead of User api keys. I hope this is not a problem

Thank you very much

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 24, 2025, 10:24pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/3 "2025-03-24T22:24:19Z")

</div>

API requests don’t track views, unconditionally, by design.

> <https://github.com/discourse/discourse/blob/e6c390eb1ddd71bed38a277fd74363685b30a244/lib/middleware/request_tracker.rb#L85-L165>

I guess you are after some feature request here to allow you to track views via our API, recategorizing.

---

<div class="post-metadata">

### Author: ![jandres](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jandres/32/130933_2.png) [@jandres](https://meta.discourse.org/u/jandres)
#### Post date: [March 25, 2025, 2:24pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/4 "2025-03-25T14:24:20Z")

</div>

hmmm 🤔  
Thank you @sam but I wonder why before 3.4.0.beta-4 version it did it ?

> [@Request from API doesn't update User#last\_seen\_at](https://meta.discourse.org/t/request-from-api-doesnt-update-user-last-seen-at/108528/10):
>
> You can now set DISCOURSE\_VISIBLE=“true” on API requests, and Discourse will update the last\_seen time for the user [https://github.com/discourse/discourse/commit/af86cf46dc003f19ba52f71826f057884f1119ba](https://github.com/discourse/discourse/commit/af86cf46dc003f19ba52f71826f057884f1119ba)

also if User::last\_seen\_at is updated why not the views ?

When you say a feature it means a plugin that allow me to track views via API ?

Thank you again

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 12, 2025, 2:42am UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/5 "2025-05-12T02:42:52Z")

</div>

> [@Request from API doesn't update User#last\_seen\_at](https://meta.discourse.org/t/request-from-api-doesnt-update-user-last-seen-at/108528/10):
>
> You can now set DISCOURSE\_VISIBLE=“true” on API requests

@david can you clarify here, is there a change missing from request tracker?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [May 12, 2025, 9:27am UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/6 "2025-05-12T09:27:01Z")

</div>

Topic views have been migrated to use our “browser pageviews” system. That means that they no longer include any kind of API or crawler requests.

The DISCOURSE\_VISIBLE header relates only to the legacy pageviews system.

---

<div class="post-metadata">

### Author: ![Nima1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nima1/32/299628_2.png) [@Nima1](https://meta.discourse.org/u/Nima1)
#### Post date: [November 16, 2025, 7:25am UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/8 "2025-11-16T07:25:46Z")

</div>

If you need API traffic (mobile apps, integrations, etc.) to count as topic views, I’ve published a small plugin that does exactly that:

🔗 **api-topic-views**  
[https://github.com/gorfist/api-topic-views](https://github.com/gorfist/api-topic-views)

It hooks into `TopicsController#show` and counts eligible API/User API requests as topic views, with options for custom headers, rate limiting, crawler filtering, and user-aware tracking.

It’s still new and not fully battle-tested yet, but it should work well for most self-hosted setups. Feedback or PRs are very welcome!

---

<div class="post-metadata">

### Author: ![jandres](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jandres/32/130933_2.png) [@jandres](https://meta.discourse.org/u/jandres)
#### Post date: [November 17, 2025, 3:30pm UTC](https://meta.discourse.org/t/topic-views-doesnt-update-on-rest-api-requests/343474/9 "2025-11-17T15:30:45Z")

</div>

Wow big thank you 👍 @Nima1  
I am going to to test it, and I would leave you my feedbacks.
