Miss any of our Open RFC calls?Watch the recordings here! »

kucoin-sdk

2.0.1 • Public • Published

Kucoin SDK 2.0.0

Version 1.x.x Endpoints match the API documentation semantically.

Version 2.x.x is Typescript integrated, partially unit tested, and contains copied docstrings and documentation references for IDE hinting.

Version 3.x.x will contain a WebSocket implementation.

2.x.x User Facing Changes

  1. PASSPHRASE?: string can be added as a parameter to the class instantiation. It is you API creation passphrase, and is required for signing authenticated requests for private endpoints.
  2. isTest?: boolean can be addedas a parameter to the class instantiation to indicate sandbox usage.

Additional Features

  • Axios interceptor callbacks on KucoinInstance
  • Param checker with console.warning or throw e for missing or unused paramters at runtime

Installation

npm i --save kucoin-sdk

Import Package(s)

  • const Kucoin = require('kucoin-sdk')
  • Or ES6 imports: import Kucoin from 'kucoin-sdk'

Usage

const Kucoin = require('kucoin-sdk')
 
const KucoinInstance = new Kucoin({
  KEY: 'xxxxxxxxxxxxxxxxxxxxxx',
  SECRET: 'xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxx',
  isTest?: true,
  PASSPHRASE?: 'xxxxxxxxxx',
})
 
const requestInterceptor = KucoinInstance.addRequestInterceptor(
  config => config,
  error => error
)
 
const responseInterceptor = KucoinInstance.addResponseInterceptor(
  response => response,
  error => error
)
 
...
 
KucoinInstance.getKlines({ symbol: 'BTC-USDT', type: '1min' })
  .then(console.log)
  .catch(console.error)
 
...
 
KucoinInstance.removeRequestInterceptor(requestInterceptor)

Auxillary Helper Methods

addRequestInterceptor

  • Docs

    • Callback to access Axios interceptor.
    • const interceptor = KucoinInstance.addRequestInterceptor(onBeforeCallback, onErrorCallback)
  • Types

(
  onBeforeCallback (valueAxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>,
  onErrorCallback: (error: AxiosError) => AxiosError | Promise<AxiosError>
) => any

removeRequestInterceptor

  • Docs

    • Callback to access Axios interceptor.
    • KucoinInstance.removeRequestInterceptor(interceptor)
  • Types

(interceptor: any) => void

addResponseInterceptor

  • Docs

    • Callback to access Axios interceptor.
    • const interceptor = KucoinInstance.addResponseInterceptor(onSuccessCallback, onErrorCallback)
  • Types

;(
  onSuccessCallback: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>,
  onErrorCallback: (error: AxiosError) => AxiosError | Promise<AxiosError>
) => any

removeResponseInterceptor

  • Docs

    • Callback to access Axios interceptor.
    • KucoinInstance.removeResponseInterceptor(interceptor)
  • Types

(interceptor: any) => void

(Public) API Endpoint Methods

async getSymbolsList

  • Docs

    • https://docs.kucoin.com/#get-symbols-list
    • Request via this endpoint to get a list of available currency pairs for trading. If you want to get the market information of the trading symbol, please use Get All Tickers.
    • KucoinInstance.getSymbolsList().then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ market?: string }>) => Promise<
  KucoinSDK.Http.Data<
    {
      symbolstring
      namestring
      baseCurrencystring
      quoteCurrencystring
      baseMinSizenumber
      quoteMinSizenumber
      baseMaxSizenumber
      quoteMaxSizenumber
      baseIncrementnumber
      quoteIncrementnumber
      priceIncrementnumber
      feeCurrencystring
      enableTradingboolean
      isMarginEnabledboolean
      priceLimitRatenumber
    }[]
  >
>

async getTicker

  • Docs

    • https://docs.kucoin.com/#get-ticker
    • Request via this endpoint to get Level 1 Market Data. The returned value includes the best bid price and size, the best ask price and size as well as the last traded price and the last traded size.
    • KucoinInstance.getTicker({ symbol: 'BTC-USDT' }).then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    sequencenumber
    bestAsknumber
    sizenumber
    pricenumber
    bestBidSizenumber
    bestBidnumber
    bestAskSizenumber
    timenumber
  }>
