fix: correct market response types (BREAKING CHANGE) - #8
Merged
Merged
Conversation
BREAKING CHANGE: Market book and BBO response types now expose the marketData envelope. Settlement types now expose slug and numeric settlement instead of marketSlug, settlementPrice, and settledAt. Typed consumers must update field accesses and handle nullable market data fields; runtime responses are unchanged.
willzeng274
approved these changes
Sep 22, 2026
poly-william
approved these changes
Sep 22, 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.
Changes
Correct sync and async
markets.book()andmarkets.bbo()to return themarketDataresponse envelope, and settlement to return{ "slug": str, "settlement": float }. Include the closed market state and nullable fields returned by the API.Runtime responses are unchanged. Consumers using the previous declarations should read book/BBO data through
marketDataand settlement through the numericsettlementfield. Add the consumer fixture to the existing mypy CI job.Release compatibility
BREAKING CHANGE: Typed consumers must read book/BBO data through
marketData, useslugand numericsettlement, and handle nullable market data fields. The README includes the migration example for sync and async clients.The existing publish workflow classifies this as a major release (
0.1.2→1.0.0). The PR title and final nonempty commit carry the marker for the configured merge, squash, and rebase defaults. Accept this version choice before merging and preserveBREAKING CHANGEin the final commit message.Testing
uv run pytest— 140 tests pass on Python 3.12 and 3.10, including sync/async populated/empty market data and settlement values 0, 0.5 and 1.uv run mypy polymarket_us tests/types— 33 files pass on both Python versions.uv run ruff check .anduv run ruff format --check .pass.uv buildpasses.git diff --check, migration example syntax, and publish classifier checks for default merge, squash, and rebase messages pass.Checklist
pytest)ruff check .)mypy polymarket_us)Note
Medium Risk
Corrects public TypedDict shapes in a breaking way for type-checked consumers, though runtime JSON and HTTP behavior are unchanged.
Overview
Aligns market endpoint typings with the JSON the API already returns, without changing runtime behavior.
markets.book()andmarkets.bbo()(sync and async) are now typed asGetMarketBookResponse/GetMarketBBOResponsewith amarketDatawrapper instead of bareMarketBook/MarketBBO.MarketSettlementis updated toslugand a numericsettlement(replacing the old slug/price/timestamp fields). Nested types addMARKET_STATE_CLOSED, and nullablestats,transactTime, and BBO price fields for empty/closed markets.CI mypy now checks
tests/types, including a consumer fixture that exercises readingmarketDataand settlement. Market tests use pytest-httpx for sync/async wire-equality checks on populated and empty book/BBO payloads and settlement values 0, 0.5, and 1.Typed callers who followed the previous declarations must use
response["marketData"]for book/BBO andsettlement["settlement"]for settlement price.Reviewed by Cursor Bugbot for commit 62da7c5. Bugbot is set up for automated code reviews on this repo. Configure here.