Skip to main content

A wrapper for the Mexc rest and websocket api.

Project description

Mexc api

Python wrapper for the Mexc api

Documentation Status

mexc docs

Usage

Requirements

  • Python 3.11 or newer
  • requests
  • websocket-client

installation

pip install mexc-api

api key

generate an api key here: https://www.mexc.com/user/openapi

Example

import time
from mexc_api.spot import Spot
from mexc_api.websocket import SpotWebsocketStreamClient
from mexc_api.common.enums import Side, OrderType, StreamInterval, Action
from mexc_api.common.exceptions import MexcAPIError

KEY = "<KEY>"
SECRET = "<KEY>"

spot = Spot(KEY, SECRET)

server_time = spot.market.server_time()
print(server_time)

order_book = spot.market.order_book("MXUSDT")
print(order_book)

order = spot.account.test_new_order(
    "MXUSDT",
    Side.BUY,
    OrderType.LIMIT,
    '1',
    price='1'
)
print(order)

ws = SpotWebsocketStreamClient(
    KEY,
    SECRET,
    on_message=print
)
time.sleep(1)
ws.klines("MXUSDT", StreamInterval.ONE_MIN)
ws.account_orders()

time.sleep(5)
ws.account_orders(Action.UNSUBSCRIBE)
ws.klines("MXUSDT", StreamInterval.ONE_MIN, Action.UNSUBSCRIBE)
ws.stop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mexc-api-0.0.1.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

mexc_api-0.0.1-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page