>

async getAllTickers

  • Docs

    • https://docs.kucoin.com/#get-all-tickers
    • Request market tickers for all the trading pairs in the market (including 24h volume). On the rare occasion that we will change the currency name, if you still want the changed symbol name, you can use the symbolName field instead of the symbol field via “Get all tickers” endpoint.
    • KucoinInstance.getAllTickers().then(console.log).catch(console.error)
  • Types

() => Promise<
  KucoinSDK.Http.Data<{
    timenumber
    ticker{
      symbolstring
      symbolNamestring
      buynumber
      sellnumber
      changeRatenumber
      changePricenumber
      highnumber
      lownumber
      volnumber
      volValuenumber
      lastnumber
    }[]
  }>
>

async get24HourStats

  • Docs

    • https://docs.kucoin.com/#get-24hr-stats
    • Request via this endpoint to get the statistics of the specified ticker in the last 24 hours.
    • KucoinInstance.get24HourStats({ symbol: 'BTC-USDT' }).then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    symbolstring
    highnumber
    volnumber
    volValuenumber
    lastnumber
    lownumber
    buynumber
    sellnumber
    changePricenumber
    averagePricenumber
    timenumber
    changeRatenumber
  }>
>

async getMarketList

  • Docs

    • https://docs.kucoin.com/#get-market-list
    • Request via this endpoint to get the transaction currency for the entire trading market.
    • KucoinInstance.getMarketList().then(console.log).catch(console.error)
  • Types

() => Promise<
  KucoinSDK.Http.Data<{
    datastring[]
  }>
>

async getCurrencies

() => Promise<
  KucoinSDK.Http.Data<
    {
      currencystring
      namestring
      fullNamestring
      precisionnumber
      withdrawalMinSizenumber
      withdrawalMinFeenumber
      isWithdrawEnabledboolean
      isDepositEnabledboolean
      isMarginEnabledboolean
      isDebitEnabledboolean
    }[]
  >
>

async getCurrencyDetail

(currency: string, params: KucoinSDK.Http.Params<{ chain?: string[] }>) => Promise<
  KucoinSDK.Http.Data<{
    currencystring
    namestring
    fullNamestring
    precisionnumber
    withdrawalMinSizenumber
    withdrawalMinFeenumber
    isWithdrawEnabledboolean
    isDepositEnabledboolean
    isMarginEnabledboolean
    isDebitEnabledboolean
  }>
>

async getFiatPrice

  • Docs

    • https://docs.kucoin.com/#get-fiat-price
    • Request via this endpoint to get the fiat price of the currencies for the available trading pairs.
    • KucoinInstance.getFiatPrice({ base: 'USD', currencies: ['BTC', 'ETH'] }).then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ base?: string; currencies?: string[] }>) => Promise<
  KucoinSDK.Http.Data<{
    codenumber
    data{
      [currencystring]number
    }
  }>
>

async getPartOrderBook

  • Docs

    • https://docs.kucoin.com/#get-part-order-book-aggregated
    • Request via this endpoint to get a list of open orders for a symbol. Level-2 order book includes all bids and asks (aggregated by price), this level returns only one size for each active price (as if there was only a single order for that price). Query via this endpoint and the system will return only part of the order book to you. If you request level2_20, the system will return you 20 pieces of data (ask and bid data) on the order book. If you request level_100, the system will return 100 pieces of data (ask and bid data) on the order book to you. You are recommended to request via this endpoint as the system reponse would be faster and cosume less traffic. To maintain up-to-date Order Book, please use Websocket incremental feed after retrieving the Level 2 snapshot.
    • KucoinInstance.getPartOrderBook(level: 20, { symbol: 'USDT-BTC' }).then(console.log).catch(console.error)
  • Types

(level: 20 | 100, params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    sequencenumber
    timenumber
    bidsnumber[][]
    asksnumber[][]
  }>
>

