stacks-blockchain-api icon indicating copy to clipboard operation
stacks-blockchain-api copied to clipboard

feat: add cursor pagination to sc events

Open ASuciuX opened this issue 3 months ago • 7 comments

[wip] to add prev_cursor

Fixes https://github.com/hirosystems/stacks-blockchain-api/issues/2349 by adding cursor-based pagination for events. This provides stable iteration through results, unlike offset-based pagination where responses can shift as new events are added.

ASuciuX avatar Sep 12 '25 17:09 ASuciuX

Vercel deployment URL: https://stacks-blockchain-57uq2bbf2-hirosystems.vercel.app :rocket:

github-actions[bot] avatar Sep 12 '25 17:09 github-actions[bot]

Codecov Report

:x: Patch coverage is 63.26531% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/datastore/pg-store.ts 51.42% 14 Missing and 3 partials :warning:
src/api/routes/contract.ts 90.00% 1 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Sep 12 '25 17:09 codecov[bot]

@ASuciuX thanks for giving a shot at this pr. With this cursor based approach, will it be possible to got from event 1 (the first one that happened) to the last one? My use case would be to index all the events from the start to a specific block.

pradel avatar Sep 23 '25 10:09 pradel

Yes, with the cursor you can iterate forward from the very first event to the latest, page by page. It’s designed so you can start at genesis and stop at any specific block height.

ASuciuX avatar Sep 23 '25 10:09 ASuciuX

Amazing, looking forward to be able to use this approach 🙏

pradel avatar Sep 23 '25 10:09 pradel

@ASuciuX lmk if I can help to get the pr merged faster

pradel avatar Nov 03 '25 12:11 pradel

@ASuciuX lmk if I can help to get the pr merged faster

The task got pushed to the backlog due to some internal priorities, but I’ll take care of it as soon as those wrap up.

ASuciuX avatar Nov 18 '25 19:11 ASuciuX