Rich Returns supports relative pagination using a sinceId
parameter.
Relative pagination scales nicely even for very large datasets compared to page-based pagination where incremental page numbers scale poorly — the bigger the page number, the slower the query.
Each request will include a sinceId
parameter with the id of the last record from the previous page. This does require the records to be sorted by id ascending, but this happens automatically when a sinceId
parameter is present. To ensure the first page is sorted by id, you can include an order
parameter with a value of ASC
.
For example, if you’re requesting a list of returns from Rich Returns, the request for the first page might look like the following:
/returns?limit=3&order=ASC
Another option to access returns in a specific timeframe is to use createdAtMin
and createdAtMax
:
/returns?limit=3&order=ASC&createdAtMin=2020-02-01&createdAtMax=2020-02-03
This will come back with the following response:
{ "returns": [ { "rma": "RMA-2342500250" ... ... }, { "rma": "RMA-4250250293" ... ... }, { "rma": "RMA-2452931529" ... ... }, ]}
Taking the id of the last record, the request to get the next page would be:
/returns?limit=3&sinceId=RMA-2452931529