async getFullOrderBookAggregated

  • Docs

    • https://docs.kucoin.com/#get-full-order-book-aggregated
    • Request via this endpoint to get the order book of the specified symbol. Level 2 order book includes all bids and asks (aggregated by price). This level returns only one aggregated size for each price (as if there was only one single order for that price). This API will return data with full depth. It is generally used by professional traders because it uses more server resources and traffic, and we have strict access frequency control. To maintain up-to-date Order Book, please use Websocket incremental feed after retrieving the Level 2 snapshot.
    • KucoinInstance.getFullOrderBookAggregated({ symbol: 'USDT-BTC' }).then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    sequencenumber
    timenumber
    bidsnumber[][]
    asksnumber[][]
  }>
>

async getFullOrderBookAtomic

  • Docs

    • https://docs.kucoin.com/#get-full-order-book-atomic
    • Request via this endpoint to get the Level 3 order book of the specified trading pari. Level 3 order book includes all bids and asks (the data is non-aggregated, and each item means a single order). This API is generally used by professional traders because it uses more server resources and traffic, and we have strict access frequency control. To maintain up-to-date order book, please use Websocket incremental feed after retrieving the Level 3 snapshot. In the orderbook, the selling data is sorted low to high by price and orders with the same price are sorted in time sequence. The buying data is sorted high to low by price and orders with the same price are sorted in time sequence. The matching engine will match the orders according to the price and time sequence.
    • KucoinInstance.getFullOrderBookAtomic({ symbol: 'USDT-BTC' }).then(console.log).catch(console.error)
  • Types

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    sequencenumber
    timenumber
    bidsnumber[][]
    asksnumber[][]
  }>
>

async getTradeHistories

  • Docs

  • Types

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<
    {
      sequencenumber
      pricenumber
      sizenumber
      sidestring
      timenumber
    }[]
  >
>

async getKlines

  • Docs

    • https://docs.kucoin.com/#get-klines
    • Request via this endpoint to get the kline of the specified symbol. Data are returned in grouped buckets based on requested type.
    • KucoinInstance.getKlines({ symbol: 'USDT-BTC', type: '1min' }).then...
  • Types

(
  paramsKucoinSDK.Http.Params<{
    symbol: string
    startAt?: string
    endAt?: string
    type:
      | '1min'
      | '3min'
      | '5min'
      | '15min'
      | '30min'
      | '1hour'
      | '2hour'
      | '4hour'
      | '6hour'
      | '8hour'
      | '12hour'
      | '1day'
      | '1week'
  }>
)Promise<KucoinSDK.Http.Data<number[][]>>

(Private) API Endpoint Methods

async getUserSubInfo

() => Promise<
  KucoinSDK.Http.Data<
    {
      userIdstring
      subNamestring
      remarksstring
    }[]
  >
>

async createAnAccount

(params: KucoinSDK.Http.Params<{ currency: string; type: 'main' | 'trade' | 'margin' }>) => Promise<
  KucoinSDK.Http.Data<{
    idstring
  }>
>

async listAccounts

  • Docs

    • https://docs.kucoin.com/#list-accounts
    • Get a list of accounts. Please deposit funds to the main account firstly, then transfer the funds to the trade account via Inner Transfer before transaction.
    • KucoinInstance.listAccounts().then...
  • Types

(params: KucoinSDK.Http.Params<{ currency?: string; type?: 'main' | 'trade' | 'margin' | 'pool' }>) => Promise<
  KucoinSDK.Http.Data<
    {
      idstring
      currencystring
      typestring
      balancenumber
      availablenumber
      holdsnumber
    }[]
  >
>

async getAnAccount

(params: KucoinSDK.Http.Params<{ accountId: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currencystring
    balancenumber
    availablenumber
    holdsnumber
  }>
>

async getAccountLedgers

  • Docs

    • https://docs.kucoin.com/#get-account-ledgers
    • Request via this endpoint to get the account ledgers. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
    • KucoinInstance.getAccountLedgers({ accountId: 'xxxxxx' }).then...
  • Types

(params: KucoinSDK.Http.Params<{
  accountId: string
  startAt?: string
  endAt?: string
  direction?: 'in' | 'out'
  bizType?:
    | 'DEPOSIT'
    | 'WITHDRAW'
    | 'TRANSFER'
    | 'SUB_TRANSFER'
    | 'TRADE_EXCHANGE'
    | 'MARGIN_EXCHANGE'
    | 'KUCOIN_BONUS'
  }>) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      idstring
      currencystring
      amountnumber
      feenumber
      balancenumber
      bizTypestring
      directionstring
      createdAtnumber
      context{
        orderIdstring
        txIdstring
      }
    }[]
  }>
