AwkwardCoder
AwkwardCoder

Reputation: 25651

Pagination in a RESTful service

I have a RESTful API which could return a large number of items and I want to be able use pagination style techniques to limit the number of items, is this a good idea in a RESTful API?

If it is possible is best to do it via the link (url in this case) or part of the body of the request?

Cheers

AWC

Upvotes: 4

Views: 4079

Answers (1)

Jan Algermissen
Jan Algermissen

Reputation: 4978

Look at the Atom Feed Paging and Archiving RFC: https://www.rfc-editor.org/rfc/rfc5005 and also look at AtomPub itself (RFC5023).

You should be able to easily leverage that in your project.

Regarding theory: the API is RESTful if the media type of the representation (or some orthogonal specification - see below) tells the client where to find the paging links or how to construct them.

In the case of RFC5005 a number of link relations are defined (next,prev...) that are of course orthogonal to any media type. You find these link rels also in the IANA Link Relations Registry at http://www.iana.org/assignments/link-relations/link-relations.xml

Jan

Upvotes: 6

Related Questions