JSON API, get topics sorted by created_at


#1

Hi

I am developing a blog-like interface for a private Discourse deployment based on the JSON API from Discourse. The idea is simple: the owner of the Discourse is the only one that can post questions in a certain category. This category will be used as a base for the posts in the blog.

The problem is, I can’t figure out how to get the topics sorted by created_at. /latest.json is almost there, however it sorts by last_posted_at, so if I made a blog based on latest.json the top posts would be the post last commented by an user, not the more traditional most recent created post.

Btw, the Discourse API documentation seems to be really outdated, since I discovered for example that passing /latest.json?page=1 allow me to see the next 30 topics (each call from the API gives at most 30 topics and this does not seem to be documented anywhere).


(Blake Erickson) #2

Nice! I like this idea. I played around with a blog layout in the past. Mostly I just modified the css to hide certain features I didn’t need or wanted other users to see.

I’ll look into this, but not sure if an existing route exists off the top of my head.

I’m currently working on updating the api docs. It will be done soon(ish) ;):two_hearts:


#3

Hi @blake, thanks to the fast answers!

This would be an option too, however in this case I would still have the problem of the user bumping posts to the top when answering right? Or is there a way in Discourse itself to force posts sorted by created_at?

Well, the other option would be to created a small server side application and sort the posts there, however this would be a uglier solution. The other option we’re thinking is to use a blog application and use Discourse only for comments, however the client would like to use Discourse itself to post new topics because he likes the interface.


(Blake Erickson) #4

Yes. You would still have this issue.


(Dave McClure) #5

Does this do what you need? https://meta.discourse.org/latest.json?order=created


#6

Yeah, it seems so. Thanks :grinning: !