Bitcoin Forum
July 05, 2024, 04:45:14 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Daily Price Download from an API  (Read 68 times)
bethanybeachbum (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 18


View Profile
July 12, 2021, 02:41:06 AM
Merited by bitmover (1)
 #1

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)
nc50lc
Legendary
*
Offline Offline

Activity: 2464
Merit: 5774


Self-proclaimed Genius


View Profile
July 12, 2021, 03:10:18 AM
Merited by hugeblack (4), ABCbits (1), bitmover (1)
 #2

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".

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bitmover
Legendary
*
Online Online

Activity: 2352
Merit: 6100


bitcoindata.science


View Profile WWW
July 12, 2021, 07:11:42 PM
Merited by NeuroticFish (3), ABCbits (1)
 #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

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!