4

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

AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152

1 Answers1

6

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

Community
  • 1
  • 1
Jan Algermissen
  • 4,930
  • 4
  • 26
  • 39