API fetch most recent posts for a topic


(Reid Van Melle) #1

I’ve read all of the discussions about using the API to fetch all of the posts for a particular topic using the post_ids from the stream. However, I cannot seem to find anything that would allow me to fetch the most recent set of posts for a topic (i.e. how the website works). Instead, I’m get the oldest 20 posts from the topic. I think the most common use case for the API would be fetching the most recent posts, and then paging page into time.

Also, are there any undocumented parameters for controlling the chunk_size? I was also looking for this in the admin interface.


(Reid Van Melle) #2

One potential strategy I see is to use http://<server>/t/<topic_id>/posts.json?post_ids[]=0 to get the stream of IDs, and then implement my own paging system starting at the end of the post stream…


(Régis Hanol) #3

If you want the latest posts, you can use http://<server>/t/-/<topic-id>/last.json

In the response, you’ll get the last 20 posts in post_stream > posts and the list of all the post ids in post_stream > stream.

That should be enough to do the pagination :wink:


(Reid Van Melle) #7

Man — exactly what I was looking for — I combed the API docs and postman :frowning: Thanks much!

Any inside knowledge on a way to set the page size?

does that just redirect to http://<server>/t/<slug>/<topic-id>/99999999.json ?

and seems like http://<server>/t/<topic-id>/99999999.json without the slug also works just fine!