Advertisement
RemcoE33

Coins

Jun 30th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getCoins(){
  2.   const ss = SpreadsheetApp.getActiveSpreadsheet()
  3.   const sheet = ss.getSheetByName('Coins')
  4.  
  5.   const response = UrlFetchApp.fetch('https://wallet-api.staging.celsius.network/util/interest/rates')
  6.   const data = JSON.parse(response.getContentText()).interestRates
  7.   const output = [["Coin","Rate","Id","Name","Short"]]
  8.   const images = []
  9.  
  10.   data.forEach(coin => {
  11.     output.push([coin.coin,coin.rate,coin.currency.id,coin.currency.name,coin.currency.short])
  12.     images.push([`=IMAGE("${coin.currency.image_url}")`])
  13.   })
  14.  
  15.   sheet.getDataRange().clearContent()
  16.  
  17.   sheet.getRange(1,1,output.length,5).setValues(output)
  18.   sheet.getRange(1,6).setValue("Image")
  19.   sheet.getRange(2,6,images.length).setFormulas(images)
  20.   sheet.getRange("1:1").setFontWeight('bold')
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement