I want to obtain historical data from charts, that are available online to turn the data into features for model training. I am aware of APIs on various platforms, but free APIs usually do not offer fetching long periods of historical data. The data I want to scrap is on this website: https://coincodex.com/market-cap/ I was able to inspect it and literally find the data, copy it and paste into some sort of file for future processing, e.g. real data
But I would like to automate this process and (hopefully, some beautiful day) I would love to be able to repeat it for multiple different charts.
import requests, json
import pandas as pd
params = {'charts':'ALL',
'samples':'md',
'assets':'SUM_ALL_COINS',
'include':'market_cap',
't':'5693598'}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0'}
data = requests.get(url=coincodex_url, params=params, headers=headers)
data.text
In this data.text
I was able to find ...SUM_ALL_COINS...
. The data inside this dict contained small amount of points and I assume this is not the right approach. When I tried to get the chart url via requests I did not work, because I think it is calling the api, which I cannot reach without having a key.
data = requests.get(url=r'https://coincodex.com/api/v1/assets/get_charts?charts=ALL&samples=md&assets=SUM_ALL_COINS&include=market_cap&t=5693614', params=params, headers=headers)
Would somebody suggest me a way of getting that data?
Here is an example how you can load the data from the URL to a pandas dataframe:
Prints: