Created
February 9, 2017 09:48
-
-
Save valichek/6238caa2a49f1b37e764075669502ee3 to your computer and use it in GitHub Desktop.
Google script to get currency rates from NBRB API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function NBRBRates(currency, date) { | |
var formattedDate = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy-M-d"); | |
var url = Utilities.formatString("http://www.nbrb.by/API/ExRates/Rates/%s?onDate=%s&ParamMode=2", currency, formattedDate); | |
var res = UrlFetchApp.fetch(url); | |
res = JSON.parse(res); | |
return res.Cur_OfficialRate; | |
} | |
// how to use | |
// =NBRBRates("EUR";TODAY()) | |
// =NBRBRates("EUR";A1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment