api:…
- User
api: https://api.cryptodatadownload.com/v1/data/ohlc/binance/guest/spot/available?_=1710763945638 the provided api returns list of all available files , and download link for each file came as “file” parameter like :
{ “data”: [ { “symbol”: “1INCHBTC”, “timeframe”: “hour”, “start_date”: “2020-12-25 05:00:00”, “end_date”: “2024-03-16 23:00:00”, “file”: “https://www.cryptodatadownload.com/cdd/Binance_1INCHBTC_1h.csv” }, { “symbol”: “1INCHBTC”, “timeframe”: “2021 minute”, “start_date”: “2021-01-01 00:00:00”, “end_date”: “2023-03-26 23:59:00”, “file”: “https://www.cryptodatadownload.com/cdd/Binance_1INCHBTC_2021_minute.csv” },
give me the proper code to fetch the download links from provided api and download them
- Assistant
- User
whrer will this downloaded files be saved?
- Assistant
The downloaded files in the provided code example will be saved in the same directory where the Python script is executed. This is because the filename derived from the URL is used directly without specifying a different path:
pythonwith open(filename, 'wb') as f: f.write(file_response.content) - User
downloading speed is slow how can i make my code download them faster
- Assistant
- User
how to check if the file exist before downloading it?
- Assistant