与BitCoinAverage API集成的库
bitcoinaverage的Python项目详细描述
BitcoinAverage PIP库
这里我们提供两个示例-第一个示例显示如何调用函数,该函数向restful api发出http请求,另一个示例连接到一个websocket。您只需要输入您的公钥和密钥,就可以运行此示例了。
官方文件:https://apiv2.bitcoinaverage.com 关于github的更多示例:https://github.com/bitcoinaverage/api-integration-examples/
http示例
#!python
from bitcoinaverage import RestfulClient
if __name__ == '__main__':
public_key = 'your_public_key'
secret_key = 'your_secret_key'
restful_client = RestfulClient(secret_key, public_key)
ticker_global_per_symbol = restful_client.ticker_global_per_symbol('BTCUSD')
print('Global Ticker for BTCUSD:')
print(ticker_global_per_symbol)
WebSocket v1示例
#!python
from bitcoinaverage import TickerWebsocketClient
if __name__ == '__main__':
public_key = 'your_public_key'
secret_key = 'your_secret_key'
print('Connecting to the ticker websocket...')
ws = TickerWebsocketClient(public_key, secret_key)
ws.ticker_data('local', 'BTCUSD')
WebSocket v2示例
版本2 WebSocket客户端分别接受加密货币列表和交换列表。 他们还使用新的优化算法,以更快的更新。
股票代码
#!python
from bitcoinaverage import TickerWebsocketClientV2
if __name__ == '__main__':
public_key = 'your_public_key'
secret_key = 'your_secret_key'
print('Connecting to the ticker websocket...')
ws = TickerWebsocketClientV2(public_key, secret_key)
ws.ticker_data('local', ['BTCUSD', 'ETHUSD'])
交换
#!python
from bitcoinaverage import ExchangeWebsocketClientV2
if __name__ == '__main__':
public_key = 'your_public_key'
secret_key = 'your_secret_key'
print('Connecting to the exchange websocket...')
ws = ExchangeWebsocketClientV2(public_key, secret_key)
ws.ticker_data(['bitstamp', 'gdax'])