UNPKG

bitmart-api

Version:

Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.

33 lines (32 loc) 1.69 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"; readonly futuresPublicV2: "futuresPublicV2"; readonly futuresPrivateV2: "futuresPrivateV2"; }; /** This is used to differentiate between each of the available websocket streams */ export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP]; /** * Some exchanges have two livenet environments, some have test environments, some dont. This allows easy flexibility for different exchanges. * Examples: * - One livenet and one testnet: NetworkMap<'livenet' | 'testnet'> * - One livenet, sometimes two, one testnet: NetworkMap<'livenet' | 'testnet', 'livenet2'> * - Only one livenet, no other networks: NetworkMap<'livenet'> */ type NetworkMap<TRequiredKeys extends string, TOptionalKeys extends string | undefined = undefined> = Record<TRequiredKeys, string> & (TOptionalKeys extends string ? Record<TOptionalKeys, string | undefined> : Record<TRequiredKeys, string>); export declare const WS_BASE_URL_MAP: Record<WsKey, NetworkMap<'livenet', 'demo'>>; export declare const WS_ERROR_ENUM: { INVALID_ACCESS_KEY: string; }; export declare function neverGuard(x: never, msg: string): Error; /** * 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; export {};