加密货币相关api的包装
xnr-cryptowrapper的Python项目详细描述
加密包装器
Python 3.7+
PEP8
Async support (without cache)
Handles configurable requests cache, retries and general request errors.
安装:
pip install xnr-cryptowrapper
功能:
围绕原始api命令构建,以允许用户更自由地实现自己的逻辑。
每个api端点都由cryptowrapper类直接提供。
以下文档中包含的详细信息:
Description | |
---|---|
CoinMarketCap.md | Wrapper for the CoinMarketCap API |
CryptoCompare.md | Wrapper for the CryptoCompare API |
BitMEX.md | Wrapper for the BitMEX REST API |
Binance.md | Wrapper for the Binance APIs |
BinanceDEX.md | Wrapper for the Binance DEX API |
Bitfinex.md | Wrapper for the Bitfinex API |
Deribit.md | Wrapper for the Deribit API |
示例:
如果未指定,结果将缓存120秒。
避免错误重试(400、401、403、404、429、500)。
速率限制信息通常出现在响应中,以简化退避策略的实施。
coinmarketcap.global_aggregate_metrics_latest_get()
>>>fromcryptowrapperimportCryptoWrapper>>>api_key="Declare you API key">>>cmc=CryptoWrapper(api="CMC",api_key=api_key,cache_expire=240)>>>cmc_wrapper=cmc.wrapper>>>cmc_wrapper.global_aggregate_metrics_latest_GET(convert="GBP"){'status':{'timestamp':'2019-02-02T10:36:40.928Z','error_code':0,'error_message':None,'elapsed':6,'credit_count':1},'data':{'active_cryptocurrencies':2104,'active_market_pairs':15817,'active_exchanges':235,'eth_dominance':9.87368,'btc_dominance':53.2881,'quote':{'GBP':{'total_market_cap':87645952771.31316,'total_volume_24h':12135287028.006516,'last_updated':'2019-02-02T10:36:00.000Z'}},'last_updated':'2019-02-02T10:27:00.000Z'},'cached':False}
bitmex.chat_get()
>>>fromcryptowrapperimportCryptoWrapper>>>api_key="Declare you API key">>>api_secret="Declare you API secret">>>bitmex=CryptoWrapper(api="BitMEX",api_key=api_key,api_secret=api_secret)>>>bitmex_wrapper=bitmex.wrapper>>>bitmex_wrapper.chat_GET(count=2)[{'id':1,'date':'2014-11-24T12:00:21.539Z','user':'BitMEX_Sam','message':'Welcome to BitMEX! We are live.','html':'Welcome to BitMEX! We are live.','fromBot':False,'channelID':1,'cached':False},{'id':2,'date':'2014-11-24T12:20:29.073Z','user':'BitMEX_Arthur','message':'Hello World','html':'Hello World','fromBot':False,'channelID':1,'cached':False},{'ratelimit':{'limit':'150','remaining':'149','reset':'1549626408'}}]
binance.ping_get()
>>>fromcryptowrapperimportCryptoWrapper>>>binance=CryptoWrapper(api="Binance")>>>binance_wrapper=binance.wrapper>>>binance_wrapper.ping_GET(){'cached':False}
二进制索引getfunctions()
>>>fromcryptowrapperimportCryptoWrapper>>>binance_dex=CryptoWrapper(api="BinanceDEX")>>>binance_dex_wrapper=binance_dex.wrapper>>>binance_dex_wrapper.__getfunctions__()['account_GET','account_sequence_GET','broadcast_POST','fees_GET','klines_GET','markets_GET','node_info_GET','orderbook_GET','orders_closed_GET','orders_id_GET','orders_open_GET','peers_GET','ticker_24h_GET','time_GET','tokens_GET','trades_GET','transaction_GET','transaction_json_GET','transactions_GET','validators_GET']
有关快速组合的示例,请参见:example.py
有关异步版本,请参见:async_example.py
反馈:
我们始终欢迎有建设性的反馈和错误报告。
联系方式: