RESTful pagination

I was looking for “proper” way to tell REST API client on which page it is and provide guidance for further traversing.

First I was considering Apigility approach which attaches something like this to the response:

  "items": [...],
  "__meta": {
    "prev": ""
    "next": ""

I just got back from the vet and he poked me and gave me a shot but he forgot to give me a treat.Creative Commons License Steve Baker via Compfight
RESTful dog (couldn’t stop myself)

The problem is it isn’t really RESTful. So I was searching, and searching, and googling, and… bam! There’s something called RFC 5988. Github uses this approach so I think this is my approach also. User Link header:

Link: <>; rel="next", \
<>; rel="last"

No metadata in response body. Just look for “Relation Name” in rfc to see what you can use. For pagination specifically:

“previous” (and it’s synonym “prev”)

Share Button

One thought on “RESTful pagination

  1. Greetings! This is my 1st comment here so I just wanted to give
    a quick shout out and tell you I genuinely enjoy reading through your posts.
    Can you suggest any other blogs/websites/forums that go over the same topics?
    Thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *