function processXMRAPI() {

 

  // Link the script with a spreadsheet using the unique identifier found in the spreadsheet web address

  var ss = SpreadsheetApp.openById('1fV9Q-wygsPa1QOrtl-Y-u69U5Nn2FYdyhmwoUE8opyI');

 

  var APIPullSheet = ss.getSheetByName("APIPull");

 

  // Clear Columns A, B, C & D

  APIPullSheet.getRange('A2:D19999').clearContent();

 

  var url= "https://poloniex.com/public?command=returnOrderBook&currencyPair=BTC_XMR&depth=19999";

  var responseAPI = UrlFetchApp.fetch(url);

  var parcedData = JSON.parse(responseAPI.getContentText());

 

  // Define the 'asks' array, and populate it from the parced data pulled

  var asks = [];

  asks.push(['askRate', 'askAmount']);

 

  for(var key in parcedData.asks)

    {

      asks.push(parcedData.asks[key]);

    }

 

  // Put the 'asks' data into the spreadsheet columns A & B

  askRange = APIPullSheet.getRange(1, 1, asks.length, 2);

  askRange.setValues(asks);

 

 

  // Get the 'bids' data into the spreadsheet columns C & D

  var bids = [];

  bids.push(['bidRate', 'bidAmount']);

  for(var key in parcedData.bids)

    {

       bids.push(parcedData.bids[key]);

    }

  bidRange = APIPullSheet.getRange(1, 3, bids.length, 2);

  bidRange.setValues(bids);

 

  // Append Latest Data to End of the File

  var tableData = ss.getSheetByName("TableData");

  var rangeData = tableData.getRange("F1:G1");  

  var latestData = rangeData.getValues();   // Put F1 & G1 in latestData variable

  tableData.appendRow(latestData[0]);   // Put the data at the bottom of the spreadsheet

 

  // Keep 144 rows - Delete any extra starting at row 2

  var rowsToKeep = 144;   // 144 * 10 Minutes = 24 Hours of Data

  var totalRows = tableData.getLastRow();

  var numToDelete = totalRows - rowsToKeep;

    if (numToDelete > 0)

       {

         tableData.deleteRows(2, numToDelete);  // Purge Extra Rows        

}

 

}