Pagination and Sorting

How to paginate and sort data using the PortierX API.

Work in progress

We are actively working on our API. The documentation and implementation described here may not yet be fully aligned.

Pagination

Pagination is controlled via query string parameters:

curl "https://api.portierx.com/v1/core/locking-system?page=2&limit=20"
  • The page parameter specifies which page of results to retrieve.
  • The limit parameter defines the number of results per page (maximum allowed is 100).

Pagination and sorting apply only to list requests. The default page is 1, and the default limit is 10.

Example Response with Pagination

{
  "msg": "Retrieved item list successfully",
  "data": [
    {
      "msg": "info"
    }
  ],
  "meta": {
    "pagination": {
      "total": 100,
      "count": 10,
      "per_page": 10,
      "current_page": 1,
      "total_pages": 10
    }
  }
}

Metadata Explanation

FieldDescription
totalThe total number of available records.
countThe number of records returned in the current response.
per_pageThe number of records per page.
current_pageThe current page number.
total_pagesThe total number of pages available.

Sorting

Sorting is done using the order query string parameter. By default, sorting is based in creation date ascending (oldest to newest / smaller to larger). It accepts a comma-separated list of fields and directions.

Sorting Example

curl "https://api.portierx.com/v1/core/locking-system?order=age.desc,height.asc"
  • age.desc sorts the age field in descending order.
  • height.asc sorts the height field in ascending order.

Default Sorting

If no direction is specified, the default order is ascending:

curl "https://api.portierx.com/v1/core/locking-system?order=age"

Null Handling

To control the sorting of null values, use nullsfirst or nullslast:

curl "https://api.portierx.com/v1/core/locking-system?order=age.nullsfirst"
curl "https://api.portierx.com/v1/core/locking-system?order=age.desc.nullslast"

This ensures predictable ordering when dealing with null values. By default, null values are sorted last.

On this page