Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active December 6, 2015 20:28
Show Gist options
  • Save khoand0000/fabc052ee05487713a2d to your computer and use it in GitHub Desktop.
Save khoand0000/fabc052ee05487713a2d to your computer and use it in GitHub Desktop.
Pagination guide #convention #rules Reference: http://www.popshops.com/support/api-3-products
  • Required request parameters: page (start 1, not 0)
  • Optional request parameters: results_per_page
  • RESTful pattern, don't include required parameters in url: http://myapi.com/items (not http://myapi.com/items/:page), include required and optional parameters in query parameters: http://api.com/items?page=1&results_per_page=50. Because there is just GET request is used for pagination, so always using query parameters (don't include them in json body, just using json body when request is PUT, POST)
  • Response: json object contains at least: count (total items), items (array)
{
  count: 10,
  items: [
    {name: '', ...},
    {name: '', ...}
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment