Pagination
Pagination in MBanq enables developers to manage large data sets by dividing them into smaller, manageable pages. It is particularly useful when working with APIs that return a high volume of results, such as the "list clients" API.
By specifying the desired number of results per page using the limit
parameter, developers can control the data load. This ensures that the API response only includes the specified number of results and that the client application can efficiently load and display data, optimizing resource consumption.
The offset
parameter allows developers to retrieve subsequent pages of results by incrementing the offset value, providing flexibility in navigating through the data.
Example of a Request with Pagination: List Clients
API Endpoint referenced in this example:
To demonstrate pagination, consider the following example request:
/clients?offset=12&limit=50
This request specifies that the API should return results starting from the 12th record and limit the response to 50 records per page.
The response will include the requested page of client data, along with information about the total number of filtered records. Each page of results will be contained within the "pageItems" array.
Response:
{
"totalFilteredRecords": 12,
"pageItems": [
{
"id": 21,
"accountNo": "000000021",
"status": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
},
"subStatus": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"active": true,
"activationDate": [
2023,
7,
3
],
"firstname": "DemoRJ",
"lastname": "DemoRJ",
"displayName": "DemoRJ DemoRJ",
"gender": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientType": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientClassification": {
"id": 651,
"active": false,
"mandatory": false,
"systemDefined": false
},
"isStaff": false,
"skipAvs": false,
"officeId": 1,
"timeline": {
"submittedOnDate": [
2023,
7,
3
],
"activatedOnDate": [
2023,
7,
3
]
},
"clientNonPersonDetails": {
"constitution": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"mainBusinessLine": {
"active": false,
"mandatory": false,
"systemDefined": false
}
},
"clientTransferOptionData": {
"externalCardDebitAllowed": false,
"externalCardCreditAllowed": false
}
},
{
"id": 20,
"accountNo": "000000020",
"status": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
},
"subStatus": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"active": true,
"activationDate": [
2023,
7,
3
],
"firstname": "DemoRJ",
"lastname": "DemoRJ",
"displayName": "DemoRJ DemoRJ",
"gender": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientType": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientClassification": {
"id": 651,
"active": false,
"mandatory": false,
"systemDefined": false
},
"isStaff": false,
"skipAvs": false,
"officeId": 1,
"timeline": {
"submittedOnDate": [
2023,
7,
3
],
"activatedOnDate": [
2023,
7,
3
]
},
"clientNonPersonDetails": {
"constitution": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"mainBusinessLine": {
"active": false,
"mandatory": false,
"systemDefined": false
}
},
"clientTransferOptionData": {
"externalCardDebitAllowed": false,
"externalCardCreditAllowed": false
}
},
{
"id": 1,
"accountNo": "000000001",
"status": {
"id": 300,
"code": "clientStatusType.active",
"value": "Active"
},
"subStatus": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"active": true,
"activationDate": [
2014,
3,
7
],
"firstname": "Smith",
"lastname": "R",
"displayName": "Smith R",
"gender": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientType": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"clientClassification": {
"id": 660,
"active": false,
"mandatory": false,
"systemDefined": false
},
"isStaff": false,
"skipAvs": false,
"officeId": 1,
"staffId": 1,
"timeline": {
"submittedOnDate": [
2010,
1,
1
],
"activatedOnDate": [
2014,
3,
7
]
},
"clientNonPersonDetails": {
"constitution": {
"active": false,
"mandatory": false,
"systemDefined": false
},
"mainBusinessLine": {
"active": false,
"mandatory": false,
"systemDefined": false
}
},
"clientTransferOptionData": {
"externalCardDebitAllowed": false,
"externalCardCreditAllowed": false
}
}
]
}
This table provides an overview of the optional parameters that can be used for pagination in the MBanq API. The "limit" parameter is particularly important as it restricts the number of results returned. By explicitly setting the desired limit, developers can control the size of the result set and optimize their API queries.
Parameter | Value Type | Requirement | Definition |
---|---|---|---|
limit | Integer | Optional | Restricts the size of results returned. To return all entries, explicitly pass a non-positive integer value for limit (e.g., limit=0 or limit=-1). Defaults to 200. |
offset | Integer | Optional | Indicates the result from which pagination starts. Defaults to 0. |
orderBy | String | Optional | Orders results by the indicated field. Can be one of displayName, accountNo, officeId, officeName. |
sortBy | String | Optional | Indicates the sorting order if orderBy is used. Can be one of ASC or DESC. |
It's important to note that the API supports additional optional parameters, such as sorting, filtering, and searching, to further refine the results according to specific criteria.
By leveraging pagination in the MBanq API, developers can efficiently manage and retrieve data in a controlled manner, ensuring optimal performance and a better user experience.
Updated over 1 year ago