>

async getHolds

  • Docs

    • https://docs.kucoin.com/#get-holds
    • Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For a withdraw, once it is completed, the hold is removed.
  • Types

(params: KucoinSDK.Http.Params<{ accountId: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      currencystring
      holdAmountnumber
      bizTypestring
      orderIdstring
      createdAtnumber
      updatedAtnumber
    }[]
  }>
>

async getSubAccountBalance

(params: KucoinSDK.Http.Params<{ subUserId: string }>) => Promise<
  KucoinSDK.Http.Data<{
    subUserIdstring
    subNamestring
    mainAccounts{
      currencystring
      balancenumber
      availablenumber
      holdsnumber
      baseCurrencystring
      baseCurrencyPricenumber
      baseAmountnumber
    }[]
    tradeAccounts?: {
      currencystring
      balancenumber
      availablenumber
      holdsnumber
      baseCurrencystring
      baseCurrencyPricenumber
      baseAmountnumber
    }[]
    marginAccounts?: {
      currencystring
      balancenumber
      availablenumber
      holdsnumber
      baseCurrencystring
      baseCurrencyPricenumber
      baseAmountnumber
    }[]
  }>
>

async getAggregatedSubAccountBalance

() => Promise<
  KucoinSDK.Http.Data<
    {
      subUserIdstring
      subNamestring
      mainAccounts{
        currencystring
        balancenumber
        availablenumber
        holdsnumber
        baseCurrencystring
        baseCurrencyPricenumber
        baseAmountnumber
      }[]
      tradeAccounts?: {
        currencystring
        balancenumber
        availablenumber
        holdsnumber
        baseCurrencystring
        baseCurrencyPricenumber
        baseAmountnumber
      }[]
      marginAccounts?: {
        currencystring
        balancenumber
        availablenumber
        holdsnumber
        baseCurrencystring
        baseCurrencyPricenumber
        baseAmountnumber
      }[]
    }[]
  >
>

async getTheTransferable

(params: KucoinSDK.Http.Params<{ currency: string; type: 'MAIN' | 'TRADE' | 'MARGIN' | 'POOL' }>) => Promise<
  KucoinSDK.Http.Data<{
    currencystring
    balancenumber
    availablenumber
    holdsnumber
    transferablenumber
  }>
>

async transferBetweenMasterAndSubUser

(
  paramsKucoinSDK.Http.Params<{
    clientOid: string
    currencystring
    amountstring | number
    direction'OUT' | 'IN'
    accountType?: 'MAIN'
    subAccountType?: 'MAIN' | 'TRADE' | 'MARGIN'
    subUserIdstring
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    orderIdstring
  }>
>

async innerTransfer

  • Docs

    • https://docs.kucoin.com/#inner-transfer
    • The inner transfer interface is used for transferring assets between the accounts of a user and is free of charges. For example, a user could transfer assets from their main account to their trading account on the platform. Support transfer between main account and pool account.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    clientOid: string
    currencystring
    from'main' | 'trade' | 'margin' | 'pool'
    to'main' | 'trade' | 'margin' | 'pool'
    amountstring | number
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    orderIdstring
  }>
>

async createDepositAddress

(params: KucoinSDK.Http.Params<{ currency: string; chain?: string }>) => Promise<
  KucoinSDK.Http.Data<{
    addressstring
    memostring
    chainstring
  }>
>

async getDepositAddress

(params: KucoinSDK.Http.Params<{ currency: string; chain?: string }>) => Promise<
  KucoinSDK.Http.Data<{
    addressstring
    memostring
    chainstring
  }>
>

async getDepositList

  • Docs

    • https://docs.kucoin.com/#get-deposit-list
    • Request via this endpoint to get deposit list Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    currency?: string 
    startAt?: string 
    endAt?: string 
    status?: string 
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      addressstring
      memostring
      amountnumber
      feenumber
      currencystring
      isInnerboolean
      walletTxIdstring
      statusstring
      remarkstring
      createdAtnumber
      updatedAtnumber
    }[]
  }>
>

async getHistoricalDepositsList

