views:

196

answers:

2

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

A: 

Check out the implementations in Microsoft ADO.NET Data Services

the use URL based query, sorting, and paging parameters in a tidy constructive form

TFD
+2  A: 

Look at the Atom Feed Paging and Archiving RFC: http://tools.ietf.org/html/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

Jan Algermissen