Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
A wrapper for the Binance REST and WebSocket APIs. For more information on the API and parameters for requests visit https://www.binance.com/restapipub.html.
const api = require('binance');
const binanceRest = new api.BinanceRest({
key: 'api-key', // Get this from your account on binance.com
secret: 'api-secret', // Same for this
timeout: 15000, // Optional, defaults to 15000, is the request time out in milliseconds
disableBeautification: false
/*
* Optional, default is false. Binance's API returns objects with lots of one letter keys. By
* default those keys will be replaced with more descriptive, longer ones.
*/
});
// You can use promises
binanceRest.allOrders({
symbole: 'BNBBTC' // Object is transformed into a query string, timestamp is automatically added
})
.then((data) => {
console.log(data);
})
.catch((err) => {
console.error(err);
});
/*
* Or you can provide a callback. Also, instead of passing an object as the query, routes
* that only mandate a symbol, or symbol and timestamp, can be passed a string.
*/
binanceRest.allOrders('BNBBTC', (err, data) => {
if (err) {
console.error(err);
} else {
console.log(data);
}
});
// WebSocket API
const binanceWS = api.BinanceWS();
binanceWS.onDepthUpdate('BNBBTC', (data) => {
console.log(data);
});
/*
* onUserData requires an instance of binanceRest in order to make the necessary startUserDataStream and
* keepAliveUserDataStream calls
*/
binanceWS.onUserData(binanceRest, (data) => {
console.log(data);
}, 60000); // How often the keep alive should be sent in milliseconds
binanceWS.onKline('BNBBTC', '1m', (data) => {
console.log(data);
});
depth(query object|string, [callback function])
aggTrades(query object|string, [callback function])
klines(query object, [callback function])
ticker24hr(query object|string, [callback function])
newOrder(query object, [callback function])
testOrder(query object, [callback function]) - If this ends up making a real order it's the API, not this library
queryOrder(query object|string, [callback function])
cancelOrder(query object|string, [callback function])
openOrders(query object|string, [callback function])
allOrders(query object|string, [callback function])
account(query object, [callback function])
myTrades(query object|string, [callback function])
startUserDataStream([callback function])
keepAliveUserDataStream(query object|string, [callback function])
closeUserDataStream(query object|string, [callback function])
onDepthUpdate(symbol, eventHandler) - Returns the websocket, an instance of https://www.npmjs.com/package/ws
onKline(symbol, interval, eventHandler) - Returns the websocket, an instance of https://www.npmjs.com/package/ws
onAggTrade(symbol, eventHandler) - Returns the websocket, an instance of https://www.npmjs.com/package/ws
onUserData(binanceRest, eventHandler, [interval]) - Will return the websocket via promise, interval defaults to 60000, is the amount of time between calls made to keep the user stream alive, binanceRest should be an instance of BinanceRest that will be used to get the listenKey and keep the stream alive
FAQs
Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.
The npm package binance receives a total of 1,775 weekly downloads. As such, binance popularity was classified as popular.
We found that binance demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.