Created by potrace 1.16, written by Peter Selinger 2001-2019

Miva Developer Docs


Page through large result sets with the Count and Offset request parameters.

It is recommended when querying lists of large data sets (products, orders, customers), that you paginate the results to avoid timeout issues and enable more robust data transfer between Miva and your system.
Every List Load Query function in the JSON API supports pagination.

There are two request parameters which enable pagination when querying a list of data:

Count - Count is used to tell Miva how many records you want returned.
Offset - Used in conjunction with the Count parameter for paginating results of large datasets. Default is 0 which is no offset.

Then contained in every response will be two parameters which will tell you how many resources are still left to be downloaded.

total_count - total_count is the total number of records that match your search criteria. Note: this is not always the total records returned. Based on the Count and Offset parameters passed, the number of records returned could be different than the total_count.
start_offset - The starting offset from the total number of products returned in the results.

Example#

To paginate a list of products, you create an initial request to Miva passing in a count of the maximum number of records you want returned. For example let say we want a max of 100 records at a time. The count parameter would be 100. Then for the offset parameter we pass 0 since we want to start at the beginning.

Miva will then return the 100 records along with total_count and start_offset. Say for example the total count is 250. You would process the total count from the response you receive and determine that you need to make two additional calls to get the remaining records. They would look like this:

Second Request Parameters

  • Count = 100
  • Offset = 100

Second Response Parameters

  • total_count = 250
  • start_offset = 100

Third Request Parameters

  • Count = 100
  • Offset = 200

Third Response Parameters

  • total_count = 250
  • start_offset = 200

The results of each call should result in 100 records returned in the 1st call, 100 records returned in the second call and 50 records returned in the 3rd call. You essentially take the start_offset response parameter + count to calculate the your next call’s offset parameter. You only stop querying results once the start_offset + count parameters is greater that the total_count.