0

Currency Conversion

Has anyone successfully implemented the European Central Bank's currency API for getting real-time currency exchange rates to use in a Ninox database?

I managed to use fixer.io to calculate the price a 3 services (VO, TL, and PR) based on the character count of a text field (Characters). I put the following code in the "On Click" field of a button field:

let mykey := "-redacted-";

let response := http("GET", "http://data.fixer.io/api/latest?access_key=" + mykey + "&base=EUR&symbols=USD,HUF");

if response.error then

alert(text(response.error))

else

let fx := response.result;

let fxusd := fx.rates.USD;

let fxhuf := fx.rates.HUF;

let fxusdx := round(sqrt(Characters / 5 / 3 / 60 / 0.000045) / 10) * 10;

let fxeurx := round(number(fxusdx) / number(fxusd) / 10) * 10;

let fxhufx := round((number(fxusdx) / number(fxusd) * number(fxhuf)) / 1000) * 1000;

let hufPR := ceil(Characters / 100) * 300;

let hufTL := ceil(Characters / 100) * 600;

'VO (USD)' := fxusdx;

'VO (EUR)' := fxeurx;

'VO (HUF)' := fxhufx;

'PR (HUF)' := hufPR;

'TL (HUF)' := hufTL

end

 

Then I discovered that the ECB has a similar API which I'd love to implement, seeing as it seems to be free for unlimited use without registration. (fixer.io has a limit of up to 1000 calls per month for registered users of the free service).

 

Please forgive the less inefficient math. We are still working on the pricing formula logic. Also, fixer.io calculates everything from EUR as a base currency.

1 reply

null
    • Admin.7
    • 2 yrs ago
    • Reported - view

    I would like to have the same 

Content aside

  • 2 yrs agoLast active
  • 1Replies
  • 592Views