Skip to content

SDK drift: Python fetch_market accepts bare str as market_id shorthand; TypeScript fetchMarket only accepts MarketFetchParams object #1294

Description

@realfishsam

Summary

Python fetch_market accepts a bare str as a shorthand for market_id, automatically wrapping it into {"market_id": params}. TypeScript fetchMarket only accepts a MarketFetchParams object (or undefined); passing a string would be a type error.

Python (sdks/python/pmxt/client.py, line 1422–1426)

def fetch_market(self, params: Optional[Union[dict, str]] = None, **kwargs) -> UnifiedMarket:
    ...
    if isinstance(params, str):
        params = {"market_id": params}  # str shorthand → dict

So Python callers can write either:

exchange.fetch_market("some-market-id")          # str shorthand
exchange.fetch_market({"market_id": "some-id"})  # dict form

TypeScript (sdks/typescript/pmxt/client.ts, line 1056)

async fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket> {
    // No string shorthand — params must be an object or undefined

TypeScript callers must always use the object form:

exchange.fetchMarket({ marketId: "some-market-id" });

Impact

Python's string shorthand is a convenience that TypeScript doesn't match. Code shared between Python and TypeScript (e.g. documentation examples, migration guides) must use the dict/object form only, and this shorthand cannot be documented as a cross-SDK pattern. TypeScript should either add a string overload to fetchMarket, or Python's string shorthand should be removed to unify the API surface.

Metadata

Metadata

Assignees

No one assigned

    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