以下有一些轻量级的代码库,使用不同语言的用户能够直接调用BitMart API。 支持所有 BitMart REST API 和 WebSockets 的官方SDK。
from bitmart.api_spot import APISpot from bitmart.lib import cloud_exceptions if __name__ == '__main__': api_key = "Your API KEY" secret_key = "Your Secret KEY" memo = "Your Memo" try: spotAPI = APISpot(api_key, secret_key, memo, timeout=(3, 10)) response = spotAPI.post_submit_order( symbol='BTC_USDT', side='sell', type='limit', size='10000', price='1000000' ) except cloud_exceptions.APIException as apiException: print("Error[HTTP<>200]:", apiException.response) except Exception as exception: print("Error[Exception]:", exception) else: if response[0]['code'] == 1000: print('Call Success:', response[0]) else: print('Call Failed:', response[0]['message'])
使用方法:
步骤 1:安装 Python 3.x 运行环境
步骤 2:安装依赖
步骤 3:保存示例代码
步骤 4:执行
步骤 5:检查结果