public-api-docs

πŸ“– Pagination

When accessing APIs of the Wunder Platform most list endpoints are paginated.

Why Pagination

  1. Performance Optimization: Fetching, transferring, and rendering large amounts of data at once can consume significant computational resources and bandwidth. Pagination allows for fetching data in chunks, reducing the load on both server and client systems.
  2. User-Friendliness: Displaying data in smaller, comprehensible chunks helps users navigate the information more effectively. Endless scrolling or massive tables are hard to comprehend and use.
  3. Scalability: As datasets grow, a paginated approach scales better, ensuring that APIs, databases, and frontends are not overwhelmed.

Pagination in Wunder Platform APIs

Request

Paginated list endpoints support the following query parameters to paginate through results. Paginated endpoints usually come with a default configuration that is used if none is provided in the request.

Request Parameter Default Purpose
page 0 Define which page should be returned (so depending on the defined size, skip the first X results). Zero-based.
size 50 unless overwritten by an endpoint (some return 500 or up to 1000 results) Define how many results should be in the returned page. At maximum we allow a size of 5000, and some endpoints might specify a lower maximum.
sort usually by ID DESC Define the sorting order of the results. See the section below for more details.

Response

The API will contain the following HTTP headers to give the consumer of the API information about the paginated result.

Header Purpose
X-Pagination-TotalPages Total number of available pages. Calculation: ceil(totalElements / size)
X-Pagination-TotalElements Total number of results across all pages
X-Pagination-Number Current page number
X-Pagination-NumberOfElements Number of elements of the currently returned page (can be less than size on the last page)
X-Pagination-Size Number of elements per page (should be the same as above except on the last page)
X-Pagination-First Boolean value indicating if it’s the first page
X-Pagination-Last Boolean value indicating if it’s the last page

Filtering and Sorting paginated endpoints in Wunder Platform APIs

Sorting

Paginated list endpoints generally also allow to sort the results for specific properties. Supported properties depend on the specific endpoint.

By adding a sort query parameter, the client can specify:

Examples:

Filtering

Paginated list endpoints generally also allow to the results for specific properties. Similar to sorting the supported properties also depend on the specific endpoint.

Filtering works by specifying the property to filter for as a query parameter, followed by the value. For example id=10 will find elements that have 10 as id (should only be one).

The concrete logic of how filtering is applied depends on the datatype of the property:

Examples: