Last active
June 16, 2022 12:17
-
-
Save kmikiy/dd1f2106d47c30cfd5905e070b111b51 to your computer and use it in GitHub Desktop.
Google Sheets Apps Script for fetching latest crypto price from Binance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function BINANCE_PRICE(coinsymbol, pair) { | |
var url = "https://api.binance.com/api/v3/ticker/price?symbol="+coinsymbol.toUpperCase()+pair.toUpperCase() | |
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true}); | |
var json = response.getContentText(); | |
var data = JSON.parse(json); | |
return data.price | |
} | |
/* | |
USAGE example | |
Enter: | |
=BINANCE_PRICE("LTC", "BTC") | |
in a cell to get the last trade price of LTC/BTC on binance | |
*/ |
Yes, I'm only using the BINANCE_PRICE function. For some reason my access is blocked...
I will try from another computer and let you know.
I got the same error too.
You could give a try to https://github.com/diegomanuel/binance-to-google-sheets 😉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I removed the unnecessary code, have you also tried removing the code that's no longer required?