API – Paginating Results
This article assumes you have read API – Responses with multiple results.
When dealing with requests that return multiple results, many times you only want a subset of results. Other times, you have more results than the default pagination settings allow you to see. This article will cover pagination settings for the LoanPro API.
The default pagination settings return up to the top 50 elements for almost all queries. This limits bandwidth and lowers response times, while still giving an abundant amount of information. This means that the summary field will have the following values:
- start: 0
- pageSize: 50
At times you will want to $skip the first 20 or 50 or 1,000 items. To do this, you use the GET parameter $skip. The $skip parameter tells LoanPro which result to skip to when fetching results. This means that to get the 20th item and onward you will have the GET parameter of $skip=20. For getting the 50th item and onward it would be $skip=50, and so forth.
However, if you are using a search endpoint (such as Loans/Autopal.Search()) you will need to use the $start variable instead of the $skip variable. The $start variable has the same usage as the $skip variable – the only difference is the variable name.
Setting Page Size
To set page size, you use the $top variable. This sets the maximum page size. Please note that this does not guarantee that, that many items will be returned, even if there are more items than the maximum page size. It does guarantee that no more than the number provided will be returned. This means that if you set $top=10, no more than 10 items will be returned. This does NOT change the order that items will be returned.
Turn Off Paging
To turn off paging, send “nopaging” as a GET parameter (note that this parameter does not have a value). This turns off the maximum number of items that can be returned, but does not change the pageSize value in summary.
To demonstrate this, use a GET to the odata.svc/Loans() endpoint.
When you send this request, you will get a response that contains all the loans in the tenant. This may take a while, so it will be better to limit the number of loans returned using the $top parameter.
The example above will limit the response to 200 loans, but you can adjust the number to return as many results as you like, up to the total number of loans in the tenant.