UNPKG

@strong-roots-capital/bybit-api

Version:

TypeScript API for Bybit cryptocurrency exchange

84 lines 4.11 kB
import * as TE from 'fp-ts/TaskEither'; import * as t from 'io-ts'; import { BybitRestMessage } from './codecs/rest/BybitRestMessage'; declare type BybitUnexpectedRequestError = { type: 'unexpected http request'; request: unknown; }; declare type BybitHttpRequestError = { type: 'http request error'; error: Error; }; declare type BybitUnexpectedResponseError = { type: 'unable to parse http response'; response: unknown; error: string; }; export declare type BybitRestApiError = BybitUnexpectedRequestError | BybitHttpRequestError | BybitUnexpectedResponseError; declare type BybitPublicRestClientConfig = { testnet: boolean; url: string; requestTimeoutMS: number; }; declare type BybitApiEndpoint<A extends t.Mixed, B extends t.Mixed> = { request: A; response: B; }; declare type BybitRestApiRequest<T> = T extends BybitApiEndpoint<infer A, any> ? t.TypeOf<A> : never; declare type BybitRestApiResponse<T> = T extends BybitApiEndpoint<any, infer A> ? BybitRestMessage<t.TypeOf<A>> : never; declare const PublicRestApi: { readonly kline: { readonly method: "get"; readonly resource: "v2/public/kline/list"; readonly request: t.IntersectionC<[t.TypeC<{ symbol: t.KeyofC<Record<"BTCUSD" | "ETHUSD" | "EOSUSD" | "XRPUSD" | "BTCUSDT" | "ETHUSDT" | "AXSUSDT" | "XRPUSDT" | "DOGEUSDT" | "EOSUSDT" | "THETAUSDT" | "TRXUSDT" | "COMPUSDT" | "XLMUSDT" | "ADAUSDT" | "DOTUSDT" | "BNBUSDT" | "LTCUSDT" | "ETCUSDT" | "MATICUSDT" | "LINKUSDT" | "AAVEUSDT" | "BCHUSDT" | "SOLUSDT" | "UNIUSDT" | "FILUSDT" | "SUSHIUSDT" | "XTZUSDT" | "XEMUSDT", null>>; interval: t.Type<{ quantifier: number & t.Brand<t.IntBrand> & (1 | 60); unit: "minute"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "hour"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "day"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "week"; }, string, unknown>; from: import("io-ts-types").DateFromUnixTimeC; }>, t.PartialC<{ limit: t.BrandC<t.NumberC, t.IntBrand>; }>]>; readonly response: t.TypeC<{ symbol: t.KeyofC<Record<"BTCUSD" | "ETHUSD" | "EOSUSD" | "XRPUSD" | "BTCUSDT" | "ETHUSDT" | "AXSUSDT" | "XRPUSDT" | "DOGEUSDT" | "EOSUSDT" | "THETAUSDT" | "TRXUSDT" | "COMPUSDT" | "XLMUSDT" | "ADAUSDT" | "DOTUSDT" | "BNBUSDT" | "LTCUSDT" | "ETCUSDT" | "MATICUSDT" | "LINKUSDT" | "AAVEUSDT" | "BCHUSDT" | "SOLUSDT" | "UNIUSDT" | "FILUSDT" | "SUSHIUSDT" | "XTZUSDT" | "XEMUSDT", null>>; interval: t.Type<{ quantifier: number & t.Brand<t.IntBrand> & (1 | 60); unit: "minute"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "hour"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "day"; } | { quantifier: t.Brand<t.IntBrand> & 1; unit: "week"; }, string, unknown>; open_time: import("io-ts-types").DateFromUnixTimeC; open: import("io-ts-types").NumberFromStringC; high: import("io-ts-types").NumberFromStringC; low: import("io-ts-types").NumberFromStringC; close: import("io-ts-types").NumberFromStringC; volume: import("io-ts-types").NumberFromStringC; turnover: import("io-ts-types").NumberFromStringC; }>; }; }; declare type PublicRestApi = typeof PublicRestApi; declare type BybitPublicRestApiClient = { [A in keyof PublicRestApi]: (request: BybitRestApiRequest<PublicRestApi[A]>) => TE.TaskEither<BybitRestApiError, BybitRestApiResponse<PublicRestApi[A]>>; }; export declare type BybitRestClient = BybitPublicRestApiClient; export declare const bybitRestClient: (clientConfig: Partial<BybitPublicRestClientConfig> & Pick<BybitPublicRestClientConfig, 'testnet'>) => BybitRestClient; export {}; //# sourceMappingURL=rest.d.ts.map