Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iofate/bitpanda-ws

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iofate/bitpanda-ws

Node.js websocket client for BitPanda

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

  • Price ticks
    • Subscription
    • Unsubscribe
  • Candlesticks
    • Subscription
    • Unsubscribe
  • Emit errors by sockets
  • 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();

Keywords

FAQs

Package last updated on 19 Jul 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc