Skip to content

Instantly share code, notes, and snippets.

@valichek
Created February 9, 2017 09:48
Show Gist options
  • Save valichek/6238caa2a49f1b37e764075669502ee3 to your computer and use it in GitHub Desktop.
Save valichek/6238caa2a49f1b37e764075669502ee3 to your computer and use it in GitHub Desktop.
Google script to get currency rates from NBRB API.
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