Skip to content

Roll out codegen registry (_endpoints.py) to all client classes #114

Description

@martinkersner

The CexCandle pilot (#113) landed API.request_endpoint(op_id, **params) and the generated datamaxi/_endpoints.py. This issue tracks converting the remaining client classes off hardcoded paths onto the registry, so endpoint paths / methods / path-query split / required params / defaults are single-sourced from the backend spec via datamaxi-codegen.

Scope

~13 modules still hardcode ~41 /api/v… paths. Convert each (follow CexCandle as the template):

  • datamaxi/datamaxi/cex.py
  • datamaxi/datamaxi/cex_announcement.py
  • datamaxi/datamaxi/cex_fee.py
  • datamaxi/datamaxi/cex_symbol.py
  • datamaxi/datamaxi/cex_ticker.py
  • datamaxi/datamaxi/cex_token.py
  • datamaxi/datamaxi/cex_wallet_status.py
  • datamaxi/datamaxi/forex.py
  • datamaxi/datamaxi/funding_rate.py
  • datamaxi/datamaxi/liquidation.py
  • datamaxi/datamaxi/open_interest.py
  • datamaxi/datamaxi/premium.py
  • datamaxi/naver/init.py
  • datamaxi/telegram/init.py

Pattern (per method)

Replace the hardcoded url_path + manual param-dict assembly with self.request_endpoint("<op_id>", **wire_params). Keep hand-written: method signatures, doc-link docstrings, semantic checks (enum-vs-constant like market ∈ [spot, futures], custom error messages), and response shaping (DataFrame conversion). Map Pythonic kwargs to wire names at the call site (e.g. **{"from": from_unix}).

Op_ids: see keys in datamaxi/_endpoints.py (derived from the path, e.g. /api/v1/cex/candlecex_candle).

Decision to settle first

Whether request_endpoint should own required/enum validation (currently the classes still do their own). Owning it in the helper trims more hand code but changes some error messages/behavior (e.g. currency=None would fill the default instead of raising). Pick one policy and apply consistently across the rollout.

Watch out for

  • Reserved-word / renamed params (fromfrom_unix, toto_unix) — map at the call site.
  • Endpoints with in: path params (none in the current spec, but request_endpoint already interpolates them).
  • Keep the existing mocked tests passing unmodified per class — they pin the wire contract (public interface must not change).

Done when

  • No client module hardcodes an /api/v… path (all go through request_endpoint); grep is clean except _endpoints.py.
  • Full suite green (pytest), black/flake8 clean.
  • Public interface unchanged (existing tests pass unmodified).

Related: #113 (pilot), datamaxi-codegen PR #19 (pipeline) and issues #20 (drift-guard automation) / #21 (black-clean emitter).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions