Skip to content

Instantly share code, notes, and snippets.

@kaskad88
Last active October 1, 2018 15:03
Show Gist options
  • Save kaskad88/c51f5c442e74b5ba61f7c1173038bf10 to your computer and use it in GitHub Desktop.
Save kaskad88/c51f5c442e74b5ba61f7c1173038bf10 to your computer and use it in GitHub Desktop.
function kursnbu( date ) {
if ( ! date ) {
return 0;
}
var apiUrl = 'https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?valcode=USD&date=',
dateApiFormat = Utilities.formatDate(date, "GMT+3", "yyyyMMdd"),
url = apiUrl + dateApiFormat + '&json',
response = UrlFetchApp.fetch( url ),
json = response.getContentText(),
data = JSON.parse(json);
return data[0].rate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment