How to input realtime data from google sheets into urlfetch google scripts?

0 votes

I'm trying to input user fed data from google sheet to modify the API link in real time. I tried using the getActivecell Sheet, but I believe I would have to use put instead of get? Or is there a simpler way to do so? TIA!

function TransactionVerification() {
   var sheet = SpreadsheetApp.getActiveSheet();
   var response=UrlFetchApp
    .fetch("https://api.ethplorer.io/getTxInfo/(sheet.getActiveCell(2,2))?apiKey=freekey");
   var json = response.getContentText();
   var data = JSON.parse(json)
   sheet.getRange(2,3).setValue([data.success]);
   sheet.getRange(2,5).setValue([data.from]);
   sheet.getRange(2,6).setValue([data.to]);
   sheet.getRange(2,4).setValue([data.value]);
   sheet.getRange(2,7).setValue([data.gasUsed]);
   Logger.log(data);
Oct 12, 2018 in Blockchain by sabby
• 4,350 points
112 views

1 answer to this question.

0 votes

Based on your title I hope to understand your question correctly. You're currently not inserting the value of the active cell in your url. Try the code below. This code takes the value of the active cell and puts it in the url.

function TransactionVerification() {
   var sheet = SpreadsheetApp.getActiveSheet();
   var url = "https://api.ethplorer.io/getTxInfo/" + sheet.getActiveCell().getValue() + "?apiKey=freekey"
   var response=UrlFetchApp.fetch(url);
   var json = response.getContentText();
   var data = JSON.parse(json)
   sheet.getRange(2,3).setValue([data.success]);
   sheet.getRange(2,5).setValue([data.from]);
   sheet.getRange(2,6).setValue([data.to]);
   sheet.getRange(2,4).setValue([data.value]);
   sheet.getRange(2,7).setValue([data.gasUsed]);
   Logger.log(data);

From the url in your initial code it almost looks like you want to take the value of the cell in row 2 column 2. If that's the case, change the urlvar to:

var url = "https://api.ethplorer.io/getTxInfo/" + sheet.getRange(2, 2).getValue() + ?apiKey=freekey"
answered Oct 12, 2018 by Perry
• 17,020 points

Related Questions In Blockchain

0 votes
1 answer

How to get data from Google Finance to Google sheets?

You need to have a from and ...READ MORE

answered Aug 21, 2018 in Blockchain by slayer
• 29,170 points
172 views
0 votes
1 answer
0 votes
1 answer

How to parse Json data from remote server?

Yes, you can do it use the ...READ MORE

answered Aug 17, 2018 in Blockchain by digger
• 26,550 points
44 views
0 votes
1 answer

Nodejs: How to pass user form data into defined class

This should do your work: // select the ...READ MORE

answered Sep 19, 2018 in Blockchain by digger
• 26,550 points
45 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
169 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
90 views
0 votes
1 answer

How to retrieve data from a block to a blockchain?

web3.eth.getTransaction(txHash) will returns transaction details like blockHash, transactionIndex, ...READ MORE

answered Jun 26, 2018 in Blockchain by Perry
• 17,020 points
235 views
0 votes
1 answer

How to retrieve data from an Ethereum Block?

To get transaction details like Block Hash ...READ MORE

answered Jul 19, 2018 in Blockchain by Perry
• 17,020 points
53 views