Upbooks API – Sorting #
Upbooks APIs support sorting for list responses to efficiently handle large datasets. Sorting is achieved by using the `sortBy` and `sortOrder` headers in your GET requests along with other necessary headers.
Pagination Headers #
Include the following headers in your GET requests to enable pagination:
Authorization: Bearer YOUR_JWT_TOKEN
Organization-ID: YOUR_ORGANIZATION_ID
API-KEY: YOUR_API_KEY
sortOrder: 1 | -1
sortBy: fieldName
The `sortOrder` represents the sort order where 1 means ascending and -1 means descending, and `sortBy` represents the field that should be sorted.
Example: Client List API #
For the “Client List” API, you can use pagination headers as follows:
GET https://api.upbooks.io/api/v1/clients
Headers:
Authorization: Bearer YOUR_JWT_TOKEN
Organization-ID: YOUR_ORGANIZATION_ID
API-KEY: YOUR_API_KEY
pageNo: 1
pageSize: 20
This request fetches the first page of 20 clients. Adjust the `pageNo` and `pageSize` headers to navigate through the list.
Pagination Response #
The API response will include information about pagination, such as:"data":
[{"clientId": "123", "name": "Client 1"}, {"clientId": "456", "name": "Client 2"}],
"totalCount": 50,
"filteredCount": 20,
"message": "Clients retrieved successfully"
The `totalCount` represents the total number of items available, and `filteredCount` represents the number of items in the current page.
Adjusting Pagination #
Modify the `pageNo` and `pageSize` headers to navigate through different pages and control the number of items per page based on your application’s requirements.