A wrapper for the Mexc rest and websocket api.
Project description
Mexc api
Python wrapper for the Mexc api
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
Release history Release notifications | RSS feed
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 details)
Built Distribution
mexc_api-0.0.1-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file mexc-api-0.0.1.tar.gz
.
File metadata
- Download URL: mexc-api-0.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b530b1dda14e85f1ebaa104b8e83fbe72d35c06a5524f8ac297a6498a2dd210c
|
|
MD5 |
2f661b86d6eda39631082d782c5db7ac
|
|
BLAKE2b-256 |
df0a2a32dfcc111f29b8bcfdcc122b63d58d0a194f9f5b4e83eceaae7e8e9686
|
File details
Details for the file mexc_api-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: mexc_api-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8efb193c90ffa558de1e6be9c290fc388b8331612cffd144ecfc1e8c05be04c0
|
|
MD5 |
bf4cb1bedd7cfd7bd992b770ba481f5a
|
|
BLAKE2b-256 |
f583da44680f4e581a25fe0132a1d2bdd96f73ec671e4027d0b6347f5c737f2a
|