Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
node-bitstamp
Advanced tools
bitstamp rest and websocket v1 and v2 api client
Weekly downloads
Readme
bitstamp REST and WS API Node.js client :dollar:
bts:request_reconnect
npm i node-bitstamp
or yarn add node-bitstamp
yarn example:api
yarn example:stream
"use strict";
const {BitstampStream, Bitstamp, CURRENCY} = require("node-bitstamp");
//printing available currencies
console.log(CURRENCY);
/* STREAMS */
// @ https://www.bitstamp.net/websocket/v2/
// Live trades
const bitstampStream = new BitstampStream();
/*
as the stream is re-usable (subscribe to multiple currencies and channel types)
every subscribe actions returns a channel name, which is the actual event you
can listen to after subscription
*/
bitstampStream.on("connected", () => {
const ethEurTickerChannel = bitstampStream.subscribe(bitstampStream.CHANNEL_LIVE_TRADES, CURRENCY.ETH_EUR);
bitstampStream.on(ethEurTickerChannel, ({ data, event }) => {
console.log(data);
/* e.g.
{
amount: 0.01513062,
buy_order_id: 297260696,
sell_order_id: 297260910,
amount_str: '0.01513062',
price_str: '212.80',
timestamp: '1505558814',
price: 212.8,
type: 1,
id: 21565524,
cost: 3.219795936
}
*/
});
});
bitstampStream.on("disconnected", () => {});
// Live orderBook updates
bitstampStream.on("connected", () => {
const btcEurOrderBookChannel = bitstampStream.subscribe(bitstampStream.CHANNEL_ORDER_BOOK, CURRENCY.BTC_EUR);
bitstampStream.on(btcEurOrderBookChannel, ({ data, event }) => {
console.log(data);
/* e.g.
{ bids:
[
[ '3284.06000000', '0.16927410' ],
[ '3284.05000000', '1.00000000' ],
[ '3284.02000000', '0.72755647' ],
.....
],
asks:
[
[ '3289.00000000', '3.16123001' ],
[ '3291.99000000', '0.22000000' ],
[ '3292.00000000', '49.94312963' ],
.....
] }
*/
});
});
bitstampStream.on("error", (e) => console.error(e));
bitstampStream.close();
/* REST-API */
// @ https://www.bitstamp.net/api/
// @ https://www.bitstamp.net/account/login/
// To get an API key, go to "Account", "Security" and then "API Access".
// Set permissions and click "Generate key"
// Dont forget to active the key and confirm the email.
const key = "abc3def4ghi5jkl6mno7";
const secret = "abcdefghijklmno";
const clientId = "123123";
const bitstamp = new Bitstamp({
key,
secret,
clientId,
timeout: 5000,
rateLimit: true //turned on by default
});
const run = async () => {
/*
Every api function returns a bluebird promise.
The promise only rejects on network errors or timeouts.
A successfull promise always resolves in an object containing status, headers and body.
status is the http status code as number, headers is an object of http response headers
and body is the parsed JSON response body of the api, you dont need to parse the results
yourself you can simply continue by accessing the object.
*/
/* PUBLIC */
const ticker = await bitstamp.ticker(CURRENCY.ETH_BTC).then(({status, headers, body}) => console.log(body));
await bitstamp.tickerHour(CURRENCY.ETH_BTC);
await bitstamp.orderBook(CURRENCY.ETH_BTC);
await bitstamp.transactions(CURRENCY.ETH_BTC, "hour");
await bitstamp.conversionRate();
/* PRIVATE */
const balance = await bitstamp.balance().then(({body:data}) => data);
await bitstamp.userTransaction(CURRENCY.ETH_BTC, {offset, limit, sort});
await bitstamp.openOrders(CURRENCY.ETH_BTC);
await bitstamp.openOrdersAll();
await bitstamp.orderStatus(id);
await bitstamp.cancelOrder(id);
await bitstamp.cancelOrdersAll();
await bitstamp.buyLimitOrder(amount, price, currency, limit_price, daily_order);
await bitstamp.sellLimitOrder(amount, price, currency, limit_price, daily_order);
await bitstamp.buyMarketOrder(amount, currency);
await bitstamp.sellMarketOrder(amount, currency);
await bitstamp.withDrawalRequests(timedelta);
await bitstamp.bitcoinWithdrawal(amount, address, instant);
await bitstamp.bchWithdrawal(amount, address);
await bitstamp.litecoinWithdrawal(amount, address);
await bitstamp.ethereumWithdrawal(amount, address);
await bitstamp.rippleWithdrawal(amount, address, currency);
await bitstamp.xrpWithdrawal(amount, address, destination_tag);
await bitstamp.bitcoinDepositAdress().then(({body}) => console.log(body));
await bitstamp.bchDepositAdress().then(({body}) => console.log(body));
await bitstamp.litecoinDepositAdress().then(({body}) => console.log(body));
await bitstamp.ethereumDepositAdress().then(({body}) => console.log(body));
await bitstamp.rippleDepositAdress().then(({body}) => console.log(body));
await bitstamp.xrpDepositAdress().then(({body}) => console.log(body));
await bitstamp.unconfirmedBitcoinDeposits();
await bitstamp.transferSubToMain(amount, currency, subAccount);
await bitstamp.transferMainToSub(amount, currency, subAccount);
await bitstamp.openBankWithdrawal(/* {..} */);
await bitstamp.bankWithdrawalStatus(id);
await bitstamp.cancelBankWithdrawal(id);
await bitstamp.newLiquidationAddress(currency);
await bitstamp.liquidationAddressInfo(address);
};
run().then(() => {
console.log(bitstamp.getStats());
bitstamp.close();
});
DEBUG=node-bitstamp:* npm start
invalid nonce
error.const async = require("async"); // npm i async or yarn add async
async.series([
cb => bitstamp.bitcoinDepositAdress()
.then(r => cb(null, "BTC: " + r.body)).catch(e => cb(e)),
cb => bitstamp.ethereumDepositAdress()
.then(r => cb(null, "ETH: " + r.body.address)).catch(e => cb(e)),
cb => bitstamp.litecoinDepositAdress()
.then(r => cb(null, "LTC: " + r.body.address)).catch(e => cb(e))
], (error, data) => {
if(error){
return console.error(error);
}
console.log(data); // [ "BTC: ..", "ETH: ..", "LTC: .." ]
});
MIT
FAQs
bitstamp rest and websocket v1 and v2 api client
The npm package node-bitstamp receives a total of 163 weekly downloads. As such, node-bitstamp popularity was classified as not popular.
We found that node-bitstamp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.