expose ws store
This commit is contained in:
@@ -60,6 +60,8 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
|
||||
|
||||
// Spot V3
|
||||
// wsClient.subscribe('trade.BTCUSDT');
|
||||
// Or an array of topics
|
||||
// wsClient.subscribe(['trade.BTCUSDT', 'trade.LTCUSDT']);
|
||||
|
||||
// usdc options
|
||||
// wsClient.subscribe([
|
||||
@@ -74,11 +76,26 @@ import { DefaultLogger, WS_KEY_MAP, WebsocketClient } from '../src';
|
||||
// unified perps
|
||||
wsClient.subscribe('publicTrade.BTCUSDT');
|
||||
|
||||
// For spot v1 (the old, deprecated client), request public connection first then send required topics on 'open'
|
||||
// Not necessary for spot v3
|
||||
// wsClient.connectPublic();
|
||||
|
||||
// To unsubscribe from topics:
|
||||
// setTimeout(() => {
|
||||
// console.log('unsubscribing');
|
||||
// wsClient.unsubscribe('trade.BTCUSDT');
|
||||
// }, 5 * 1000);
|
||||
|
||||
// For spot, request public connection first then send required topics on 'open'
|
||||
// wsClient.connectPublic();
|
||||
// Topics are tracked per websocket type
|
||||
// Get a list of subscribed topics (e.g. for public v3 spot topics)
|
||||
const publicSpotTopics = wsClient
|
||||
.getWsStore()
|
||||
.getTopics(WS_KEY_MAP.spotV3Public);
|
||||
|
||||
console.log('public spot topics: ', publicSpotTopics);
|
||||
|
||||
const privateSpotTopics = wsClient
|
||||
.getWsStore()
|
||||
.getTopics(WS_KEY_MAP.spotV3Private);
|
||||
console.log('private spot topics: ', publicSpotTopics);
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bybit-api",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"description": "Complete & robust node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & integration tests.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
||||
@@ -174,6 +174,11 @@ export class WebsocketClient extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the WsStore that tracks websockets & topics */
|
||||
public getWsStore(): WsStore {
|
||||
return this.wsStore;
|
||||
}
|
||||
|
||||
public isTestnet(): boolean {
|
||||
return this.options.testnet === true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user