This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Bitcoin currency
#1
With the script below you can get the current Bitcoin value and compare it with the formaer value.
The script is in Dutch using EUR as acurrency but you can change it to USD or GBP as well.

require('socket.http')
require('json')

socket.http.timeout = 5

data = socket.http.request('http://api.coindesk.com/v1/bpi/currentprice.json')

if data then
 
  datatable = json.pdecode(data)
--log(datatable)
 
  huidige_koers = datatable.bpi.EUR.rate_float --gebruik EUR of GBP of USD
 
  log('Bitcoin actuele koers € ' ..huidige_koers) 
 
  storage.set('bitcoin_actueel', huidige_koers)

  vorige_koers = storage.get('bitcoin_vorige')

  if vorige_koers == nil then
    storage.set('bitcoin_vorige', huidige_koers)
  else
    log('Bitcoin vorige koers € ' ..vorige_koers)
    if vorige_koers == huidige_koers then
      log('Bitcoin koers ongewijzigd')
    elseif
      vorige_koers < huidige_koers then
      log('Bitcoin koers gestegen')
    else
      log('Bitcoin koers gedaald')
    end
    storage.set('bitcoin_vorige', huidige_koers)
  end
end
Reply


Forum Jump: