feat: add auto-pagination iterators for list endpoints#4
Open
harley-poly wants to merge 3 commits into
Open
Conversation
mustafa-poly
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
adds
iterate()helpers that transparently walk all pages so callers no longer hand-roll cursor/offset logic:events.iterate(),markets.iterate(),series.iterate()(page until a short page is returned).portfolio.iterate_activities()(follownextCursoruntileofor an empty cursor).polymarket_us/pagination.py; both sync (Iterator) and async (AsyncIterator) variants are provided.positions are intentionally not iterated (the endpoint returns the full set in one response).
test plan
ruff check/ruff format --checkmypy polymarket_uspytest(125 passed; newtests/test_pagination.pycovers offset paging until short/empty page, cursor paging until eof/no-next-cursor, and async variants)Note
Low Risk
Additive client-side helpers and documentation; no changes to signing, orders, or server contracts beyond extra list requests when iterating.
Overview
Adds auto-pagination so callers can stream full list results without manual
offset/cursorhandling. Shared logic inpolymarket_us/pagination.pycovers offset pages (stop on short/empty page, clamppage_sizeto at least 1) and cursor pages (follownextCursoruntileofor missing cursor), with sync and async variants.iterate()onevents,markets, andserieswalks offset-paginated lists (optional filters +page_size).portfolio.iterate_activities()walks authenticated activity history via cursor. README documents sync/async forusage.Tests in
tests/test_pagination.pycover multi-page offset, empty pages, cursor/eof, and async mirrors.test_authnow builds a valid 64-byte base64 secret for the Ed25519 key-length test.Reviewed by Cursor Bugbot for commit bfd4f37. Bugbot is set up for automated code reviews on this repo. Configure here.