Author

Topic: Bitcoin Daily Price Download from an API (Read 89 times)

legendary
Activity: 2352
Merit: 6089
bitcoindata.science
July 12, 2021, 02:11:42 PM
#3
You can also use Coindesk API, whicih allows you to choose the currency and the interval you want to download.

For example, you can get Bitcoin in EUR since 2011:

https://api.coindesk.com/v1/bpi/historical/close.json?currency=EUR&start=2011-01-01&end=2021-07-12

This is the best historical price API i have found.

Documentation here:
https://www.coindesk.com/coindesk-api
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
blockchain.com's API has one: https://www.blockchain.com/charts/market-price?format=json
You can also visit the URL and download the data manually, you can choose from JSON or CSV format in the drop-down menu named "Export Data".
newbie
Activity: 11
Merit: 18
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)
Jump to: