UNPKG

bitmart-api

Version:

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

51 lines (50 loc) 2.12 kB
import { AxiosRequestConfig } from 'axios'; import { RestClientOptions } from './requestUtils.js'; /** * Used to switch how authentication/requests work under the hood */ export declare const REST_CLIENT_TYPE_ENUM: { readonly mainV1: "mainV1"; readonly mainV2: "mainV2"; }; export type RestClientType = (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM]; export declare abstract class BaseRestClient { private options; private baseUrl; private globalRequestOptions; private apiKey; private apiSecret; private apiMemo; /** Defines the client type (affecting how requests & signatures behave) */ abstract getClientType(): RestClientType; /** * Create an instance of the REST client. Pass API credentials in the object in the first parameter. * @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity * @param {AxiosRequestConfig} [networkOptions={}] HTTP networking options for axios */ constructor(restClientOptions?: RestClientOptions, networkOptions?: AxiosRequestConfig); /** * Timestamp used to sign the request. Override this method to implement your own timestamp/sync mechanism */ getSignTimestampMs(): number; get(endpoint: string, params?: any): Promise<any>; post(endpoint: string, params?: any): Promise<any>; getPrivate(endpoint: string, params?: any): Promise<any>; postPrivate(endpoint: string, params?: any): Promise<any>; deletePrivate(endpoint: string, params?: any): Promise<any>; /** * @private Make a HTTP request to a specific endpoint. Private endpoint API calls are automatically signed. */ private _call; /** * @private generic handler to parse request exceptions */ parseException(e: any, request: AxiosRequestConfig<any>): unknown; /** * @private sign request and set recv window */ private signRequest; private prepareSignParams; /** Returns an axios request object. Handles signing process automatically if this is a private API call */ private buildRequest; }