Feb-17-2022, 04:12 AM
Hello, I'm trying to get information from every individual tag key like symbol, pair, markPrice, IndexPice, bid and so on. Does anybody can help me to iterate over this object to get each value please?
import requests import json req = requests.get('https://futures.kraken.com/derivates/api/v3/tickers') print(type(req)) obj = req.json() print(type(obj)) for k in obj: for x in obj[k]: print(x,k)
Output:<class 'requests.models.Response'>
<class 'dict'>
{'tag': 'perpetual', 'pair': 'XBT:USD', 'symbol': 'pi_xbtusd', 'markPrice': 43529.8, 'bid': 43514.5, 'bidSize': 8976, 'ask': 43545, 'askSize': 5600, 'vol24h': 126116935, 'openInterest': 103754747.0, 'open24h': 43969, 'indexPrice': 43562.01, 'last': 43552.5, 'lastTime': '2022-02-17T04:00:30.649Z', 'lastSize': 4400, 'suspended': False, 'fundingRate': -4.86247209e-10, 'fundingRatePrediction': -2.3744941e-10} tickers
{'tag': 'perpetual', 'pair': 'ETH:USD', 'symbol': 'pi_ethusd', 'markPrice': 3081.38, 'bid': 3080.1, 'bidSize': 7500, 'ask': 3082.6, 'askSize': 400, 'vol24h': 25550994, 'openInterest': 67951298.0, 'open24h': 3142, 'indexPrice': 3082.05, 'last':
3083.8, 'lastTime': '2022-02-17T04:00:28.705Z', 'lastSize': 1, 'suspended': False, 'fundingRate': -7.275179811e-09, 'fundingRatePrediction': 1.707476211e-09} tickers
{'tag': 'perpetual', 'pair': 'LTC:USD', 'symbol': 'pi_ltcusd', 'markPrice': 126.17, 'bid': 126.1, 'bidSize': 2394, 'ask':
126.21, 'askSize': 3120, 'vol24h': 4713388, 'openInterest': 2337699.0, 'open24h': 129.47, 'indexPrice': 126.24, 'last': 126.15, 'lastTime': '2022-02-17T04:00:25.458Z', 'lastSize': 3067, 'suspended': False, 'fundingRate': -2.85598926868e-07, 'fundingRatePrediction': -4.30648001583e-07} tickers
{'tag': 'perpetual', 'pair': 'BCH:USD', 'symbol': 'pi_bchusd', 'markPrice': 330, 'bid': 329.5, 'bidSize': 5077, 'ask': 330.4, 'askSize': 19866, 'vol24h': 633695, 'openInterest': 1175084.0, 'open24h': 335.8, 'indexPrice': 330.07, 'last': 330.4,
'lastTime': '2022-02-17T04:00:32.147Z', 'lastSize': 2, 'suspended': False, 'fundingRate': -1.53118887754e-07, 'fundingRatePrediction': -9.1671839046e-08} tickers
{'tag': 'perpetual', 'pair': 'XRP:USD', 'symbol': 'pi_xrpusd', 'markPrice': 0.821, 'bid': 0.8204, 'bidSize': 5985, 'ask':
0.8215, 'askSize': 3040, 'vol24h': 11796871, 'openInterest': 3107929.0, 'open24h': 0.8358, 'indexPrice': 0.82186, 'last':
0.8223, 'lastTime': '2022-02-17T04:00:22.306Z', 'lastSize': 1940, 'suspended': False, 'fundingRate': 2.0826146090948e-05,
'fundingRatePrediction': -3.69892211193e-06} tickers
{'tag': 'quarter', 'pair': 'XBT:USD', 'symbol': 'fi_xbtusd_220325', 'markPrice': 43532, 'bid': 43515, 'bidSize': 386, 'ask': 43557, 'askSize': 17809, 'vol24h': 3518394, 'openInterest': 10506598.0, 'open24h': 43925, 'indexPrice': 43562.01, 'last': 43510.5, 'lastTime': '2022-02-17T04:00:26.289Z', 'lastSize': 24635, 'suspended': False} tickers
{'tag': 'quarter', 'pair': 'ETH:USD', 'symbol': 'fi_ethusd_220325', 'markPrice': 3083.3, 'bid': 3081.05, 'bidSize': 1171,
'ask': 3085.55, 'askSize': 1171, 'vol24h': 860315, 'openInterest': 10058907.0, 'open24h': 3139, 'indexPrice': 3082.05, 'last': 3088.35, 'lastTime': '2022-02-17T03:59:45.077Z', 'lastSize': 485, 'suspended': False} tickers
{'tag': 'semiannual', 'pair': 'XBT:USD', 'symbol': 'fi_xbtusd_220624', 'markPrice': 44059.5, 'bid': 44024.5, 'bidSize': 1898, 'ask': 44091, 'askSize': 12278, 'vol24h': 3783572, 'openInterest': 10955825.0, 'open24h': 44465.5, 'indexPrice': 43562.01, 'last': 43999.5, 'lastTime': '2022-02-17T03:59:28.568Z', 'lastSize': 74985, 'suspended': False} tickers
{'tag': 'semiannual', 'pair': 'ETH:USD', 'symbol': 'fi_ethusd_220624', 'markPrice': 3117.62, 'bid': 3114.35, 'bidSize': 1098, 'ask': 3120.8, 'askSize': 500, 'vol24h': 137105, 'openInterest': 2870782.0, 'open24h': 3165.2, 'indexPrice': 3082.05,
'last': 3137.1, 'lastTime': '2022-02-17T03:38:51.177Z', 'lastSize': 2822, 'suspended': False} tickers
{'tag': 'quarter', 'pair': 'BCH:USD', 'symbol': 'fi_bchusd_220325', 'markPrice': 326.6, 'bid': 325.7, 'bidSize': 500, 'ask': 327.4, 'askSize': 500, 'vol24h': 9529, 'openInterest': 642708.0, 'open24h': 330.9, 'indexPrice': 330.07, 'last': 333.8, 'lastTime': '2022-02-16T19:40:06.147Z', 'lastSize': 1, 'suspended': False} tickers
{'tag': 'quarter', 'pair': 'XRP:USD', 'symbol': 'fi_xrpusd_220325', 'markPrice': 0.8192, 'bid': 0.8182, 'bidSize': 611, 'ask': 0.8198, 'askSize': 611, 'vol24h': 194494, 'openInterest': 1037273.0, 'open24h': 0.8337, 'indexPrice': 0.82186, 'last': 0.8196, 'lastTime': '2022-02-17T04:00:18.137Z', 'lastSize': 100, 'suspended': False} tickers
{'tag': 'quarter', 'pair': 'LTC:USD', 'symbol': 'fi_ltcusd_220325', 'markPrice': 125.82, 'bid': 125.7, 'bidSize': 8635, 'ask': 125.94, 'askSize': 691, 'vol24h': 331213, 'openInterest': 1342865.0, 'open24h': 129.18, 'indexPrice': 126.24, 'last': 125.89, 'lastTime': '2022-02-17T04:00:25.429Z', 'lastSize': 270, 'suspended': False} tickers
{'tag': 'month', 'pair': 'ETH:USD', 'symbol': 'fi_ethusd_220225', 'markPrice': 3078.08, 'bid': 3075.35, 'bidSize': 1193, 'ask': 3080.75, 'askSize': 500, 'vol24h': 925828, 'openInterest': 323104.0, 'open24h': 3136.55, 'indexPrice': 3082.05, 'last': 3083.2, 'lastTime': '2022-02-17T03:59:45.072Z', 'lastSize': 433, 'suspended': False} tickers
{'tag': 'month', 'pair': 'XBT:USD', 'symbol': 'fi_xbtusd_220225', 'markPrice': 43521.5, 'bid': 43485.5, 'bidSize': 1993, 'ask': 43548.5, 'askSize': 20000, 'vol24h': 1294515, 'openInterest': 2462745.0, 'open24h': 44004.5, 'indexPrice': 43562.01, 'last': 43500, 'lastTime': '2022-02-17T04:00:26.037Z', 'lastSize': 1000, 'suspended': False} tickers
{'tag': 'month', 'pair': 'XRP:USD', 'symbol': 'fi_xrpusd_220225', 'markPrice': 0.8182, 'bid': 0.8175, 'bidSize': 633, 'ask': 0.8191, 'askSize': 633, 'vol24h': 254403, 'openInterest': 87723.0, 'open24h': 0.8326, 'indexPrice': 0.82186, 'last': 0.8197, 'lastTime': '2022-02-17T04:00:22.306Z', 'lastSize': 713, 'suspended': False} tickers
{'tag': 'month', 'pair': 'BCH:USD', 'symbol': 'fi_bchusd_220225', 'markPrice': 328.8, 'bid': 328, 'bidSize': 500, 'ask': 329.7, 'askSize': 500, 'vol24h': 0, 'openInterest': 66712.0, 'indexPrice': 330.07, 'last': 335.7, 'lastTime': '2022-02-15T22:01:38.610Z', 'lastSize': 500, 'suspended': False} tickers
{'tag': 'month', 'pair': 'LTC:USD', 'symbol': 'fi_ltcusd_220225', 'markPrice': 125.84, 'bid': 125.73, 'bidSize': 2925, 'ask': 125.93, 'askSize': 713, 'vol24h': 64124, 'openInterest': 122023.0, 'open24h': 129.14, 'indexPrice': 126.24, 'last': 127.24, 'lastTime': '2022-02-17T03:53:01.815Z', 'lastSize': 1, 'suspended': False} tickers
{'symbol': 'in_xbtusd', 'last': 43562, 'lastTime': '2022-02-17T04:00:35.000Z'} tickers
{'symbol': 'in_xrpusd', 'last': 0.8219, 'lastTime': '2022-02-17T04:00:35.000Z'} tickers
{'symbol': 'in_ethusd', 'last': 3082.05, 'lastTime': '2022-02-17T04:00:35.000Z'} tickers
{'symbol': 'in_ltcusd', 'last': 126.24, 'lastTime': '2022-02-17T04:00:35.000Z'} tickers
{'symbol': 'in_bchusd', 'last': 330.07, 'lastTime': '2022-02-17T04:00:35.000Z'} tickers
{'symbol': 'rr_xbtusd', 'last': 43642, 'lastTime': '2022-02-16T16:00:00.000Z'} tickers
{'symbol': 'rr_xrpusd', 'last': 0.8177, 'lastTime': '2022-02-16T16:00:00.000Z'} tickers
{'symbol': 'rr_ethusd', 'last': 3069.74, 'lastTime': '2022-02-16T16:00:00.000Z'} tickers
{'symbol': 'rr_ltcusd', 'last': 127.43, 'lastTime': '2022-02-16T16:00:00.000Z'} tickers
{'symbol': 'rr_bchusd', 'last': 331.13, 'lastTime': '2022-02-16T16:00:00.000Z'} tickers
Regards!