Pagination

In this guide, we will look at how to work with paginated responses when querying the Quincy API. By default, all responses limit results to 15 items per page. You can customize this by adding a limit parameter to your requests.

When an API response returns a list of objects, pagination is supported. In paginated responses, objects are nested in a data attribute and include links and meta information to help you navigate through pages. You can use the page query parameter to browse pages.

Example using page-based pagination

In this example, we search for patients with the name "John" and get a paginated response. The response includes the current page data along with metadata about total pages, navigation links, and other pagination details.

  • Name
    page
    Type
    integer
    Description

    The page number you want to retrieve (default: 1).

  • Name
    limit
    Type
    integer
    Description

    Number of items to return per page (default: 15).

  • Name
    query
    Type
    string
    Description

    Search query to filter results.

Page-based pagination using cURL

  curl -G https://app.quincy.health/api/v1/patients/search \
  -H "Authorization: Bearer {token}" \
  -d query="John" \
  -d page=1 \
  -d limit=15

Paginated response

{
  "data": [
    {
      "id": 1000000,
      "firstname": "John",
      "lastname": "Smith",
      "dob": "1980-01-01",
      "sex": "Male",
      "email": "[email protected]",
      "phone": "01923 811 291",
      "address_line1": "Patient Line 1",
      "address_line2": "Patient Line 2",
      "city": "London",
      "postcode": "PXA 123",
      "country": "United Kingdom",
      "created_at": "2024-08-28T23:24:51.000000Z",
      "updated_at": "2024-09-19T08:18:33.000000Z"
    }
  ],
  "links": {
    "first": "http://app.quincy.health/api/v1/patients?query=John&page=1",
    "last": "http://app.quincy.health/api/v1/patients?query=John&page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "per_page": 15,
    "to": 1,
    "total": 1,
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "active": false
      },
      {
        "url": "http://app.quincy.health/api/v1/patients?query=John&page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ]
  }
}