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!
Get current Bitcoin price as an integer?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Get current Bitcoin price as an integer?
You might find some useful hints here https://hackaday.com/2017/05/21/bitcoin-price-ticker/.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Get current Bitcoin price as an integer?
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:
Install urequests with upip:
Reboot and make a get request:
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
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")
Code: Select all
import upip
upip.install('micropython-urequests')
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)
-
- Posts: 1
- Joined: Mon Nov 18, 2019 11:03 am
Re: Get current Bitcoin price as an integer?
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/
https://www.cryptopolitan.com/is-coinbase-safe/
Re: Get current Bitcoin price as an integer?
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 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?
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.McMoe wrote: ↑Tue Apr 13, 2021 10:05 amHi 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.
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.?
Last edited by brittany on Fri Jul 02, 2021 8:46 am, edited 2 times in total.
-
- Posts: 15
- Joined: Mon Jun 14, 2021 12:49 am
Re: Get current Bitcoin price as an integer?
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?
Last edited by katesimon123 on Sun Jul 11, 2021 2:24 am, edited 1 time in total.
Re: Get current Bitcoin price as an integer?
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.
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.