Skip to content

Pagination

suryayadavalli edited this page Mar 29, 2015 · 1 revision

Why pagination?

A lot of the time, when you're making calls to the REST API, there could be a lot of results to return. For that reason, we paginate the results to make sure responses are easier to handle. Let's say trusted app's initial call is asking for all the beds information for a specific project; the result could be a massive response with hundreds of thousands of beds. That's not a good place to start.

Rather than that, we build a default limit on results, but we recommend trusted apps always explicitly set the start and max parameters to ensure you get the number of results from the index the trusted app wants to retrieve from cloud.

Sample request by the trusted App

https://www.hmisdomain.com/servicename/clients?from=1&max=30

Sample response by HMIS Cloud

{
  "clientList": {
    "pagination": {
      "total": "100",
      "from": "1",
      "returned": "30",
      "maximum": "30"
    },
    "client": [
      {
        "index": "10",
        "id": "123",
        "name": "1_Client Name"
      },
      {
        "index": "11",
        "id": "423",
        "name": "2_Client Name"
      },
      {
        "index": "12",
        "id": "986",
        "name": "3_Client Name"
      }
    ]
  }
}

Implementation

Code snippet below shows how to declare a specific model to support Pagination
public class ClientList extends PaginatedModel { //fields }
Clone this wiki locally