(
  paramsKucoinSDK.Http.Params<{
    currency?: string 
    startAt?: string 
    endAt?: string 
    status?: string 
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      currencystring
      createAtnumber
      amountnumber
      walletTxIdstring
      isInnerboolean
      statusstring
    }[]
  }>
>

async getWithdrawalsList

(
  paramsKucoinSDK.Http.Params<{
    currency?: string 
    startAt?: string 
    endAt?: string 
    status?: string 
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      idstring
      addressstring
      memostring
      currencystring
      amountnumber
      feenumber
      walletTxIdstring
      isInnerboolean
      statusstring
      remarkstring
      createdAtnumber
      updatedAtnumber
    }[]
  }>
>

async getHistoricalWithdrawalsList

(
  paramsKucoinSDK.Http.Params<{
    currency?: string 
    startAt?: string 
    endAt?: string 
    status?: 'PROCESSING' | 'SUCCESS' | 'FAILURE'
    currentPage?: number 
    pageSize?: number 
  }>
)Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      currencystring
      createAtnumber
      amountnumber
      addressstring
      walletTxIdstring
      isInnerboolean
      statusstring
    }[]
  }>
>

async getWithdrawalQuotas

(params: KucoinSDK.Http.Params<{ currency: string; chain?: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currencystring
    limitBTCAmountnumber
    usedBTCAmountnumber
    limitAmountnumber
    remainAmountnumber
    availableAmountnumber
    withdrawMinFeenumber
    innerWithdrawMinFeenumber
    withdrawMinSizenumber
    isWithdrawEnabledboolean
    precisionnumber
    chainstring
  }>
>

async applyWithdrawal

(
  paramsKucoinSDK.Http.Params<{
    currency: string
    addressstring
    amountnumber
    memo?: string
    isInner?: boolean
    remark?: string
    chain?: string
  }>
)Promise<
  KucoinSDK.Http.Data<{
    withdrawalIdstring
  }>
>

async cancelWithdrawal

(params: KucoinSDK.Http.Params<{ withdrawalId: string }>) => Promise<KucoinSDK.Http.Data<{}>>

async placeANewOrder

  • Docs

    • https://docs.kucoin.com/#place-a-new-order
    • You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified. See the Holds details below.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    clientOId: string
    side'buy' | 'sell'
    symbolstring
    type?: 'limit' | 'market'
    remark?: string
    stop?: 'loss' | 'entry'
    stopPrice?: string
    stp?: 'CN' | 'CO' | 'CB' | 'DC'
    tradeType?: 'TRADE' | 'MARGIN_TRADE'
    price?: string
    size?: string
    timeInForce?: string
    cancelAfter?: string
    postOnly?: boolean
    hidden?: boolean
    iceberg?: boolean
    visibleSize?: string
    funds?: string
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    orderIdstring
  }>
>

async cancelAnOrder

  • Docs

    • https://docs.kucoin.com/#cancel-an-order
    • Request via this endpoint to cancel a single order previously placed. You will receive cancelledOrderIds field once the system has received the cancellation request. The cancellation request will be processed by the matching engine in sequence. To know if the request is processed (successfully or not), you may check the order status or the update message from the pushes.
  • Types

(params: KucoinSDK.Http.Params<{ orderId: string }>): Promise<
  KucoinSDK.Http.Data<{
    cancelledOrderIds: string[]
  }>
>

async cancelAllOrders

(params: KucoinSDK.Http.Params<{ symbol?: string; tradeType?: 'TRADE' | 'MARGIN_TRADE' | string }>) => Promise<
  KucoinSDK.Http.Data<{
    cancelledOrderIdsstring[]
  }>
>

async listOrders

  • Docs

    • https://docs.kucoin.com/#list-orders
    • Request via this endpoint to get your current order list. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    status?: 'active' | 'done'
    symbol?: string 
    side?: 'buy' | 'sell'
    type?: 'limit' | 'market' | 'limit_stop' | 'market_stop'
    tradeType: 'TRADE' | 'MARGIN_TRADE'
    startAt?: string
    endAt?: string
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      idstring
      symbolstring
      opTypestring
      typestring
      sidestring
      pricenumber
      sizenumber
      fundsnumber
      dealFundsnumber
      dealSizenumber
      feenumber
      feeCurrencystring
      stpstring
      stopstring
      stopTriggeredboolean
      stopPricenumber
      timeInForcestring
      postOnlyboolean
      hiddenboolean
      icebergboolean
      visibleSizenumber
      cancelAfternumber
      channelstring
      clientOidstring
      remarkstring
      tagsstring
      isActiveboolean
      cancelExistboolean
      createdAtnumber
      tradeTypestring
    }[]
  }>
