Skip to content

feat: extend typed response models to all documented data endpoints (#141)#147

Merged
martinkersner merged 1 commit into
mainfrom
feat/typed-response-models-all
Jul 3, 2026
Merged

feat: extend typed response models to all documented data endpoints (#141)#147
martinkersner merged 1 commit into
mainfrom
feat/typed-response-models-all

Conversation

@martinkersner

Copy link
Copy Markdown
Member

Follow-up to the candle/ticker pilot (#146) — types the rest of the data endpoints, per your ask to "do it for all."

Added models (datamaxi/resources/responses.py)

AnnouncementRow/Response, TokenUpdateRow/Response, WalletStatusRow, ForexRow, FundingRateRow + FundingHistoryResponse, LatestFundingRate, PremiumDetail (~75 fields, total=False) + PremiumRow + PremiumResponse, TelegramChannel(s)Response, TelegramMessage(s)Response, NaverTrendRow. All exported from the top level.

Each method's return annotation matches its actual pandas=False shape:

  • envelope {"data":[...]}*Response (premium; announcement/token/telegram as the first tuple element; funding history)
  • bare list → List[Row] (wallet status, naver)
  • single object → Row (forex, funding latest)

Type conventions (documented in the module)

  • Fields sourced from the live API docs, not guessed.
  • Typed str to match this API's string-on-the-wire serialization (verified on candle/ticker/funding), with two verified native exceptions: premium booleans t/sms/tmsbool, and naver-trend vint (its payload shows a native 10).
  • PremiumDetail is total=False — AMM-only fields (chain, pool address) are absent for most pairs.
  • Hint-only: no runtime cost, no validation, no behavior change.

Deliberately NOT typed

liquidation, open_interest, margin_borrow, index_price, and cex.symbol.* return raw request_endpoint() dicts and have no published field schema (no docs URL, placeholder-only test mocks). I left them untyped rather than invent field shapes. These are the natural candidates for a future codegen-based pass.

Tests

  • Extended tests/test_response_models.py: field-set assertions for every new model (guards transcription drift) + the native-type exceptions (v:int, premium bools, PremiumDetail.__total__ is False).
  • pytest -m "not integration": 151 passed, 11 skipped.
  • black + flake8 clean.

Caveat (restating)

Hand-authored models can drift if the backend changes; the drift-proof endgame remains emitting them from the upstream OpenAPI codegen. Field names/types reflect the docs as of today — flag any the backend actually returns differently (e.g. if telegram counts are native ints, I'll switch those).

Known failures

None.

…141)

Follow-up to the candle/ticker pilot: add TypedDicts for announcement, token
updates, wallet status, forex, funding rate (history + latest), premium
(incl. ~75-field detail, total=False), telegram channels/messages, and naver
trend; annotate each method's pandas=False return with the matching model
(envelope / bare list / single object per the actual return shape).

Fields sourced from the live API docs. Typed str to match the API's
string-on-the-wire serialization, with two verified native exceptions:
premium booleans (t/sms/tms) and naver trend v (int). Hint-only; no runtime
cost or behavior change. All models exported from the top level.

Endpoints returning raw request_endpoint() dicts without published field
schemas (liquidation, open_interest, margin_borrow, index_price, cex.symbol)
are intentionally left untyped rather than guessed.
@martinkersner martinkersner merged commit e66771a into main Jul 3, 2026
5 checks passed
@martinkersner martinkersner deleted the feat/typed-response-models-all branch July 3, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant