Skip to content

Spot

Spot groups spot market, account, trade, wallet, rebate, sub-account, and stream methods.

Constructors

new

Create a spot API group with signed endpoint support.

Source code in pkg/src/mexc/spot/__init__.py
@classmethod
def new(
  cls, api_key: str | None = None, api_secret: str | None = None, *,
  base_url: str = MEXC_SPOT_API_BASE,
  ws_url: str = MEXC_SPOT_SOCKET_URL,
  default_validate: bool = True,
):
  """Create a spot API group with signed endpoint support."""
  if api_key is None:
    api_key = os.environ['MEXC_ACCESS_KEY']
  if api_secret is None:
    api_secret = os.environ['MEXC_SECRET_KEY']
  auth_http = AuthHttpClient(api_key=api_key, api_secret=api_secret)
  return cls(api_url=base_url, ws_url=ws_url, auth_http=auth_http, default_validate=default_validate)

public

Create a public-only spot API group.

Source code in pkg/src/mexc/spot/__init__.py
@classmethod
def public(
  cls, *,
  base_url: str = MEXC_SPOT_API_BASE,
  ws_url: str = MEXC_SPOT_SOCKET_URL,
  default_validate: bool = True,
):
  """Create a public-only spot API group."""
  auth_http = AuthHttpClient(api_key='', api_secret='', public=True)
  return cls(api_url=base_url, ws_url=ws_url, auth_http=auth_http, default_validate=default_validate)

Groups