I had used the API to get a data and then asign
to "sol_tvl_df" class.
from defillama import DefiLlama
import requests
import pandas
import ccxt
from math import sqrt
import time
import json
from typing import List, Union
import numpy
_binance = ccxt.binanceusdm()
BASE_URL = "https://api.llama.fi"
class DefiLlama:
"""
DeFi Llama class to act as DeFi Llama's API client.
All the requests can be made through this class.
"""
def __init__(self):
"""
Initialize the object
"""
self.session = requests.Session()
def _send_message(self, method, endpoint, params=None, data=None):
url = BASE_URL + endpoint
response = self.session.request(method, url, params=params, data=data, timeout=30)
return response.json()
sol_tvl_df = DefiLlama()._send_message('GET', '/charts/solana' )
After API request, then I got thos data as below:
print (sol_tvl_df)
[{'date': '1616025600', 'totalLiquidityUSD': 148988798.24},
{'date': '1616112000', 'totalLiquidityUSD': 153204288.86},
{'date': '1616198400', 'totalLiquidityUSD': 147690914.44},
{'date': '1616284800', 'totalLiquidityUSD': 151935325.31},
{'date': '1616371200', 'totalLiquidityUSD': 152981122.24},
{'date': '1616457600', 'totalLiquidityUSD': 162065402.5018374},
{'date': '1616544000', 'totalLiquidityUSD': 156101310.64592892},
{'date': '1616630400', 'totalLiquidityUSD': 144439504.2605513},
{'date': '1616716800', 'totalLiquidityUSD': 135610450.40169644},
{'date': '1616803200', 'totalLiquidityUSD': 147786656.29307032},
{'date': '1616889600', 'totalLiquidityUSD': 172583243.64011288}
.............]
Now, I want to select all part of 'date' to convert to date format of iso8601 for human readable status like
2022-03-22 00:00:00+00:00 then maybe let them to merge into the other data.
I tried so many times and google it, but I didn't get answer.
Would you guys help me, please
I have tried this:
ts_int_list = ( ", ".join( repr(e) for e in sol_tvl_df ) )
ts_int_list = ts_int_list.get(date)