ViewBlock / binance-api-node

:chart: A complete and heavily tested wrapper with typings for the Binance API.
654 stars 495 forks source link

(Unannounced) Binance read-only public API endpoints are no longer available in the US / restricted locations #610

Open gldstrrbt opened 1 year ago

gldstrrbt commented 1 year ago

Up until today, the Binance public read-only data API has been available for all to use and access. But now, any device not connected to a VPN / proxy server outside of restricted areas is getting 451 errors.

The customer service rep I spoke with assured me that they (Binance) put in their "best efforts" to notify those who would be affected by this cut off of their read-only data endpoints... by email. Email? Really? They're surely aware that many devs from all over the world (restricted and non-restricted alike) make use of the read-only API endpoints that they've provided up until today. They're also likely aware that many folks have products (charting/analytics/etc) which rely on this read-only data they provide, considering they're one of, if not THE, top exchange(s) in the world, meaning their data paints a better picture of global trading activity.

Binance should have been responsible and should have given all devs a heads up through a public announcement, stating how they're cutting off their access to their read-only data in "restricted" locations, such as the US. It makes zero sense why they would pull this, especially considering that this read-only data is still accessible for all to read around the world through the tables and advanced charts provided on their core website... just not through their public API.

The customer service rep insisted that I use the Binance US API, but again, the previously publicly available read-only data provided by the main Binance is much more robust and paints a clearer picture of international trading activity, and doesn't limit devs to data from one region. They also insisted that I create a ticket speaking to this, knowing that it would require me to create a Binance account... which I'm restricted from doing.

So after being fed up with all the corporate speak, mental gymnastics, and gaslighting the rep pulled, I decided to write here in hopes of letting those using the API in the US and other now restricted areas, know that their access to the core read-only Binance public API has been cutoff as of today. Also wrote this in hopes of catching any of the Binance dev's attention and maybe reversing this cutoff or at least encourage their team to reverse the decision should they have any actual in this.

Yes, a proxy server / VPN can be connected to in a non-restricted area to side step this, but for those (such as myself) in situations where their project or product is purely client side, this is negatively affecting my livelihood/progression of my business/offerings.

gldstrrbt commented 1 year ago

Not sure if you're official Binance employees, but if you are, can this be addressed without the corporate speak? Why cutoff access now? If you aren't, my apologies.

balthazar commented 1 year ago

Sorry, not a Binance dev 😄

gldstrrbt commented 1 year ago

@balthazar thank you for the heads up and my apologies.

jaggedsoft commented 1 year ago

The only alternative I can think of is hosting a simple proxy for private use, I have a php file I can share to wrap it through a digitalocean host like this: https://example.site/cors/https://api1.binance.com/api/v3/ticker?symbol=BTCUSDT

balthazar commented 1 year ago

No worries, you can keep the message up for others though. And no need to tag the others, they're not Binance employees either.

gldstrrbt commented 1 year ago

@jaggedsoft that'd be much appreciated. Thank you so much. Trying to keep everything client side, but if that doesn't work out I'll go through with your suggestion

@balthazar thank you again, man. Just removed the tags

jaggedsoft commented 1 year ago

save to /cors/index.php and access from your server ip, for example http://127.0.0.1/cors/?url=https://api.binance.com/api/v3/ticker?symbol=BTCUSDT if you require https use cloudflare with flexible ssl enabled

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$url = $_GET['url'];
//if ( substr( $url, 0, 8 ) !== "https://" ) die("Access Denied");
$whitelist = [
    "bitmax.io",
    "ascendex.com",
    "hotbit.io",
    "bitmex",
    "mexc.com",
    "binance.org",
    "openapi-v2.kucoin.com",
    "api.kucoin.com",
    "api.binance.com",
    "info.binance.com",
    "quandl.com",
    "bitstamp",
    "hitbtc",
    "okex",
    "coinex",
    "bibox",
    "idex",
    "coingecko",
    "coinpaprika",
    "poloniex",
    "btse"
];
$matches = 0;
foreach ( $whitelist as $keyword ) {
    if ( strpos($url, $keyword) === false ) ++$matches;
}
if ( $matches < 1 ) die("Not Authorized");
header('Access-Control-Allow-Origin: *');
echo file_get_contents($url);
gldstrrbt commented 1 year ago

@jaggedsoft thank you so much for your help with this. Truly appreciated, especially with facing this current situation