binance-to-google-sheets
binance-to-google-sheets copied to clipboard
[BUG] Error: Request failed with status: 451
Describe the bug Script has been working flawless over a year but today I started to get error 451: Unavailable For Legal Reasons
Binance API last call Wed Nov 30 2022 09:10:50 GMT+0100 (Central European Standard Time)
I'm from Europe, I guess this error is due to that Google runs on server in a “Restricted Location” or?
attempting to access the Binance Platform or the Binance Services from, or otherwise acting on behalf of a person or legal entity that is resident or located in, a Restricted Location. For the purposes hereof, “Restricted Location” shall include the United States, Malaysia, Ontario (Canada), and such other locations as designated by Binance Operators from time to time as a “Restricted Location” https://www.binance.com/en/terms
I'm able to call API Locally but unable to do it using Google script, simple test is to use this API call in a browser.
https://api.binance.com/api/v3/time
Update: https://data.binance.com/ can be used for getting market data.
replace: const SPOT_API_URL = "https://api.binance.com"; with const SPOT_API_URL = "https://data.binance.com";
and add data.binance.com to urlFetchWhitelist
Work around (not needed any more)
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account.
replace: const SPOT_API_URL = "https://api.binance.com"; with const SPOT_API_URL = "https://api.binance.us";
and add .us to urlFetchWhitelist
"urlFetchWhitelist": [
"https://api.binance.com/",
"https://api.binance.us/",
"https://api1.binance.com/",
"https://api1.binance.us/",
"https://api2.binance.com/",
"https://api2.binance.us/",
"https://api3.binance.com/",
"https://api3.binance.us/",
"https://fapi.binance.com/",
"https://dapi.binance.com/",
]
Edit: Same problem with DEMO https://docs.google.com/spreadsheets/d/1AcOcPFsncrDB_ve3wWMHwfiFql6A4hmG1sFc01LLTDg
Also experiencing this error "Error: Request failed with status: 451 (linha 2751)." 451: Unavailable For Legal Reasons
Same here. But I'm from Brazil.
Not sure if related to this:
Exception: Request failed for https://api.binance.com returned code 451. Truncated server response: { "code": 0, "msg": "Service unavailable from a restricted location according to 'b. Eligibility' in https://www.binance.com/en/terms. Please c... (use muteHttpExceptions option to examine full response) (linha 131).
Current urlFetchWhitelist
"urlFetchWhitelist": [
"https://api.binance.com/",
"https://api1.binance.com/",
"https://api2.binance.com/",
"https://api3.binance.com/",
"https://fapi.binance.com/",
"https://dapi.binance.com/"
]
Current urlFetchWhitelist
"urlFetchWhitelist": [ "https://api.binance.com/", "https://api1.binance.com/", "https://api2.binance.com/", "https://api3.binance.com/", "https://fapi.binance.com/", "https://dapi.binance.com/" ]
same issue from germany also the following links are not working https://api3.binance.com/api/v3/ticker/price at least the staking link is still working https://www.binance.com/gateway-api/v1/friendly/pos/union?status=ALL&pageSize=200
looks like issue on api dev side, better upvote :) https://dev.binance.vision/t/service-unavailable-from-a-restricted-location/13813
Same here, I'm from Romania
I'm from India and facing similar issue, hope the developer will look into it.
Not just me then! (yay). Same issue - New Zealand based Thanks for all your hard work @diegomanuel i've been using your code for well over a year to track things. Hopefully there is a way to resolve this.
Same issue here in Portugal
Same issue here in uae
On Thu, 1 Dec 2022, 18:26 Diogo Serrano, @.***> wrote:
Same issue here in Portugal
— Reply to this email directly, view it on GitHub https://github.com/diegomanuel/binance-to-google-sheets/issues/142#issuecomment-1333848186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVJXIIONH74LRUMK6LNMEPDWLCYTFANCNFSM6AAAAAASPRS24E . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>
Same issue here in UAE. This script has been working perfectly for the last 12 months, but it's now just throwing our a 451 status error.
Concerningly, this appears to be a legal status code exception, suggesting the API calls are now region restricted? I note the developer is based in Argentina, so I'm wondering if the API requests are now region-locked to Argentina only? Has anyone tried running this on a VPN with Argentina as the host country?
The location of the user has nothing to do with it. Requests are sent by google server
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account.
replace: const SPOT_API_URL = "https://api.binance.com";
with const SPOT_API_URL = "https://api.binance.us";
and add .us to urlFetchWhitelist
"urlFetchWhitelist": [
"https://api.binance.com/",
"https://api.binance.us/",
"https://api1.binance.com/",
"https://api1.binance.us/",
"https://api2.binance.com/",
"https://api2.binance.us/",
"https://api3.binance.com/",
"https://api3.binance.us/",
"https://fapi.binance.com/",
"https://dapi.binance.com/",
]
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account.
replace: const SPOT_API_URL = "https://api.binance.com";
with const SPOT_API_URL = "https://api.binance.us";
and add .us to urlFetchWhitelist
"urlFetchWhitelist": [ "https://api.binance.com/", "https://api.binance.us/", "https://api1.binance.com/", "https://api1.binance.us/", "https://api2.binance.com/", "https://api2.binance.us/", "https://api3.binance.com/", "https://api3.binance.us/", "https://fapi.binance.com/", "https://dapi.binance.com/", ]
Binance US have very limited no of coins also liquidity is not good so if you are using historical data you might get very poor results.
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account.
replace: const SPOT_API_URL = "https://api.binance.com";
with const SPOT_API_URL = "https://api.binance.us";
and add .us to urlFetchWhitelist
"urlFetchWhitelist": [ "https://api.binance.com/", "https://api.binance.us/", "https://api1.binance.com/", "https://api1.binance.us/", "https://api2.binance.com/", "https://api2.binance.us/", "https://api3.binance.com/", "https://api3.binance.us/", "https://fapi.binance.com/", "https://dapi.binance.com/", ]
This is a no go also for personal accout info like spot wallet.
So I played a round a bit. It seamed strange that https://api.binance.com/api/v1/ticker/allPrices was working in chrome, but I was getting the stupid 451 (I am not in US) when using an importjson google extension based on https://github.com/bradjasper/ImportJSON I installed the ImportJSON from google marketplace (still do not like it since I want to have/see control of the code) which allowed me to see the .com link in table format. My guess would be that the .com is working, except if I use some intermediate steps which is accessing US servers somehow??? @diegomanuel can you please test the above to see if it makes sense?
So I played a round a bit. It seamed strange that https://api.binance.com/api/v1/ticker/allPrices was working in chrome, but I was getting the stupid 451 (I am not in US) when using an importjson google extension based on https://github.com/bradjasper/ImportJSON I installed the ImportJSON from google marketplace (still do not like it since I want to have/see control of the code) which allowed me to see the .com link in table format. My guess would be that the .com is working, except if I use some intermediate steps which is accessing US servers somehow??? @diegomanuel can you please test the above to see if it makes sense?
Se post 1. I'm able to call API Locally but unable to do it using Google script, simple test is to use this API call in a browser. https://api.binance.com/api/v3/time
When using the API I get this message: "msg": "Service unavailable from a restricted location according to 'b. Eligibility' in https://www.binance.com/en/terms. Please contact customer service if you believe you received this message in error."
According the Binance terms. Binance started to restrict the use of API in the US and some other countries. As the Google server that runs apps script is in US and API request will be refused.
When using the API I get this message: "msg": "Service unavailable from a restricted location according to 'b. Eligibility' in https://www.binance.com/en/terms. Please contact customer service if you believe you received this message in error."
According the Binance terms. Binance started to restrict the use of API in the US and some other countries. As the Google server that runs apps script is in US and API request will be refused.
Exactly that my friends... it's not a bug, sadly, instead, it seems that Binance's legal restrictions are blocking the US servers in where the apps script is run, and we can't choose or change what internal Google server/instance/region to use (as far as I know).
It makes no sense to me that Binance blocks IPs for read-only calls too...What if I'm from any other country but I travel to USA? I wouldn't be able to access and use my account while staying there? Whatever... clearly an extremelly stupid decision.
The error message also says: "Please contact customer service if you believe you received this message in error."
I think I'll try to speak with them, but I have little hope in that path.
The best shot could be to push all together as a community to make Binance change this shitty restriction, at least, allowing read-only request to access account data.
A non-trivial workaroud could be to use a "trusted proxy", changing all the defined URLs at config.gs
and appsscript.json
to point there and just tunnel the requests to Binance.
Sorry folks, but no easy-fix for this one, we would need to push and wait for some resolution between Binance and Google servers :disappointed:
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account.
replace: const SPOT_API_URL = "https://api.binance.com";
with const SPOT_API_URL = "https://api.binance.us";
and add .us to urlFetchWhitelist
"urlFetchWhitelist": [ "https://api.binance.com/", "https://api.binance.us/", "https://api1.binance.com/", "https://api1.binance.us/", "https://api2.binance.com/", "https://api2.binance.us/", "https://api3.binance.com/", "https://api3.binance.us/", "https://fapi.binance.com/", "https://dapi.binance.com/", ]
Hi Robert, Diego suggested that there is no easy fix around, so I'm trying the solution suggested by you.
Can you guide me where should I add urlFetchWhitelist to get the desired result.
I might have found a work around to get some prices but obvious not balance, open orders etc. since I don't have a US account. replace: const SPOT_API_URL = "https://api.binance.com"; with const SPOT_API_URL = "https://api.binance.us"; and add .us to urlFetchWhitelist
"urlFetchWhitelist": [ "https://api.binance.com/", "https://api.binance.us/", "https://api1.binance.com/", "https://api1.binance.us/", "https://api2.binance.com/", "https://api2.binance.us/", "https://api3.binance.com/", "https://api3.binance.us/", "https://fapi.binance.com/", "https://dapi.binance.com/", ]
Hi Robert, Diego suggested that there is no easy fix around, so I'm trying the solution suggested by you.
Can you guide me where should I add urlFetchWhitelist to get the desired result.
appsscript.json https://imgur.com/a/JRgndmX
Hi Guys,
I've found a good alternative, which is an extension you simply install on Google Sheets and you can get access to live prices from it;
https://workspace.google.com/marketplace/app/cryptosheets/898843532532
Thanks
From an online bot i use called shrimpy.io - they had to move their servers to ireland from california to get around this issue
We have just been informed by the Binance team that they will no longer allow API access to anyone from the United States. As a result, some of our customers have received a notice from Binance that their API keys will be disabled in seven days. First and foremost, there is nothing for you to be concerned about. This will not impact the integrity of your account. However, it will require you to recreate your API keys AFTER they make their updates in seven days. Over the next week, our team will be developing updates that will connect our US-based infrastructure to other countries. As a result of that effort, we will be assigning new IPs to any customer that uses a Binance account. In seven days, we'll notify you to create your new API keys. When creating them, you will need to use the new IPs provided by Shrimpy. The old IPs will no longer work for Binance.Our team will continue to provide updates as we get closer to the migration date.
First and foremost, there is nothing for you to be concerned about. This will not impact the integrity of your account.
However, it will require you to recreate your API keys AFTER they make their updates in seven days.
Over the next week, our team will be developing updates that will connect our US-based infrastructure to other countries. As a result of that effort, we will be assigning new IPs to any customer that uses a Binance account.
In seven days, we'll notify you to create your new API keys. When creating them, you will need to use the new IPs provided by Shrimpy. The old IPs will no longer work for Binance.
Our team will continue to provide updates as we get closer to the migration date. In the mean-time, please email [email protected] if you have any questions.
The Shrimpy Team
Shrimpy
3833 E Main St PMB 4006, St. Charles, IL 60174
Update: https://data.binance.com can be used for getting market data.
@diegomanuel https://binance-docs.github.io/apidocs/spot/en/#change-log
Update: https://data.binance.com can be used for getting market data.
@diegomanuel https://binance-docs.github.io/apidocs/spot/en/#change-log
Hi Robert, can you share a sample spreadsheet if you managed to get it.
Update: https://data.binance.com can be used for getting market data. @diegomanuel https://binance-docs.github.io/apidocs/spot/en/#change-log
Hi Robert, can you share a sample spreadsheet if you managed to get it.
Se post 1
replace: const SPOT_API_URL = "https://api.binance.com/"; with const SPOT_API_URL = "https://data.binance.com/";
and add data.binance.com to urlFetchWhitelist
Update: https://data.binance.com can be used for getting market data. @diegomanuel https://binance-docs.github.io/apidocs/spot/en/#change-log
Hi Robert, can you share a sample spreadsheet if you managed to get it.
Se post 1
replace: const SPOT_API_URL = "https://api.binance.com/"; with const SPOT_API_URL = "https://data.binance.com/";
and add data.binance.com to urlFetchWhitelist
Made both the changes but still getting no update in 24h stats. Please have a look if possible
https://docs.google.com/spreadsheets/d/1x3yPplVXpFnIPQ-mDDGYIvWgwXmenooTh6QlyQHr4mw/edit?usp=sharing
I'm getting price and 24h stats, but error in DEMO is "Exceeded maximum execution time (line 0)"
Hey folks, I've released a new version with proxy support: https://github.com/diegomanuel/binance-to-google-sheets/releases/tag/v0.5.3
I've also created a basic proxy implementation that may be useful for someone else: https://github.com/diegomanuel/binance-to-google-sheets-proxy
I'm closing this ticket. Hope Binance changes his mind and we could return to normal "non-proxy" mode soon.
[#143] How to install Add-On Proxy on Mac
https://dev.binance.vision/t/api-error-451-unavailable-for-legal-reasons/13828 data.binance.com will answer all READ-only API requests can this bypass the proxy workaround? I kind of gave up, wrote my own python script for binance-connector on pythonanywhere, just to have also access to the staking and wallet data
https://dev.binance.vision/t/api-error-451-unavailable-for-legal-reasons/13828 data.binance.com will answer all READ-only API requests can this bypass the proxy workaround? I kind of gave up, wrote my own python script for binance-connector on pythonanywhere, just to have also access to the staking and wallet data
Didn't try data.binance.com
but I'm almost sure that it doesn't support some of the add-on requests (mainly some POST
ones), although they are all read-only too.
You could try it easily, just replace all the URLs at config.gs
, add to appsscript.json
and let USE_PROXY=false
.
For now, I'm just using the proxy I've built and that's it.
Plz @cristipurdel let us know if you manage to get all the add-on functions/endpoints working with data.binance.com
!