feat!: migrate data reads to the Data API v2 contract - #297
Conversation
… enums Reject an explicit empty user on list_trades, a bare string for activity_types, and an empty leaderboard category, which is now sent as given instead of lowercased. Allow include_archived=False with CLOSED positions and zero-length price history windows, matching the service. Send condition_id on every route. Reject a missing event id on market biggest winners and accept epoch zero on activity rows. Output vocabularies such as PositionStatus, ActivityType, and ResolutionStatus are StrEnum types, with *Filter and *Input aliases that keep plain-string inputs working. Live volume is documented in shares. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Date-only ISO strings on combo leg markets and resolutions parse as midnight UTC instead of naive datetimes, which also removes the frames warning. Market biggest winners require a positive decimal event id. Covers the end-before-start price window and enum-member inputs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Reviewed the Data API v2 migration across all four clients, including pagination, response models, retries, and the backend contract. The overall structure looks good, and the unit suite, lint, and type checks passed during review. There are two request-contract edge cases I’d like addressed before merging: 1.
Consequently, requesting full history can return fewer holdings than the default request, without any error. Please handle the positions case separately by omitting both bounds for full history, while retaining validation against combining it with explicit bounds. The other feeds have different default-window semantics, so I wouldn’t change the shared helper globally. A regression covering a holding without an activity timestamp would pin this. 2. Combo synchronization no longer accepts zero watermarks.
This breaks callers initializing synchronization with One documentation correction: One non-blocking convention question: the new |
Decided to add a rule to keep full_history boolean at AGENTS.md to be on par with ts-sdk |
Migrates portfolio, activity, analytics, price history, and leaderboards to cursor-paginated Data API v2 across all four clients. Adds bounded 429 retries and typed metrics/resolutions. Port pinned to ts-sdk
6e5c293(upstream rechecked).BREAKING CHANGE: removes
list_closed_positions,list_market_positions,get_traded_market_count, andget_price_history; uselist_positions,get_user_stats, andlist_price_history. Renamesget_portfolio_values→get_portfolio_value,get_market_holders→list_market_holders, andget_event_live_volumes→get_event_live_volume. Fields/frame columns usecurrent_size,current_price, explicit cost/PnL fields,wallet,taker_volume_total,volume, and builder names/calendar dates; legacy token aliases remain. Default page size is 100 (history: 10000). Leaderboard windows are lowercase; ranks are integers.Validation: 2,331 unit tests; 15 live data workflows (production data, staging auth); Ruff, Pyright, Sphinx, pandas/Polars. Full integration suite has 24 failures and four non-data setup errors reproduced on untouched main with the supplied credentials.
Before merge: confirm the intended release version (
bump-minor-pre-majoris unset). Supersedes #270 and #272. Follow-ups: #298 and #299.Note
High Risk
Large breaking change across all four clients—pagination, method names, and position field names will break existing integrations; core portfolio and history reads now depend on new v2 semantics and validation rules.
Overview
BREAKING: Portfolio, activity, analytics, leaderboards, and price history now go through Data API v2 (
/v2/*) with cursor keyset pagination (default page size 100; price history default 10000). Offset-paginated v1 data paths and several standalone endpoints are removed or folded into unified methods.Public API reshaping:
list_closed_positionsandlist_market_positionsare gone—uselist_positionswithstatus="CLOSED"or a singlecondition_id.get_traded_market_countis replaced byget_user_stats. CLOBget_price_historyis removed in favor oflist_price_historyon the data service (interval, bounded window, oras_of). Renames includeget_portfolio_values→get_portfolio_value, holders aslist_market_holders, andget_event_live_volume(plural volumes removed). Filters shift frommarkettocondition_id, with shared param builders for condition IDs, event IDs, and timezone-awarestart/end.full_historyremains on trades, activity, positions, and user volume (documented as a narrow exception).New capabilities: user PnL/volume series, resolutions lookup, biggest winners, trader leaderboard standing, expanded builder volume buckets, and typed filter/sort aliases (
LeaderboardWindow,PositionStatusFilter, etc.). Data models and analytics types are re-exported frompolymarket.models.data.Models & internals:
Positionusescurrent_size/current_price(relayer merge logic updated). v2 responses parse throughdata+paginationenvelopes; data reads get bounded 429 retries. Examples and SDK direction docs reflect the new field names and enum input/output patterns.Reviewed by Cursor Bugbot for commit d8aaa92. Bugbot is set up for automated code reviews on this repo. Configure here.