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.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

mexc_api-0.0.2-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file mexc-api-0.0.2.tar.gz.

File metadata

  • Download URL: mexc-api-0.0.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for mexc-api-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ad2f284663a57f73ff2743544f4b6cdef93fcf7784b7a24d6e14aee39cc12e3f
MD5 6c7b46b71129520bf0207ffda46a9ed6
BLAKE2b-256 b3cfee43ad19b73fc86a2f7219658441262e382d9975f0ae3e6b358b67ca2660

See more details on using hashes here.

File details

Details for the file mexc_api-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mexc_api-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for mexc_api-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8db9457b21070747cf5bb3ee1b55afdd75bcad378ab6a760d7e736933caad563
MD5 3cdd01ae5ed546d24ed9e1af0e043f96
BLAKE2b-256 51bb2ca7d94e82eadaffada15657148d32092bf0eee2a3d587dee3d3f02feca3

See more details on using hashes here.

Supported by

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