jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

exchangeInfo single symbol

pdoria opened this issue · comments

Made a small change to exchangeInfo() so it supports returning info on a single symbol:

/** * Gets the the exchange info * @param {function} callback - the callback function * @param {string} single symbol to get info e.g. "BNBBTC" * @return {promise or undefined} - omitting the callback returns a promise */ exchangeInfo: function ( callback, symbol ) { if ( !callback ) { return new Promise( ( resolve, reject ) => { callback = ( error, response ) => { if ( error ) { reject( error ); } else { resolve( response ); } } publicRequest( base + 'v3/exchangeInfo', {symbol}, callback ); } ) } else { publicRequest( base + 'v3/exchangeInfo', {symbol}, callback ); } },

by the way, you can modify this npm library without changing it,

for example, I needed api to disable "spotBNBBurn" , which this library dont have, but api have it, so I used javascript ability to modify any function:

        let binance = new Binance().options({});

        binance.disable_bnb_fee = (req_type) => {
            let parameters = Object.assign( {"spotBNBBurn":false} );
			return new Promise((resolve, reject) => {
				callback = (error, response) => {
					if (error) {
						reject(error);
					} else {
						resolve(response);
					}
				}
				binance.signedRequest('https://api.binance.com/sapi/v1/bnbBurn', parameters, callback, req_type);
			});
        }

and then you can run it:

		
		let ret;
		try {
			ret = await binance.disable_bnb_fee('GET');
		}catch(err){
			console.log("err", err);
		}
		
		if(ret.spotBNBBurn != false){
			try {
				ret = await binance.disable_bnb_fee('POST');
			}catch(err){
				console.log("err", err);
			}
			console.log("Setting BNB fee to disabled");
		}