GuidesAPI ReferenceChangelog
Log In
Guides

Pagination

All top-level API resources have support for bulk fetches via "list" API methods. For instance, you can list members. These list API methods share a common structure, taking at least these three parameters: limit, startingAfter and endingBefore.

SafetyWing's list API methods use cursor-based pagination via the startingAfter and endingBefore parameters. Both parameters take an existing object ID value (see below) and return objects respectively in ascending order (startingAfter) and descending order (endingBefore). The endingBefore parameter returns objects listed before the named object. The startingAfter parameter returns objects listed after the named object. These parameters are exclusive -- only one of startingAfter OR endingBefore may be used.

Request parameterDescription
startingAfterA cursor for use in pagination. startingAfter is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with 1234 (member ID for a Remote Health user), your subsequent call can include startingAfter=1234 in order to fetch the next page of the list.
endingBeforeA cursor for use in pagination. endingBefore is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with 1234 (member ID for a Remote Health user), your subsequent call can include endingBefore=1234 in order to fetch the previous page of the list.
limitA limit on the number of objects to be returned, between 1 and 100. This parameter is optional and by default set to 100.

Example list response:

{
    "has_more":true,
		"data": [
        {
            "id": 12345678,
            "email": "[email protected]",
            "insuranceStartDate": "2022-01-01",
            "insuranceExpiryDate": "2022-12-31",
						"annualCost": "20.30",
            "planId": 2,
            "planName": "Premium",
            "status": "ACTIVE",
            "firstName": "John",
            "lastName": "Doe",
            "birthdate": "1980-01-01",
            "citizenship": "CA",
            "residency": "CA",
          	{...}
        },
				{...},
				{...}
		]
}
Response parameterDescription
dataAn array containing the response elements, paginated by requested parameters.
hasMoreWhether or not there are more elements available after this set. If false, this is the last dataset of the list.