idex rest api python实现
python-idex的Python项目详细描述
这是一个用于IDEX exchanges REST API v1的非正式python包装器。我不属于IDEX,使用风险自负。
- pypi
- https://pypi.python.org/pypi/python-idex
- 源代码
- https://github.com/sammchardy/python-idex
- 文档
- https://python-idex.readthedocs.io/en/latest/
功能
- 实现除存款之外的所有rest端点。
- 钱包地址的帮助功能
- 响应异常处理
- 用于Python3.5+的WebSocket
升级
如果您使用的是较旧版本的python idex<;1.0.0,则需要为rest客户端使用api密钥 和WebSocket客户端。见下面的例子。
同步示例
api_key='api:jVXLd5h1bEYcKgZbQru2k'address='<address_string>'private_key='<private_key_string>'fromidex.clientimportClientclient=Client(api_key,address,private_key)# get currenciescurrencies=client.get_currencies()# get market depthdepth=client.get_order_book('ETH_SENT')# get your balancesbalances=client.get_my_balances()# get your open ordersorders=client.get_my_open_orders('ETH_SENT')# create a limit orderorder=client.create_order('SENT','ETH','0.001','10000')
python 3.5+的异步示例
fromidex.asyncioimportAsyncClient,IdexSocketManager,SubscribeCategoryloop=Noneasyncdefmain():globalloop# Initialise the clientclient=awaitAsyncClient(api_key,address,private_key)# get currenciescurrencies=awaitclient.get_currencies()# get market depthdepth=awaitclient.get_order_book('ETH_SENT')# get your balancesbalances=awaitclient.get_my_balances()# get your open ordersorders=awaitclient.get_my_open_orders('ETH_SENT')# create a limit orderorder=awaitclient.create_order('SENT','ETH','0.001','10000')# Coroutine to receive messagesasyncdefhandle_evt(msg):print(f"event:{msg['event']} payload:{msg['payload']}")# do something with this event# Initialise the socket manager with the callback funcitonism=awaitIdexSocketManager.create(loop,handle_evt,api_key)# Subscribe to updates for the ETH_SENT, ETH_AURA and ETH_IDXM market for cancels, orders and tradesawaitism.subscribe(SubscribeCategory.markets,['ETH_SENT','ETH_AURA','ETH_IDXM'],['market_cancels','market_orders','market_trades'])# keep the script running so we can retrieve websocket eventswhileTrue:awaitasyncio.sleep(20,loop=loop)if__name__=="__main__":# get a loop and switch from synchronous to asyncloop=asyncio.get_event_loop()loop.run_until_complete(main())
待办事项
- 存款端点
捐赠
如果这个图书馆帮了你,你可以随意捐赠。
- ETH:0xD7A7FDDCFA687073D7CC93E9E51829A727F9FE70
- 近地天体:avjb4zgn7vgsutarct94y7zyt6d5ndfpbo
- ltc:lpc5vw9ajr1ynde1hyveo3kj9ldhjcruz
- BTC:1dknp6l6orzrhdecredihpzx2ssfmvebys
其他交易所
如果您使用Binance请查看我的python-binance库。
如果您使用Binance Chain请查看我的python-binance-chain库。
如果您使用Kucoin请查看我的python-kucoin库。
如果使用Quoinex 或者Qryptos查看我的python-quoine库。
如果您使用Allcoin请查看我的python-allucoin库。
如果您使用Exx请查看我的python-exx库。
如果您使用BigONE请查看我的python-bigone库。