Pagination
Split your requests into smaller chunks to avoid overwhelming QuickBooks Desktop
Some QuickBooks Desktop users have unexpectedly large amounts of data. In addition, QuickBooks Desktop is slow and memory-intensive. Without proper limits or pagination, a request might inadvertently retrieve tens of thousands of rows, which can take many minutes to return. To avoid overwhelming QuickBooks Desktop, you may need to split your requests into smaller chunks. This process is called pagination.
Pagination via the Node.js client library
Cursor-based pagination is not yet supported in the Node.js client library. Instead, we recommend batching your requests by date range and concatenating the results. This will avoid overwhelming QuickBooks Desktop by requesting only a subset of the data at a time.
For example, the following fetches all invoices from the provided date range in yearly batches:
Pagination via the REST API
If you are using the REST API directly, you can paginate requests by following the instructions below.
Initiating pagination
To paginate a QuickBooks Desktop query, include the MaxReturned
parameter in your request body, specifying the maximum number of records you want to receive in a single response. If the total number of records exceeds MaxReturned
, the response will include two additional fields:
IteratorID
: A unique identifier for the current query.IteratorRemainingCount
: The number of records remaining to be fetched.
Here’s an example of a pagination request:
And here’s an example of a pagination response:
Continuing pagination
If IteratorRemainingCount
is greater than 0, send another request with the same request body as the previous request, but include the IteratorID
parameter on the root level of the request body, set to the value from the previous response.
The parameter IteratorID
goes on the root level of the request body, not
inside the query object.
Considerations
- The iterator can only be used within the same QuickBooks Web Connector session, which we keep open for 10 seconds. If the iterator is not used within that time, you will receive an error. Therefore, you must implement the pagination logic programmatically in your backend to ensure that the iterator is used within the 3-second window.
- The short expiry is due to how the QuickBooks Web Connector handles pagination. Upon the initial request, the QuickBooks Web Connector requests the entire result set from QuickBooks Desktop, stores it in local memory, and returns only the first batch. As a result, the first request will take longer because QBD must process and assemble the entire result set. Subsequent requests will return immediately.
- If you attempt to use the iterator after the previous request returned
IteratorRemainingCount
of0
, you will receive an error.