BitkubClient is a class that provides methods to interact with the Bitkub API. It allows users to perform various operations such as getting server time, retrieving market symbols, checking balances, placing bids and asks, and canceling orders.

BitkubClient

Example

const client = new BitkubClient(apiKey, apiSecret);
const serverTime = await client.getServerTime();
const symbols = await client.getSymbols();
const balances = await client.getBalances();
const bids = await client.getBids('BTC_THB');
const asks = await client.getAsks('BTC_THB');
const placeBidResponse = await client.placeBid('BTC_THB', 1, 500000);
const placeAskResponse = await client.placeAsk('BTC_THB', 1, 600000);
const cancelOrderResponse = await client.cancelOrder(null, 'BTC_THB', '12345', 'buy');

Param: apiKey

Your API Key

Param: apiSecret

Your API Secret

Param: environment

Environment to call API

Param: baseApiUrl

Base API URL

Param: requestTimeout

Request timeout in milliseconds

Constructors

  • Create a new BitkubClient

    Parameters

    • apiKey: string

      Your API Key

    • apiSecret: string

      Your API Secret

    • environment: BitkubEnvironment = BitkubEnvironment.TEST

      Environment to call API

    • baseApiUrl: string = SECURE_API_URL

      Base API URL

    • requestTimeout: number = 10000

      Request timeout in milliseconds

    Returns default

Properties

_apiKey: string
_apiSecret: string
_axiosInstance: Axios
_baseApiUrl: string
_environment: BitkubEnvironment
_requestHeaders: BitkubHeaderType
_requestTimeout: number

Accessors

  • set apiKey(key): void
  • Change the api secret in axios configuration

    Parameters

    • key: string

    Returns void

  • set apiSecret(secret): void
  • Change the api secret

    Parameters

    • secret: string

    Returns void

  • set baseApiUrl(url): void
  • Change the base url in axios configuration

    Parameters

    • url: string

    Returns void

  • set requestTimeout(timeout): void
  • Change the request timeout in axios configuration

    Parameters

    • timeout: number

    Returns void

Methods

  • Cancel order

    Parameters

    • hash: null | string
    • symbol: undefined | string = undefined
    • orderId: undefined | string = undefined

      : Order Id

    • orderSide: undefined | OrderSide = undefined

    Returns Promise<AxiosResponse<CancelResponse, any>>

    Result of cancelling order

  • Create an axios instance

    Returns AxiosInstance

  • Parameters

    • token: string

    Returns string

  • Get ask list from Bitkub

    Parameters

    • symbol: string

      Trading Symbol (THB_BNB, THB_BTC)

    • limit: number = 1

      Response Limit Size

    Returns Promise<AxiosResponse<AskResponse, any>>

    A list of ask

  • Get bid list from Bitkub

    Parameters

    • symbol: string

      Trading Symbol (BNB_THB, BTC_THB)

    • limit: number = 1

      Response Limit Size

    Returns Promise<AxiosResponse<BidResponse, any>>

    A list of bid

  • Get server time

    Returns Promise<AxiosResponse<number, any>>

    Bitkub server time

  • Place ask

    Parameters

    • symbol: string

      Trading Symbol (THB_BNB, THB_BTC)

    • amount: number

      Sell amount

    • rate: number

      Price rate

    • orderType: BitkubOrderType = BitkubOrderType.MARKET

      Order type (LIMIT, MARKET)

    • clientId: undefined | string = undefined

    Returns Promise<AxiosResponse<PlaceAskResponse, any>>

    Result of placing ask

  • Place bid

    Parameters

    • symbol: string

      Trading Symbol (THB_BNB, THB_BTC)

    • amount: number

      Buy amount

    • rate: number

      Price rate

    • orderType: BitkubOrderType = BitkubOrderType.MARKET

      Order type (LIMIT, MARKET)

    • clientId: undefined | string = undefined

    Returns Promise<AxiosResponse<PlaceBidResponse, any>>

    Result of placing bid

  • Change environment to call API It will affect to call place-bid and place-ask api.

    Parameters

    Returns void