npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@iofate/bitpanda-ws

v1.0.0

Published

Node.js websocket client for BitPanda

Downloads

7

Readme

BitPanda WS

Node.js CI

Node.js websocket client for BitPanda. Websocket API documentation: https://developers.bitpanda.com/exchange/?shell#websocket-api-overview

IOfate

This package is made by the IOfate company and is open source, feel free to use it, share it and contribute!

Features

  • [x] Price ticks
    • [x] Subscription
    • [x] Unsubscribe
  • [x] Candlesticks
    • [x] Subscription
    • [x] Unsubscribe
  • [x] Emit errors by sockets
  • [x] Auto-reconnect

Install

$ npm install @iofate/bitpanda-ws

How to use it

import { BitPandaWs } from '@iofate/bitpanda-ws';

const main = async () => {
  const client = new BitPandaWs();
  const symbol = 'BTC/EUR';
  const candleTimeFrame = '1m';

  await client.open();

  client.on(`ticker-${symbol}`, ticker => console.log(ticker));
  client.on(`candle-${symbol}-${candleTimeFrame}`, candle => console.log(candle));
  client.on('error-ticker', error => console.error(error));
  client.on('error-candle', error => console.error(error));

  client.subscribeTicker(symbol);
  client.subscribeCandles(symbol, candleTimeFrame);
};

main();

API

This package export one class BitPandaWs which extend from Emittery, which allow us to dispatch and listen events. More information about Emittery API here: https://github.com/sindresorhus/emittery#api

bitPandaWs = new BitPandaWs()

Create a new instance of BitPandaWs.

bitPandaWs.open()

Open BitPanda websockets. Must be called before any subscription!

Returns a promise.

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

await bitPandaWs.open();

bitPandaWs.isOpen()

To know if sockets are open or not.

Returns a boolean.

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

if (!bitPandaWs.isOpen()) {
  await bitPandaWs.open();
}

bitPandaWs.subscribeTicker(symbol)

Subscribe to the websocket ticker of the chosen symbol. Once called you'll be able to listen to ticker events for this symbol. open method must be called before calling this one.

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

await bitPandaWs.open();
bitPandaWs.subscribeTicker('BTC/EUR');
bitPandaWs.on('ticker-BTC/EUR', ticker => console.log(ticker));

bitPandaWs.unsubscribeTicker(symbol)

Unsubscribe from the ticker websocket of the associated symbol. Once called no more events will be dispatched.

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

await bitPandaWs.open();
bitPandaWs.subscribeTicker('BTC/EUR');
const stopListenFn = bitPandaWs.on('ticker-BTC/EUR', ticker => console.log(ticker));
bitPandaWs.unsubscribeTicker('BTC/EUR');
stopListenFn();

bitPandaWs.subscribeCandles(symbol, timeFrame)

Subscribe to the websocket candle of the chosen symbol and time frame. Once called you'll be able to listen to candle events for this symbol. open method must be called before calling this one.

Valid time frame: '1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w', '1M'

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

await bitPandaWs.open();
bitPandaWs.subscribeCandles('BTC/EUR', '1d');
bitPandaWs.on('candle-BTC/EUR-1d', candle => console.log(candle));

bitPandaWs.unsubscribeCandles(symbol, timeFrame)

Unsubscribe from the candle websocket of the associated symbol. Once called no more events will be dispatched.

import { BitPandaWs } from '@iofate/bitpanda-ws';

const bitPandaWs = new BitPandaWs();

await bitPandaWs.open();
bitPandaWs.subscribeCandles('BTC/EUR', '1d');
const stopListenFn = bitPandaWs.on('candle-BTC/EUR-1d', candle => console.log(candle));
bitPandaWs.unsubscribeCandles('BTC/EUR', '1d');
stopListenFn();