【发布时间】:2021-08-03 13:23:09
【问题描述】:
我尝试从从加密货币价格代码的 api 请求获得的列表中过滤掉一些特定数据。
这会打印所有数据:
import requests, json
r = requests.get('https://api.bitvavo.com/v2/ticker/price')
data = r.json()
print (data)
但我只需要“BTC-EUR”和“ETH-EUR”市场的价格。
这是来自 API 的数据:
[{"market":"AAVE-EUR","price":"258.99"},{"market":"ADA-BTC","price":"0.000021401"},{"market":"ADA-EUR","price":"1.0998"},{"market":"AE-BTC","price":"0.0000031334"},{"market":"AE-EUR","price":"0.064378"},{"market":"AION-BTC","price":"0.000004433"},{"market":"AION-EUR","price":"0.10173"},{"market":"ANT-BTC","price":"0.00011591"},{"market":"ANT-EUR","price":"3.1229"},{"market":"ARK-BTC","price":"0.000024647"},{"market":"ARK-EUR","price":"0.945"},{"market":"BAL-EUR","price":"17.716"},{"market":"BAND-EUR","price":"5.4089"},{"market":"BAT-BTC","price":"0.000020403"},{"market":"BAT-EUR","price":"0.53508"},{"market":"BCH-BTC","price":"0.0091659"},{"market":"BCH-EUR","price":"448.27"},{"market":"BSV-BTC","price":"0.0036256"},{"market":"BSV-EUR","price":"116.89"},{"market":"BTC-EUR","price":"32574"},{"market":"CHZ-EUR","price":"0.2181"},{"market":"CMT-BTC","price":"0.000000095639"},{"market":"CMT-EUR","price":"0.027029"},{"market":"COMP-EUR","price":"333.45"},{"market":"DAI-EUR","price":"0.8424"},{"market":"DCR-BTC","price":"0.002769"},{"market":"DCR-EUR","price":"110.82"},{"market":"DGB-BTC","price":"0.0000012116"},{"market":"DGB-EUR","price":"0.041454"},{"market":"DOT-EUR","price":"14.545"},{"market":"ELF-BTC","price":"0.0000060815"},{"market":"ELF-EUR","price":"0.21208"},{"market":"ENJ-BTC","price":"0.000044049"},{"market":"ENJ-EUR","price":"1.1605"},{"market":"EOS-BTC","price":"0.000072182"},{"market":"EOS-EUR","price":"3.3319"},{"market":"ETC-BTC","price":"0.0002102"},{"market":"ETC-EUR","price":"42.069"},{"market":"ETH-BTC","price":"0.030931"},{"market":"ETH-EUR","price":"2113.9"},{"market":"FET-EUR","price":"0.332"},{"market":"GAS-BTC","price":"0.00020596"},{"market":"GAS-EUR","price":"6.6111"},{"market":"GLM-EUR","price":"0.30293"},{"market":"GNO-EUR","price":"160.32"},{"market":"GNT-BTC","price":"0.000005145"},{"market":"GNT-EUR","price":"0.09968"},{"market":"HOT-BTC","price":"0.00000013588"},{"market":"HOT-EUR","price":"0.0051574"},{"market":"ICX-BTC","price":"0.000033193"},{"market":"ICX-EUR","price":"0.82902"},{"market":"IOST-BTC","price":"0.00000083881"},{"market":"IOST-EUR","price":"0.020588"},{"market":"KMD-BTC","price":"0.000030016"},{"market":"KMD-EUR","price":"0.686"},{"market":"KNC-EUR","price":"1.3403"},{"market":"LINK-BTC","price":"0.00051778"},{"market":"LINK-EUR","price":"19.137"},{"market":"LOOM-EUR","price":"0.06653"},{"market":"LRC-BTC","price":"0.00001021"},{"market":"LRC-EUR","price":"0.20504"},{"market":"LSK-BTC","price":"0.000064109"},{"market":"LSK-EUR","price":"2.6978"},{"market":"LTC-BTC","price":"0.0034759"},{"market":"LTC-EUR","price":"116.79"},{"market":"MANA-EUR","price":"0.58193"},{"market":"MIOTA-BTC","price":"0.000022837"},{"market":"MIOTA-EUR","price":"0.73894"},{"market":"MKR-EUR","price":"2366.8"},{"market":"NANO-BTC","price":"0.000088476"},{"market":"NANO-EUR","price":"3.6449"},{"market":"NAS-BTC","price":"0.000015282"},{"market":"NAS-EUR","price":"0.28762"},{"market":"NEO-BTC","price":"0.00076305"},{"market":"NEO-EUR","price":"35.342"},{"market":"NMR-EUR","price":"37.275"},{"market":"NPXS-BTC","price":"0.000000080918"},{"market":"NPXS-EUR","price":"0.0063093"},{"market":"NULS-BTC","price":"0.00001495"},{"market":"NULS-EUR","price":"0.33311"},{"market":"OGN-EUR","price":"0.65464"},{"market":"OMG-BTC","price":"0.00010162"},{"market":"OMG-EUR","price":"3.5235"},{"market":"ONG-BTC","price":"0.000013713"},{"market":"ONG-EUR","price":"0.64352"},{"market":"ONT-BTC","price":"0.00002071"},{"market":"ONT-EUR","price":"0.66787"},{"market":"OXT-EUR","price":"0.23841"},{"market":"POWR-BTC","price":"0.0000063743"},{"market":"POWR-EUR","price":"0.22833"},{"market":"PUNDIX-EUR","price":"1.3019"},{"market":"QTUM-BTC","price":"0.00011871"},{"market":"QTUM-EUR","price":"6.554"},{"market":"RDD-BTC","price":"0.00000006"},{"market":"RDD-EUR","price":"0.0029025"},{"market":"REN-EUR","price":"0.35152"},{"market":"REP-EUR","price":"20.646"},{"market":"REQ-BTC","price":"0.0000027979"},{"market":"REQ-EUR","price":"0.049529"},{"market":"RLC-EUR","price":"2.7609"},{"market":"RSR-EUR","price":"0.029507"},{"market":"RVN-BTC","price":"0.000003409"},{"market":"RVN-EUR","price":"0.055052"},{"market":"SNT-BTC","price":"0.0000017591"},{"market":"SNT-EUR","price":"0.066089"},{"market":"SNX-EUR","price":"7.672"},{"market":"STEEM-BTC","price":"0.0000092917"},{"market":"STEEM-EUR","price":"0.4"},{"market":"STMX-BTC","price":"0.00000083031"},{"market":"STMX-EUR","price":"0.017834"},{"market":"STORJ-EUR","price":"0.84081"},{"market":"STORM-BTC","price":"0.00000032019"},{"market":"STORM-EUR","price":"0.0028761"},{"market":"STRAT-BTC","price":"0.000038581"},{"market":"STRAT-EUR","price":"0.41621"},{"market":"STRAX-EUR","price":"1.59"},{"market":"SUSHI-EUR","price":"6.8024"},{"market":"SXP-EUR","price":"1.8182"},{"market":"TRB-EUR","price":"32.783"},{"market":"TRX-BTC","price":"0.00000093686"},{"market":"TRX-EUR","price":"0.05386"},{"market":"UMA-EUR","price":"7.2881"},{"market":"UNI-EUR","price":"17.943"},{"market":"USDC-EUR","price":"0.84219"},{"market":"USDT-EUR","price":"0.8388"},{"market":"UTK-EUR","price":"0.19191"},{"market":"VET-BTC","price":"0.0000014302"},{"market":"VET-EUR","price":"0.070825"},{"market":"VTC-BTC","price":"0.000010824"},{"market":"VTC-EUR","price":"0.42721"},{"market":"VTHO-BTC","price":"0.0000001866"},{"market":"VTHO-EUR","price":"0.005126"},{"market":"WAVES-BTC","price":"0.00017881"},{"market":"WAVES-EUR","price":"13.344"},{"market":"WTC-BTC","price":"0.000028721"},{"market":"WTC-EUR","price":"0.46438"},{"market":"XEM-BTC","price":"0.0000063552"},{"market":"XEM-EUR","price":"0.13628"},{"market":"XLM-BTC","price":"0.0000068038"},{"market":"XLM-EUR","price":"0.22757"},{"market":"XRP-BTC","price":"0.0000080191"},{"market":"XRP-EUR","price":"0.60536"},{"market":"XTZ-BTC","price":"0.000072727"},{"market":"XTZ-EUR","price":"2.5732"},{"market":"XVG-BTC","price":"0.00000055161"},{"market":"XVG-EUR","price":"0.019311"},{"market":"YFI-EUR","price":"26489"},{"market":"YFII-EUR","price":"3468.8"},{"market":"ZIL-BTC","price":"0.0000031492"},{"market":"ZIL-EUR","price":"0.066433"},{"market":"ZRX-BTC","price":"0.00002664"},{"market":"ZRX-EUR","price":"0.6746"},{"market":"SOL-EUR","price":null}]
我尝试了很多选择。但是我还没有找到解决办法。
期待您的回答。
【问题讨论】:
-
你能分享一下你尝试过的两个选项吗?
标签: python json api python-requests