I am trying to get post counts from the discourse API via the /directory_items.json 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.
Not a bug. If you reverse engineer our Discourse API 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.