I would like to be able to pull historical daily bitcoin price from an API like coinbase.
I created this simple python file to retrieve realtime bitcoin price and print to screen every two seconds:
Can anyone direct me to a URL that pulls historical daily bitcoin price so i can save it to a file?
from time import sleep
from datetime import datetime
import requests
import json
while True:
response = requests.get('
https://api.coinbase.com/v2/prices/BTC-USD/spot')
data = response.json()
x = (data["data"]["base"])
y = ( data["data"]["amount"])
print(' =======================')
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print("Current Time =", current_time)
print (x + ' ' + y)
sleep(2)