I am struggling to extract specific data from a website API. My current method involves dumping the entire response into Google Sheets and using the mid function to retrieve the desired string. Is there a more efficient way to only return the value of "unpaid"?
The response I receive is:
{"status":"OK","data":{"time":1612834200,"lastSeen":1612834035,"reportedHashrate":154783794,"currentHashrate":131055555.55555557,"validShares":116,"invalidShares":0,"staleShares":3,"averageHashrate":150218750,"activeWorkers":3,"unpaid":26075516667066776,"unconfirmed":null,"coinsPerMin":0.00000787562193181224,"usdPerMin":0.013755797534761213,"btcPerMin":2.9738348414523017e-7}}
I only require:
"unpaid":26075516667066776
Below is the script I'm using to import this data to Google Sheets.
function callNumbers() {
var response = UrlFetchApp.fetch("");
Logger.log(response.getContentText());
var data = response.getContentText();
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(49,7).setValue([data]);
}
I have been unable to find sufficient guidance on this matter, or perhaps I am looking in the wrong places. The functions mentioned above were sourced from a Google page and modified to suit my requirements. Thank you.