简体   繁体   English

交易api数据采集

[英]trade api data collecting

hi there when i type this data嗨,当我输入这些数据时

url = 'https://rest.coinapi.io/v1/quotes/BITSTAMP_SPOT_BTC_USD/current'

headers={'X-CoinAPI-Key' : '73034021-0EBC-493D-8A00-E0F138111F41'}
response = requests.get(url, headers=headers)
x=response.json()
print(x)

my print list is我的打印清单是

{'ask_size': 1.0105962, 'ask_price': 3422.58, 'time_exchange': '2019-02-05T13:11:10.0724918Z', 'symbol_id': 'BITSTAMP_SPOT_BTC_USD', 'bid_size': 2.49846056, 'last_trade': {'uuid': 'a2894632-441e-4ad5-bfb8-c61bd84a724e', 'time_exchange': '2019-02-05T13:10:51.0000000Z', 'size': 0.00553675, 'taker_side': 'BUY', 'price': 3422.58, 'time_coinapi': '2019-02-05T13:10:51.2541019Z'}, 'bid_price': 3421.8, 'time_coinapi': '2019-02-05T13:11:10.0724918Z'}

but i only wanna get taker side and price how can i do it?但我只想得到接受者和价格我该怎么做?

The output of response.json() is a Python dictionary, which means you can access data using the following syntax: response.json()的输出是一个 Python 字典,这意味着您可以使用以下语法访问数据:

resp = response.json()
taker_side = resp['last_trade']['taker_side']
price = resp['last_trade']['price']

You can then use them just like any other variable.然后您可以像使用任何其他变量一样使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM