bybit-api-gnome
Version:
Forked for Lick Hunter, Complete & robust node.js SDK for Bybit's REST APIs and WebSockets v5, with TypeScript & integration tests.
152 lines (151 loc) • 5.31 kB
TypeScript
import { AxiosRequestConfig } from 'axios';
import { RestClientOptions } from './util/requestUtils';
export interface V5APIResponse<T = any> {
retCode: number;
retMsg: string;
result: T;
retExtInfo: any;
time: number;
}
export interface V5RestClientOptions extends RestClientOptions {
/** Override the base URL for v5 API endpoints */
baseUrl?: string;
}
export default class RestClientV5 {
private timeOffset;
private syncTimePromise;
private options;
private baseUrl;
private globalRequestOptions;
private key;
private secret;
constructor(restOptions?: V5RestClientOptions, networkOptions?: AxiosRequestConfig);
private getV5BaseUrl;
get<T = any>(endpoint: string, params?: any): Promise<V5APIResponse<T>>;
getPrivate<T = any>(endpoint: string, params?: any): Promise<V5APIResponse<T>>;
post<T = any>(endpoint: string, params?: any): Promise<V5APIResponse<T>>;
postPrivate<T = any>(endpoint: string, params?: any): Promise<V5APIResponse<T>>;
deletePrivate<T = any>(endpoint: string, params?: any): Promise<V5APIResponse<T>>;
getServerTime(): Promise<V5APIResponse<{
timeSecond: string;
timeNano: string;
}>>;
getKline(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol: string;
interval: string;
start?: number;
end?: number;
limit?: number;
}): Promise<V5APIResponse<any>>;
getOrderbook(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol: string;
limit?: number;
}): Promise<V5APIResponse<any>>;
getTickers(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
expDate?: string;
}): Promise<V5APIResponse<any>>;
getInstrumentsInfo(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
limit?: number;
cursor?: string;
}): Promise<V5APIResponse<any>>;
placeOrder(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol: string;
side: 'Buy' | 'Sell';
orderType: 'Market' | 'Limit';
qty: string;
price?: string;
timeInForce?: 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
orderLinkId?: string;
isLeverage?: 0 | 1;
orderFilter?: 'Order' | 'tpslOrder' | 'StopOrder';
triggerDirection?: 1 | 2;
triggerPrice?: string;
triggerBy?: 'LastPrice' | 'IndexPrice' | 'MarkPrice';
orderIv?: string;
positionIdx?: 0 | 1 | 2;
takeProfit?: string;
stopLoss?: string;
tpTriggerBy?: 'LastPrice' | 'IndexPrice' | 'MarkPrice';
slTriggerBy?: 'LastPrice' | 'IndexPrice' | 'MarkPrice';
reduceOnly?: boolean;
closeOnTrigger?: boolean;
mmp?: boolean;
}): Promise<V5APIResponse<any>>;
cancelOrder(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol: string;
orderId?: string;
orderLinkId?: string;
orderFilter?: 'Order' | 'tpslOrder' | 'StopOrder';
}): Promise<V5APIResponse<any>>;
getOrders(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
settleCoin?: string;
orderId?: string;
orderLinkId?: string;
openOnly?: 0 | 1;
orderFilter?: 'Order' | 'tpslOrder' | 'StopOrder';
limit?: number;
cursor?: string;
}): Promise<V5APIResponse<any>>;
getOrderHistory(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
settleCoin?: string;
orderId?: string;
orderLinkId?: string;
orderFilter?: 'Order' | 'tpslOrder' | 'StopOrder';
orderStatus?: string;
startTime?: number;
endTime?: number;
limit?: number;
cursor?: string;
}): Promise<V5APIResponse<any>>;
getPositionInfo(params: {
category: 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
settleCoin?: string;
limit?: number;
cursor?: string;
}): Promise<V5APIResponse<any>>;
setLeverage(params: {
category: 'linear' | 'inverse';
symbol: string;
buyLeverage: string;
sellLeverage: string;
}): Promise<V5APIResponse<any>>;
getWalletBalance(params: {
accountType: 'UNIFIED' | 'CONTRACT' | 'SPOT' | 'INVESTMENT' | 'OPTION' | 'FUND';
coin?: string;
}): Promise<V5APIResponse<any>>;
getFeeRate(params: {
category: 'spot' | 'linear' | 'inverse' | 'option';
symbol?: string;
baseCoin?: string;
}): Promise<V5APIResponse<any>>;
getCoinBalance(params: {
accountType: 'SPOT' | 'CONTRACT' | 'INVESTMENT' | 'OPTION' | 'UNIFIED' | 'FUND';
coin?: string;
}): Promise<V5APIResponse<any>>;
getAllCoinBalance(params: {
accountType: 'SPOT' | 'CONTRACT' | 'INVESTMENT' | 'OPTION' | 'UNIFIED' | 'FUND';
}): Promise<V5APIResponse<any>>;
private buildRequest;
private _call;
private parseException;
private syncTime;
private fetchTimeOffset;
}