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": "http://example.com/items?page=1"
    "next": "http://example.com/items?page=2"
  }
}

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: <http://example.com/items?page=2>; rel="next", \
<http://example.com/items?page=2662>; rel="last"

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

“next”
“previous” (and it’s synonym “prev”)
“first”
“last”

Share Button

Dear Polish Gov. – you made my inner geek happy

Set of rules describing security levels of IT system which processes personal or sensitive data has number 1024!

suchgeek

Share Button

Ride a bike!

It was quite a long time ago but I recalled recenty that in my youth I was walking only to school (5minutes) and to church by foot. I spent almost every second on bike (except when playing footbal, but not necessary).

By public transportation it took me 45 minutes to go to work I thought I could totally make this nearly 9km in the same time on bike, and after some time event beat it. So recently I dusted out my old bike and it actually took me half an hour to get to the office.

bikeride

Other advantage is arriving home with totally clear head. It maybe less comfortable when the Summer arrives and we have 30 deg. but I’ll figure it out.
On the disadvantages – I would read less books now… maybe I should switch to audio-books?

Share Button