>

async getHistoricalOrdersList

  • Docs

    • https://docs.kucoin.com/#get-v1-historical-orders-list
    • Request via this endpoint to get your historical orders list of the KuCoin V1. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    currentPage?: number 
    pageSize?: number 
    symbol?: string 
    side?: 'buy' | 'sell'
    startAt?: string 
    endAt?: string 
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      symbolstring
      dealPricenumber
      dealValuenumber
      amountnumber
      feenumber
      sidestring
      createdAtnumber
    }[]
  }>
>

async recentOrders

  • Docs

    • https://docs.kucoin.com/#recent-orders
    • Request via this endpoint to get 1000 orders in the last 24 hours. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
  • Types

() => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      idstring
      symbolstring
      opTypestring
      typestring
      sidestring
      pricenumber
      sizenumber
      fundsnumber
      dealFundsnumber
      dealSizenumber
      feenumber
      feeCurrencystring
      stpstring
      stopstring
      stopTriggeredboolean
      stopPricenumber
      timeInForcestring
      postOnlyboolean
      hiddenboolean
      icebergboolean
      visibleSizenumber
      cancelAfternumber
      channelstring
      clientOidstring
      remarkstring
      tagsstring
      isActiveboolean
      cancelExistboolean
      createdAtnumber
      tradeTypestring
    }[]
  }>
>

async getAnOrder

(
  paramsKucoinSDK.Http.Params<{ orderId: string }>
) => Promise<
  KucoinSDK.Http.Data<{
    idstring
    symbolstring
    opTypestring
    typestring
    sidestring
    pricenumber
    sizenumber
    fundsnumber
    dealFundsnumber
    dealSizenumber
    feenumber
    feeCurrencystring
    stpstring
    stopstring
    stopTriggeredboolean
    stopPricenumber
    timeInForcestring
    postOnlyboolean
    hiddenboolean
    icebergboolean
    visibleSizenumber
    cancelAfternumber
    channelstring
    clientOidstring
    remarkstring
    tagsstring
    isActiveboolean
    cancelExistboolean
    createdAtnumber
    tradeTypestring
  }>
>

async listFills

  • Docs

    • https://docs.kucoin.com/#list-fills
    • Request via this endpoint to get the recent fills. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page.
  • Types

