How to get more posts from posts.json

/posts.json?before=X returns the first 50 posts with an ID lower than X. So if you want the get the lastest 75 posts for example, you can do:

  1. GET /posts.json to get the last 50
  2. GET /posts.json?before=x where x is the ID of the oldest post in the set of the previous GET call.
  3. Get the first 25 posts of this last GET set and you’ll have the 75 you wanted.

In my case I needed all the posts from the last 24hs, so my code looks like:

  1. GET /posts.json to get the last 50.
  2. If the oldest post in the set returned by the previous GET was created between the last 24hs, I do GET /posts.json?before=x where x is the ID of the oldest post in the set of the previous GET call.
  3. Repeat until the GET call returns at least 1 post that was created more than 24hs ago.

Hope this helps anyone :slight_smile: