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,390 points
1,268 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,100 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,350 points
1,108 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,740 points
634 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
1,633 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,203 views
+1 vote
1 answer

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

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,113 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 27, 2018 in Blockchain by Perry
• 17,100 points
3,713 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,100 points
2,478 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP