Pagination
Pagination is available for List endpoints (consumers, corporates, ledgers, cards, transactions, ...).
It allows to retrieve small subsets of lists, avoiding to receive large amount of data.
Offset Pagination
You have to provide the following parameters in the request :
Name | Description |
---|---|
pageSize | Number of elements to be returned in the page |
page | Number of the page (starting at page 0) |
sortDirection | Sorting order of the results, depending on the sortAttribute : Ascending (ASC) or Descending (DESC) |
sortAttribute | Atribute for the sorting, usually dates. See each endpoint for available values. |
If not provided, these default values will apply :
Name | Default value |
---|---|
pageSize | 20 |
page | 0 |
sortDirection | "DESC" |
sortAttribute | "CREATION_DATE" |
These parameters are Query Parameters, and should be send in the Query, not the Request Body :
In response, the API will send the selected page
, according to the defined pageSize
and the sorting.
If there is not enough elements to fill a page, returned page size will be smaller than requested.
totalElements
field is also present in the response, and always indicates the total number of elements available, no matter the pages
Exemples
Let's assume you have created 50 Ledgers.
To get the 1st page of 30 Ledgers, sorted by descending creation date, you should input :
/api/partner/ledgers?pageSize=30&page=0&sortDirection=DESC&sortAttribute=CREATION_DATE
This will return an array of 30 Ledgers (In this case the 30 most recent ones)
{
"content": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2021-08-24T14:15:22Z"
}
{
"id": "497f6eca-6276-4993-bfeb-42dccccb5f43",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2021-08-23T13:15:22Z"
}
[....] //28 other ledgers
],
"totalElements": 50
}
If you want the 4th page, with 10 Ledgers per page, sorted by the oldest ones (ascending creation dates) :
/api/partner/ledgers?pageSize=10&page=3&sortDirection=ASC&sortAttribute=CREATION_DATE
This will return an array of 10 Ledgers, ordered by Desceding creation date.
In this case, it corresponds to the 31st to the 40th Ledgers you created (1st to 30th are in pages 0, 1 & 2).
{
"content": [
{
"id": "566bd6cf-f4ee-41fc-9de6-a1e99c301383",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2019-05-22T14:15:22Z"
}
{
"id": "d9b95b96-bb75-4df0-854f-38b9812bfadc",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2019-09-23T13:15:22Z"
}
[....] //8 other ledgers
],
"totalElements": 50
}
At last, if you want the 3rd page, with 20 Ledgers per page, sorted with default order
api/partner/ledgers?page=2&pageSize=20
This will return an array of only 10 Ledgers. Indeed, as there is only 50 created ledgers, the 3rd page contains only 10 ledgers.
{
"content": [
{
"id": "566bd6cf-f4ee-41fc-9de6-a1e99c301383",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2019-05-22T14:15:22Z"
}
{
"id": "d9b95b96-bb75-4df0-854f-38b9812bfadc",
"enduserId": "e1641979-307f-485a-a0d3-8e962220018a",
"friendlyName": "string",
"currency": "EUR",
"country": "LITHUANIA",
"creationDate": "2019-09-23T13:15:22Z"
}
[....] //8 other ledgers
],
"totalElements": 50
}