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

binance.mgAccount returns 404 error #688

Open rostislavryzhkov opened 3 years ago

rostislavryzhkov commented 3 years ago

it seems that there is a bug for the method mgAccount. I tried to get my margin account balance and receive error 404 not found :

{"timestamp":1623791037710,"status":404,"error":"Not Found","message":"No message available","path":"/sapi//isolated"} this is code I called this method :

function logAcount(error,out) {
    if (error) { 
        console.log(error.body)
    }
    console.log(out)

}

binance.mgAccount(logAcount,true)

It seems that your code returns wrong route for binance API call I looked through your library and found bug, after I fixed it everything worked: file: node-finance-api.js (4685)

 mgAccount: function( callback ,isIsolated = false) {
            const endpoint = 'v1/margin' + isIsolated ? '/isolated' : ''  + '/account'
            signedRequest( sapi + endpoint, {}, function( error, data ) {
                if( callback ) return callback( error, data );
            } );
        },

I checked and const endpoint instead of whole route returns only result for condition of isIsolated variable so if isIsolated is true, the endpoint ='/isolated', but the correct value must be endpoint='v1/margin/isolated/account' I don't know why it is happening, because the code seems correct, but anyway this issue and problem exist.

I changed code to :

const endpoint =  `v1/margin${isIsolated ? '/isolated' : '' }/account`
pablob206 commented 3 years ago

Hi! I also have the same problem for 3 days ago, but replacing the line that @rostislavryzhkov comments I could solve it, obviously there is a problem there. Thanks @rostislavryzhkov

wa1one commented 1 year ago

why thiis has not been fixed?