Page 1 of 1

Get current Bitcoin price as an integer?

Posted: Thu May 25, 2017 3:06 pm
by slowcheetah
I want to try something out:

An ESP module that constantly checks the current bitcoin price and compares it to the previous value, whereafter it turns on either a red led if it's lower or a green one if it's higher. The logic for the script seems pretty easy for me, except for which option would be best for actually getting the current Bitcoin value in my own currency, which is ZAR (South African Rand).

First thing I can think of is with a GET request, but I'm a little unsure about how to go about getting that actual value into Micropython.

If I do a straightforward Google search with: 'bitcointozar' in my browser, I get the value I'm looking for. How does that translate to the microcontroller doing the search instead of me in a browser? I've been trying with the urequests module, but I'm a little lost. any nudge in the right direction would be awesome, thanks!

Re: Get current Bitcoin price as an integer?

Posted: Thu May 25, 2017 5:22 pm
by pythoncoder
You might find some useful hints here https://hackaday.com/2017/05/21/bitcoin-price-ticker/.

Re: Get current Bitcoin price as an integer?

Posted: Sun Jun 04, 2017 12:56 pm
by mcauser
I made this, which get requests the coinbase api, parses the json and outputs on a Nokia 5110 display.
https://github.com/mcauser/MicroPython- ... 10-Bitcoin

Connect to your wifi:

Code: Select all

import network
sta_if = network.WLAN(network.STA_IF);
sta_if.active(True)
sta_if.scan()
sta_if.connect("ssid","pass")
Install urequests with upip:

Code: Select all

import upip
upip.install('micropython-urequests')
Reboot and make a get request:

Code: Select all

import urequests

try:
	r = urequests.get("http://api.coindesk.com/v1/bpi/currentprice/AUD.json")
	rate = '%d' % r.json()['bpi']['AUD']['rate_float']
	r.close()
except KeyError:
	rate = "0"
print(rate)
Looking at the api, http://www.coindesk.com/api/ - ZAR is a supported country, so you can get a price by requesting: http://api.coindesk.com/v1/bpi/currentprice/ZAR.json

Re: Get current Bitcoin price as an integer?

Posted: Sun Nov 24, 2019 11:11 am
by johnmeller
You can try API from coinbase: https://developers.coinbase.com/api/v2. However, I haven't used it till now, so I can't say how safe or trustworthy it is. You may want to read about safety of coinbase here:
https://www.cryptopolitan.com/is-coinbase-safe/

Re: Get current Bitcoin price as an integer?

Posted: Tue Apr 13, 2021 10:05 am
by McMoe
Hi slowcheetah,

i developed a micropython repository for tracking coinprices via api.mcmoe.de. That includes bitcoin as well as hundreds of altcoins. Check this repository https://github.com/McMoes/Crypto-Ticker. You can install it on your esp32 and display realtime prices on max7219 displays. Pecentage development is an option too. If you want to test something via the used API don't hesitate to contact support@mcmoe.de. The API ist live, but the homepage is still under development. Of course you can modify the code using another API if you want.

Re: Get current Bitcoin price as an integer?

Posted: Tue Jun 29, 2021 9:28 am
by brittany
McMoe wrote:
Tue Apr 13, 2021 10:05 am
Hi slowcheetah,

i developed a micropython repository for tracking coinprices via api.mcmoe.de. That includes bitcoin as well as hundreds of altcoins. Check this repository https://github.com/McMoes/Crypto-Ticker. You can install it on your esp32 and display realtime prices on max7219 displays. Pecentage development is an option too. If you want to test something via the used API don't hesitate to contact support@mcmoe.de. The API ist live, but the homepage is still under development. Of course you can modify the code using another API if you want.
I used the API from blockchain.info for getting Bitcoin price data. From a quick glance at their site, it looks like they also offer Ethereum and BCH data.
Updated: I just came across a crypto bot . It is a bot that will trade for you on binance. I suck pretty bad at trading - so, I thought I could find something that could work for me. Tried to research it for some reviews about it . - I think it has a low internet profile right now but it has some good feature any one heard of it.?

Re: Get current Bitcoin price as an integer?

Posted: Tue Jun 29, 2021 12:12 pm
by katesimon123
brittany wrote:
Tue Jun 29, 2021 9:28 am
I used the API from blockchain.info for getting Bitcoin price data. From a quick glance at their site, it looks like they also offer Ethereum and BCH data.
There must be some data limit on it as on all Blockchain Technology related stuff, how many queries you can make per month for free?

Re: Get current Bitcoin price as an integer?

Posted: Thu Jul 01, 2021 8:06 am
by McMoe
Hi katesimon123,

at www.mcmoe.de you can contact them via the contact form at the page (https://www.mcmoe.de/en/contact/), explaining what your needs are and that you would like to test their api. They will reply with a free plan to you having up to 50 - 100 calls a day for free. Altcoin data included, of course, not Bitcoin only.


Hope that helps.