UNPKG

okx-v5-ws

Version:

This is a non-official OKX V5 websocket SDK for nodejs.

92 lines (91 loc) 2.57 kB
/// <reference types="node" /> import EventEmitter from 'events'; /** * Provide service level function to user */ declare class OkxV5Ws { #private; static PUBLIC_ENDPOINT: string; static PRIVATE_ENDPOINT: string; static DEMO_PUBLIC_ENDPOINT: string; static DEMO_PRIVATE_ENDPOINT: string; /** * constructor */ constructor({ serverBaseUrl, profileConfig, options, messageHandler, }: { serverBaseUrl: string; profileConfig?: { apiKey: string; secretKey: string; passPhrase: string; }; options?: { autoLogin?: boolean; logLoginMessage?: boolean; logSubscriptionMessage?: boolean; logChannelTopicMessage?: boolean; logTradeMessage?: boolean; }; messageHandler?: (message: string) => any; }); /** * Get the event emitter */ get event(): EventEmitter; /** * start connecting to server */ connect(): Promise<void>; /** * sending message payload to server * * @param payload */ send(payload: object): Promise<void>; /** * subscribe channel topic * * @param subscriptionTopic * @returns */ subscribeChannel(subscriptionTopic: SubscriptionTopic): Promise<SubscriptionResponse>; /** * unsubscribe channel topic * * @param subscriptionTopic * @returns */ unsubscribeChannel(subscriptionTopic: SubscriptionTopic): Promise<UnsubscriptionResponse>; /** * Add channel topic message handler * * @param subscriptionTopic * @param channelMessageHandler */ addChannelMessageHandler(subscriptionTopic: SubscriptionTopic, channelMessageHandler: ChannelMessageHandler): void; /** * Remove channel topic message handler * * @param subscriptionTopic * @param channelMessageHandler */ removeChannelMessageHandler(subscriptionTopic: SubscriptionTopic, channelMessageHandler: ChannelMessageHandler): void; /** * Remove that channel topic's ALL message handler * * @param subscriptionTopic */ removeAllChannelMessageHandler(subscriptionTopic: SubscriptionTopic): void; /** * Send trade op message * * @param payload * @returns */ trade(payload: TradePayload): Promise<TradeResponse>; /** * close connection */ close(): void; } export { OkxV5Ws };