UNPKG

okx-api

Version:

Complete & robust Node.js SDK for OKX's REST APIs and WebSockets, with TypeScript & end-to-end tests

36 lines (35 loc) 1.91 kB
import { APIMarket, WebsocketClientOptions, WsChannel } from '../types'; import { DefaultLogger } from './logger'; export declare const WS_BASE_URL_MAP: Record<APIMarket, Record<'public' | 'private', string>>; export declare const WS_KEY_MAP: { readonly prodPublic: "prodPublic"; readonly prodPrivate: "prodPrivate"; readonly demoPublic: "demoPublic"; readonly demoPrivate: "demoPrivate"; readonly businessPrivate: "businessPrivate"; readonly businessPublic: "businessPublic"; readonly businessDemoPublic: "businessDemoPublic"; readonly businessDemoPrivate: "businessDemoPrivate"; }; /** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */ export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; export declare const PRIVATE_WS_KEYS: WsKey[]; export declare const PUBLIC_WS_KEYS: WsKey[]; /** Determine which WsKey (ws connection) to route an event to */ export declare function getWsKeyForTopicChannel(market: APIMarket, channel: WsChannel, isPrivate?: boolean): WsKey; export declare function getWsKeyForMarket(market: APIMarket, isPrivate: boolean, isBusinessChannel: boolean): WsKey; /** Maps a WS key back to a WS URL */ export declare function getWsUrlForWsKey(wsKey: WsKey, wsClientOptions: WebsocketClientOptions, logger: typeof DefaultLogger): string; export declare function getMaxTopicsPerSubscribeEvent(market: APIMarket): number | null; export declare function isWsPong(event: unknown): boolean; export declare const WS_EVENT_CODE_ENUM: { OK: string; LOGIN_FAILED: string; LOGIN_PARTIALLY_FAILED: string; }; /** * #305: ws.terminate() is undefined in browsers. * This only works in node.js, not in browsers. * Does nothing if `ws` is undefined. Does nothing in browsers. */ export declare function safeTerminateWs(ws?: WebSocket | any, fallbackToClose?: boolean): boolean;