Fix a paging loop that stops early, returns duplicate rows, or rejects its cursor. Every cursor-paged route follows one rule: while meta.has_more is true, send meta.next_cursor back as cursor with every other parameter unchanged. Most paging bugs break that rule or split a long range into windows that overlap.
Symptoms
- The loop stops before the window is done.
- The same rows appear twice in the output.
- A request fails with
400 invalid_cursor.
- A page returns fewer rows than the
limit you sent.
- Cumulative volume delta (CVD) jumps at regular points in a joined series.
Match the symptom to the cause
Follow the cursor unchanged
A rejected cursor names the fix in its message:
Store the exact cursor string with the window and filters it belongs to. Never parse, compare, or construct cursors; their encoding differs by route. Pagination has the full contract and a single-window loop.
Split long ranges without overlap
The Hyperliquid trades route returns rows at both start and end, so a window that starts at the previous window’s end repeats the rows at that millisecond. Start each window 1 ms later. Hyperliquid trades also return two rows per trade, one per side, sharing one trade_id, so a dedupe key of trade_id alone drops half the fills. Key on trade_id and side.
This loop pulls the last hour of yesterday (UTC), a window every plan serves, in four 15-minute windows:
The row count is twice the trade count. Persist the last next_cursor per window so a stopped run resumes inside the window instead of starting it again.
Rebuild running totals across pages
On the CVD routes, cumulative_delta runs from the first bucket of each response. A response that is one page of several says so in meta.notice:
Join the pages first, then recompute the total from delta:
The HIP-3 CVD route pages the same way.
Verify the fix
- The final page has
meta.has_more set to false and no meta.next_cursor.
- Your dedupe set removes nothing on a clean run with non-overlapping windows; anything it removes points to an overlap or a retried page.
- The joined CVD series has no reset at page boundaries.
- You kept
meta.request_id for every page.
Next step
Last modified on December 1, 2026