Skip to content

Typed response models (TypedDict/dataclasses) for endpoint returns #141

Description

@martinkersner

Problem

Endpoints return raw dict/list (or DataFrames), so users index by guessed keys (res["data"][0]["p"]) with no autocomplete or type checking on outputs. PR #136 gave Literal typing to inputs; outputs have none.

Proposal

Add lightweight typed models per response (start with the high-traffic ones: candle, ticker, premium):

  • TypedDict for the dict-return path (cheap, no runtime cost), or
  • dataclasses if we want attribute access + validation.
  • Keep pandas=True DataFrame path as-is.

Notes

  • Could be generated from the same OpenAPI spec that feeds _endpoints.py (codegen upstream) to avoid drift.
  • Incremental: type one endpoint family at a time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions