kucoin-api
Version:
Complete & robust Node.js SDK for Kucoin's REST APIs and WebSockets, with TypeScript & strong end to end tests.
43 lines (42 loc) • 2.05 kB
TypeScript
import WebSocket from 'isomorphic-ws';
import { WsRequestOperationKucoin } from '../../types/websockets/ws-api.js';
/** 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";
readonly wsApiSpotV1: "wsApiSpotV1";
readonly wsApiFuturesV1: "wsApiFuturesV1";
};
/** This is used to differentiate between each of the available websocket streams */
export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP];
export type WSAPIWsKey = typeof WS_KEY_MAP.wsApiFuturesV1 | typeof WS_KEY_MAP.wsApiSpotV1;
/**
* 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;
/**
* #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;
/**
* WS API promises are stored using a primary key. This key is constructed using
* properties found in every request & reply.
*
* The counterpart to this is in resolveEmittableEvents
*/
export declare function getPromiseRefForWSAPIRequest(wsKey: WsKey, requestEvent: WsRequestOperationKucoin<string>): string;
export declare function isWSAPIWsKey(wsKey: WsKey): wsKey is WSAPIWsKey;