Get current Bitcoin price as an integer?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 2
Joined: Mon May 01, 2017 10:35 am

Get current Bitcoin price as an integer?

Post by slowcheetah » Thu May 25, 2017 3:06 pm

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!

User avatar
Posts: 5144
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: Get current Bitcoin price as an integer?

Post by pythoncoder » Thu May 25, 2017 5:22 pm

You might find some useful hints here
Peter Hinch

User avatar
Posts: 493
Joined: Mon Jun 15, 2015 8:03 am

Re: Get current Bitcoin price as an integer?

Post by mcauser » Sun Jun 04, 2017 12:56 pm

I made this, which get requests the coinbase api, parses the json and outputs on a Nokia 5110 display. ... 10-Bitcoin

Connect to your wifi:

Code: Select all

import network
sta_if = network.WLAN(network.STA_IF);
Install urequests with upip:

Code: Select all

import upip
Reboot and make a get request:

Code: Select all

import urequests

	r = urequests.get("")
	rate = '%d' % r.json()['bpi']['AUD']['rate_float']
except KeyError:
	rate = "0"
Looking at the api, - ZAR is a supported country, so you can get a price by requesting:

Posts: 1
Joined: Mon Nov 18, 2019 11:03 am

Re: Get current Bitcoin price as an integer?

Post by johnmeller » Sun Nov 24, 2019 11:11 am

You can try API from coinbase: 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:

User avatar
Posts: 3
Joined: Tue Apr 13, 2021 9:57 am

Re: Get current Bitcoin price as an integer?

Post by McMoe » Tue Apr 13, 2021 10:05 am

Hi slowcheetah,

i developed a micropython repository for tracking coinprices via That includes bitcoin as well as hundreds of altcoins. Check this repository 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 The API ist live, but the homepage is still under development. Of course you can modify the code using another API if you want.

Post Reply