我有以下脚本从 Poloniex JSON 输出中提取键,但没有将与键对应的实际数据放入实际工作表中……它只是将键作为标题放在工作表的顶部。
我是 API 和 GAS 以及一般编码的新手,所以我确信我遗漏了一些非常明显的东西,如果你能指出什么,我将不胜感激。
提前致谢
function Bitcoin_fromPolo_toCSV() {
//Link the script with a spreasdsheet using the identifier found in the spreadsheet url
var ss = SpreadsheetApp.openById('1cubxxxxxxxxxxxxjDqM');
var APIPullSheet = ss.getSheetByName("APIPull");
// Clear Columns A,B,C,D
APIPullSheet.getRange('A2:D19999').clearContent();
var url = "https://poloniex.com/public?command=returnChartData¤cyPair=BTC_ETH&start=1502344800&end=9999999999&period=14400";
//Fetch pulls data from URL
var responseAPI = UrlFetchApp.fetch(url);
//Parse that JSON
var parcedData = JSON.parse(responseAPI.getContentText());
//Break that Parsed data into fields
//Define the 'stats' array, and populate it from the parced data pulled
// for loop iterates over each 'key' in 'parcedData' pushing that data to 'stats'
var stats = [];
stats.push(['date','high', 'low', 'open', 'close', 'volume', 'quoteVolume', 'weightedAverage']);
for(var key in parcedData.stats)
{
stats.push(parcedData.stats[key]);
}
statsRange = APIPullSheet.getRange(1, 1, stats.length, 8);
statsRange.setValues(stats);
}