UNPKG

kucoin-api

Version:

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

37 lines (36 loc) 1.58 kB
import WebSocket from 'isomorphic-ws'; /** Should be one WS key per unique URL */ export declare const WS_KEY_MAP: { readonly spotPublicV1: "spotPublicV1"; readonly spotPrivateV1: "spotPrivateV1"; readonly futuresPublicV1: "futuresPublicV1"; readonly futuresPrivateV1: "futuresPrivateV1"; }; /** This is used to differentiate between each of the available websocket streams */ export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; /** * Normalised internal format for a request (subscribe/unsubscribe/etc) on a topic, with optional parameters. * * - Topic: the topic this event is for * - Payload: the parameters to include, optional. E.g. auth requires key + sign. Some topics allow configurable parameters. */ export interface WsTopicRequest<TWSTopic extends string = string, TWSPayload = any> { topic: TWSTopic; payload?: TWSPayload; } /** * Conveniently allow users to request a topic either as string topics or objects (containing string topic + params) */ export type WsTopicRequestOrStringTopic<TWSTopic extends string, TWSPayload = any> = WsTopicRequest<TWSTopic, TWSPayload> | string; export interface MessageEventLike { target: WebSocket; type: 'message'; data: string; } export declare function isMessageEvent(msg: unknown): msg is MessageEventLike; /** * #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;