We page orders with POST /query and want "47 orders" in the header. The response has result_count, but it never goes above our limit.
Showing a total count next to a filtered list
Common question, written up by the Supero team.
1 answer
/query returns only success, results and result_count. It has no pagination object, so there's nowhere for a total to go.
For the list itself, use POST /list-bulk with include_total: true and read pagination.total. It costs a full scan, so ask for it on the first page and leave it off the pages after.
{"type": "order", "filters": {"status": "open"}, "limit": 20, "include_total": true}If you only need the number, don't pull rows. The aggregate API's GET /api/v1/aggregate/{domain}/{type}/stats takes a JSON match parameter and returns count. In the Python SDK that's org.crud.count("order", status="open"), or .count() at the end of a query builder chain. Aggregate match is exact-match only; for ranges, list-bulk's dict filters accepts $gte, $gt, $lte, $lt, $ne, $in and $nin.
Your answer
Know the answer? Sign in to post it. It takes an email address and a 6-digit code.
Sign in to answer