(
  paramsKucoinSDK.Http.Params<{
    orderId?: string 
    symbol?: string 
    side?: 'buy' | 'sell'
    type?: 'limit' | 'market' | 'limit_stop' | 'market_stop'
    startAt?: string 
    endAt?: string 
    tradeType: 'TRADE' | 'MARGIN_TRADE'
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    pageSizenumber
    totalNumnumber
    totalPagenumber
    items{
      symbolstring
      tradeIdstring
      orderIdstring
      counterOrderIdstring
      sidestring
      liquiditystring
      forceTakerboolean
      pricenumber
      sizenumber
      fundsnumber
      feenumber
      feeRatenumber
      feeCurrencystring
      stopstring
      typestring
      createdAtnumber
      tradeTypestring
    }[]
  }>
>

async recentFills

() => Promise<
  KucoinSDK.Http.Data<{
    codenumber
    data{
      counterOrderIdstring
      createdAtnumber
      feenumber
      feeCurrencystring
      feeRatenumber
      forceTakerboolean
      fundsnumber
      liquiditystring
      orderIdstring
      pricenumber
      sidestring
      sizenumber
      stopstring
      symbolstring
      tradeIdstring
      tradeTypestring
      typestring
    }[]
  }>
>

async getMarkPrice

(params: KucoinSDK.Http.Params<{ symbol: string }>) => Promise<
  KucoinSDK.Http.Data<{
    symbolstring
    granularitynumber
    timePointnumber
    valuenumber
  }>
>

async getMarginConfigurationInfo

() => Promise<
  KucoinSDK.Http.Data<{
    currencyListstring[]
    warningDebtRationumber
    liqDebtRationumber
    maxLeveragenumber
  }>
>

async getMarginAccount

() => Promise<
  KucoinSDK.Http.Data<{
    accounts{
      availableBalancenumber
      currencystring
      holdBalancenumber
      liabilitynumber
      maxBorrowSizenumber
      totalBalancenumber
    }[]
    debtRationumber
  }>
>

async postBorrowOrder

(
  paramsKucoinSDK.Http.Params<{
    currency: string
    typestring
    sizenumber
    maxRatenumber
    termstring
  }>
) => Promise<
  KucoinSDK.Http.Data<{
    orderIdstring
    currencystring
  }>
>

async getBorrowOrder

(params: KucoinSDK.Http.Params<{ orderId: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currencystring
    fillednumber
    matchList{
      currencystring
      dailyIntRatenumber
      sizenumber
      termnumber
      timestampnumber
      tradeIdnumber
    }[]
    orderIdstring
    sizenumber
    statusstring
  }>
>

async getRepayRecord

(params: KucoinSDK.Http.Params<{ currency?: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    items{
      accruedInterestnumber
      createdAtnumber
      currencystring
      dailyIntRatenumber
      liabilitynumber
      maturityTimenumber
      principalnumber
      repaidSizenumber
      termnumber
      tradeIdnumber
    }[]
    pageSizenumber
    totalNumnumber
    totalPagenumber
  }>
>

async getRepaymentRecord

(params: KucoinSDK.Http.Params<{ currency?: string }>) => Promise<
  KucoinSDK.Http.Data<{
    currentPagenumber
    items{
      currencystring
      dailyIntRatenumber
      interestnumber
      principalnumber
      repaidSizenumber
      repayTimenumber
      termnumber
      tradeIdnumber
    }[]
    pageSizenumber
    totalNumnumber
    totalPagenumber
  }>
>

async oneClickRepayment

(
  paramsKucoinSDK.Http.Params<{
    currency: string
    sequence'RECENTLY_EXPIRE_FIRST' | 'HIGHEST_RATE_FIRST'
    sizenumber
  }>
) => Promise<KucoinSDK.Http.Data<{}>>

async repayASingleOrder

(
  paramsKucoinSDK.Http.Params<{ currency: stringtradeIdstringsizenumber }>
) => Promise<KucoinSDK.Http.Data<{}>>

async marginTradeData

  • Docs

    • https://docs.kucoin.com/#margin-trade-data
    • Request via this endpoint to get the last 300 fills in the lending and borrowing market. The returned value is sorted based on the descending sequence of the order execution time.
  • Types

(params: KucoinSDK.Http.Params<{ currency: string }>) => Promise<
  KucoinSDK.Http.Data<
    {
      tradeIdstring
      currencystring
      sizenumber
      dailyIntRatenumber
      termnumber
      timestampnumber
    }[]
  >
>

async serverTime

() => Promise<
  KucoinSDK.Http.Data<{
    codenumber
    msgstring
    datanumber
  }>
>

History

  • 1.0.0 Initial Commit
  • 1.1.0 Added untested routes for Deposits, Withdrawals, Margin Trading, Account Info, Orders, and Fills
  • 2.0.0 Integrate Typescript
  • 2.0.0 Integrate Docstrings for IDE comment hinting
  • 2.0.0 Added Param Checker for all endpoints, emits console.warning if unused and throw e if missing required.
  • 2.0.0 Added Axios callbacks for interceptors on request and response
  • 2.0.0 Added non-breaking PASSPHRASE?: string and isTest?: boolean as paramters for KucoinInstance

Credits

  • Company: ©2019 The Launch
  • Author: Daniel Griffiths
  • Role: Founder and Engineer
  • Project: ©2020 CryptoDock

License

MIT Licence ©2020 Daniel Griffiths

Install

npm i kucoin-sdk

DownloadsWeekly Downloads

8

Version

2.0.1

License

MIT

Unpacked Size

152 kB

Total Files

11

Last publish

Collaborators

  • avatar