RESTful Design: Paging Collections

Posted by Koen Bok on Stack Overflow See other posts from Stack Overflow or by Koen Bok
Published on 2009-02-01T15:41:08Z Indexed on 2010/06/01 7:13 UTC
Read the original article Hit count: 324

Filed under:
|
|
|

I am designing a REST api that needs paging (per x) enforces from the server side.

What would be the right way to page through any collection of resources:

Option 1:

GET /resource/page/<pagenr>
GET /resource/tags/<tag1>,<tag2>/page/<pagenr>
GET /resource/search/<query>/page/<pagenr>

Option 2:

GET /resource/?page=<pagenr>
GET /resource/tags/<tag1>,<tag2>?page=<pagenr>
GET /resource/search/<query>?page=<pagenr>

If 1, what should I do with GET /resource? Redirect to /resource/page/0, reply with some error or reply with the exact same as /resource/page/0 without redirecting?

© Stack Overflow or respective owner

Related posts about web-services

Related posts about api