jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.57k stars 767 forks source link

Can not set the base URL #735

Open idoor88 opened 2 years ago

idoor88 commented 2 years ago

Hi, I am trying set the base url to api.binance.us, but the following code is not working:

const binance = new Binance().options({ APIKEY: apiKey, APISECRET: apiSecret, adjustForTimeDifference: true, urls: { base: "https://api.binance.us" } });

and I changed the library code in the node-binance.api.js file with all the binance.com to binance.us: let base = 'https://api.binance.us/api/'; let wapi = 'https://api.binance.us/wapi/'; let sapi = 'https://api.binance.us/sapi/'; let fapi = 'https://fapi.binance.us/fapi/'; let dapi = 'https://dapi.binance.us/dapi/'; ... Still got error back, inside the error, it shows still the binance.com url when I call: binance.mgAccount((error, response) => {....}), I am trying to get my account information from binance.us, my api key is definitely correct, since I used it with raw query call, it works:

"statusCode": 400, "body": "{\"code\":-2008,\"msg\":\"Invalid Api-Key ID.\"}", "headers": { "content-type": "application/json;charset=UTF-8", "content-length": "42", "connection": "keep-alive", "date": "Thu, 30 Sep 2021 20:36:39 GMT", "server": "nginx", "strict-transport-security": "max-age=31536000; includeSubdomains", "x-frame-options": "SAMEORIGIN", "x-xss-protection": "1; mode=block", "x-content-type-options": "nosniff", "content-security-policy": "default-src 'self'", "x-content-security-policy": "default-src 'self'", "x-webkit-csp": "default-src 'self'", "cache-control": "no-cache, no-store, must-revalidate", "pragma": "no-cache", "expires": "0", "x-cache": "Error from cloudfront", "via": "1.1 530b01c2c88db2b27d295e2504b501cb.cloudfront.net (CloudFront)", "x-amz-cf-pop": "IAD89-C1", "x-amz-cf-id": "dNUqBHc_uC9I2ZwiUrHcuN22aj2I8yErfUeIn7Sed0360qD1iOcC5g==" }, "request": { "uri": { "protocol": "https:", "slashes": true, "auth": null, "host": "api.binance.com", "port": null, "hostname": "api.binance.com", "hash": null, "search": "?timestamp=1633034198935&recvWindow=5000&signature=xxxxxxx", "query": "timestamp=1633034198935&recvWindow=5000&signature=xxxxxx", "pathname": "/sapi/v1/margin/account", "path": "/sapi/v1/margin/account?timestamp=1633034198935&recvWindow=5000&signature=xxxxx", "href": "https://api.binance.com/sapi/v1/margin/account?timestamp=1633034198935&recvWindow=5000&signature=xxxxx" }, "method": "GET", "headers": { "User-Agent": "Mozilla/4.0 (compatible; Node Binance API)", "Content-type": "application/x-www-form-urlencoded", "X-MBX-APIKEY": "xxxxxxxx" } } }

I changed the original sensitive data to xxxxx.

Any clues?

Thanks for help!

kiaxseventh commented 1 year ago

anyone found any solution ?