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 | |
*/ |
The Cryptopia API is no longer active. Removing lines 10-16 should resolve this error.
@willdolezal is correct. Cryptopia is no longer active. I have removed it from the gist. Use =BINANCE_PRICE("LTC", "BTC")
from now on.
It doesn't work for me through Google Script.
Still receiving the same error from Cloudfront.
I removed the unnecessary code, have you also tried removing the code that's no longer required?
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
Hello, does this still work?
When running this through Google Script, I get the following error:
[20-08-06 20:14:14:955 CEST] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type"CONTENT="text/html; charset=iso-8859-1"><TITLE>ERROR: The request could not be satisfied</TITLE></HEAD><BODY><H1>403 ERROR</H1><H2>The request could not be satisfied.</H2><HR noshade size="1px">Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.<BR clear="all">If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.<BR clear="all"><HR noshade size="1px"><PRE>Generated by cloudfront (CloudFront) Request ID: -m-__LPRs7J_orooCPROW2R4JjqiaQGauojl7fEoi2JxDXeIDbwJOQ==</PRE><ADDRESS></ADDRESS></BODY></HTML>
I've made a post on StackExchange, but no positive response yet.
Thank you so much!