I am trying to import the following JSON into Google sheets and have the results split into two columns. The data is coin price data from Coingecko.
https://api.coingecko.com/api/v3/coins/invictus/market_chart?vs_currency=usd&days=30&interval=daily
The JSON returns UNIX timestamp data and price in the following format:
"prices":[timestamp , price],[timestamp , price]....
I can import the JSON using the code from
CodePudding user response:
See below answer, and my final solution to include Market Cap data.
url = 'https://api.coingecko.com/api/v3/coins/invictus/market_chart?vs_currency=usd&days=30&interval=daily'
var json = JSON.parse(UrlFetchApp.fetch(url).getContentText())
var data = json.prices
var data2 = json.market_caps
var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('ChartData')
sh.getRange(2,1,data.length,data[0].length).setValues(data)
sh.getRange(2,3,data2.length,data2[0].length).setValues(data2)
}```