# /directory\_items.json API returns wrong link for next page

**URL:** https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268
**Category:** Support
**Created:** [03.Сентябрь.2018 13:03:26 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268 "2018-09-03T13:03:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cebe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cebe/32/119560_2.png) [@cebe](https://meta.discourse.org/u/cebe)
#### Post date: [03.Сентябрь.2018 13:03:26 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268/1 "2018-09-03T13:03:26Z")

</div>

I am trying to get post counts from the discourse API via the [/directory\_items.json](https://docs.discourse.org/#tag/Users%2Fpaths%2F~1directory_items.json%3Fperiod%3D%7Bperiod%7D%26order%3D%7Border%7D%2Fget) endpoint.

The API returns a URL for retrieving the next page of items, however the URL I see is `/directory_items?order=post_count&page=1&period=all` while I expected the URL to include the `.json` extension: `/directory_items.json?order=post_count&page=1&period=all`.

As far as I see this is a bug, the API should return the URL for the next page for the format which I am currently using in the API request (json) and not the URL for the HTML page.

I am currently using discourse v2.1.0.beta5.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [03.Сентябрь.2018 19:28:38 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268/2 "2018-09-03T19:28:38Z")

</div>

Not a bug. If you [reverse engineer our Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) then you can find that we use extensionless endpoints in many places. If you add the `Accept: application/json` header in your requests then we will treat both `/directory_items` and `/directory_items.json` endpoints in same manner.

---

<div class="post-metadata">

### Author: ![cebe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cebe/32/119560_2.png) [@cebe](https://meta.discourse.org/u/cebe)
#### Post date: [04.Сентябрь.2018 07:37:58 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268/3 "2018-09-04T07:37:58Z")

</div>

Aha that makes sense, thanks. This clearly needs to be documented, will see if I can improve the docs about it.

---

<div class="post-metadata">

### Author: ![cebe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cebe/32/119560_2.png) [@cebe](https://meta.discourse.org/u/cebe)
#### Post date: [05.Сентябрь.2018 14:30:05 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268/4 "2018-09-05T14:30:05Z")

</div>

[https://github.com/discourse/discourse\_api\_docs/pull/16](https://github.com/discourse/discourse_api_docs/pull/16)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [05.Октябрь.2018 14:38:29 UTC](https://meta.discourse.org/t/directory-items-json-api-returns-wrong-link-for-next-page/96268/5 "2018-10-05T14:38:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
