Kucoin

CryptoExchangeAPIs.Kucoin.KucoinClientType
KucoinClient <: AbstractAPIsClient

Client info.

Required fields

  • base_url::String: Base URL for the client.

Optional fields

  • public_key::String: Public key for authentication.
  • secret_key::String: Secret key for authentication.
  • interface::String: Interface for the client.
  • proxy::String: Proxy information for the client.
  • account_name::String: Account name associated with the client.
  • description::String: Description of the client.
source
CryptoExchangeAPIs.Kucoin.PageType
Page{D} <: AbstractAPIsData

Required fields

  • pageSize::Int64: Number of results per request.
  • totalNum::Int64: Total number of results.
  • currentPage::Int64: Current request page.
  • totalPage::Int64: Total request page.
  • items::Vector{D}: Result data.
source

Spot

CryptoExchangeAPIs.Kucoin.Spot.Candle.candleFunction
candle(client::KucoinClient, query::CandleQuery)
candle(client::KucoinClient = Kucoin.Spot.public_client; kw...)

Request via this endpoint to get the kline of the specified symbol.

GET api/v1/market/candles

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue
typeTimeIntervaltruem1 m3 m5 m15 m30 h1 h2 h4 h6 h8 h12 d1 w1
endAtDateTimefalse
startAtDateTimefalse

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Spot.candle(;
    symbol = "BTC-USDT",
    type = Kucoin.Spot.Candle.m1,
)

to_pretty_json(result.result)

Result:

{
  "code":200000,
  "data":[
    {
      "time":"2024-05-14T10:37:00",
      "open":61665.9,
      "close":61676.4,
      "high":61676.4,
      "low":61660.3,
      "volume":0.61931855,
      "turnover":38189.806617378
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Kucoin.Spot.Deposit.depositFunction
deposit(client::KucoinClient, query::DepositQuery)
deposit(client::KucoinClient; kw...)

Request via this endpoint to get the V1 historical deposits list on KuCoin.

GET api/v1/hist-deposits

Parameters:

ParameterTypeRequiredDescription
currencyStringfalse
endAtDateTimefalse
startAtDateTimefalse
statusStatusfalsePROCESSING, SUCCESS, FAILURE
passphraseStringfalse
signatureStringfalse
timestampDateTimefalse

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

kucoin_client = KucoinClient(;
    base_url = "https://api.kucoin.com",
    public_key = ENV["KUCOIN_PUBLIC_KEY"],
    secret_key = ENV["KUCOIN_SECRET_KEY"],
    passphrase = ENV["KUCOIN_PASSPHRASE"],
)

result = Kucoin.Spot.deposit(
    kucoin_client;
    currency = "BTC",
)

to_pretty_json(result.result)

Result:

{
  "pageSize":1,
  "totalNum":9,
  "currentPage":1,
  "totalPage":9,
  "items":[
    {
      "amount":0.03266638,
      "createAt":"1970-01-18T16:35:36.998",
      "currency":"BTC",
      "isInner":false,
      "status":"SUCCESS",
      "walletTxId":"55c643bc2c68d6f17266383ac1be9e454038864b929ae7cee0bc408cc5c869e8"
    }
  ]
}
source
CryptoExchangeAPIs.Kucoin.Spot.SymbolInfo.symbol_infoFunction
symbol_info(client::KucoinClient, query::SymbolInfoQuery)
symbol_info(client::KucoinClient = Kucoin.Spot.public_client; kw...)

Request via this endpoint to get detail currency pairs for trading.

GET /api/v2/symbols/{symbol}

ParameterTypeRequiredDescription
symbolStringtrue

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Spot.symbol_info(; 
    symbol = "BTC-USDT"
)

to_pretty_json(result.result)

Result:

{
  "symbol":"BTC-USDT",
  "baseCurrency":"BTC",
  "quoteCurrency":"USDT",
  "feeCurrency":"USDT",
  "market":"USDS",
  "baseMaxSize":1.0e10,
  "baseIncrement":1.0e-8,
  "quoteMinSize":0.1,
  "quoteIncrement":1.0e-6,
  "priceIncrement":0.1,
  "priceLimitRate":0.1,
  "minFunds":0.1,
  "isMarginEnabled":true,
  "enableTrading":true,
  "baseMinSize":1.0e-5,
  "name":"BTC-USDT",
  "quoteMaxSize":9.9999999e7
}
source
CryptoExchangeAPIs.Kucoin.Spot.SymbolInfo.symbols_infoFunction
symbols_info(client::KucoinClient, query::SymbolsInfoQuery)
symbols_info(client::KucoinClient = Kucoin.Spot.public_client; kw...)

Request via this endpoint to get detail currency pairs for trading.

GET /api/v2/symbols/{symbol}

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Spot.symbols_info()

to_pretty_json(result.result)

Result:

[
  {
    "symbol":"AVA-USDT",
    "baseCurrency":"AVA",
    "quoteCurrency":"USDT",
    "feeCurrency":"USDT",
    "market":"USDS",
    "baseMaxSize":1.0e10,
    "baseIncrement":0.01,
    "quoteMinSize":0.1,
    "quoteIncrement":0.0001,
    "priceIncrement":0.0001,
    "priceLimitRate":0.1,
    "minFunds":0.1,
    "isMarginEnabled":false,
    "enableTrading":true,
    "baseMinSize":0.1,
    "name":"AVA-USDT",
    "quoteMaxSize":9.9999999e7
  },
  ...
]
source
CryptoExchangeAPIs.Kucoin.Spot.Ticker.tickerFunction
ticker(client::KucoinClient, query::TickerQuery)
ticker(client::KucoinClient = Kucoin.Spot.public_client; kw...)

Request via this endpoint to get the statistics of the specified ticker in the last 24 hours.

GET api/v1/market/stats

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Spot.ticker(; symbol = "BTC")

to_pretty_json(result.result)

Result:

{
  "code":200000,
  "data":{
    "symbol":"BTC",
    "averagePrice":null,
    "buy":null,
    "changePrice":null,
    "changeRate":null,
    "high":null,
    "last":null,
    "low":null,
    "makerCoefficient":null,
    "makerFeeRate":null,
    "sell":null,
    "takerCoefficient":null,
    "takerFeeRate":null,
    "time":"2024-09-23T15:48:26.456999936",
    "vol":null,
    "volValue":null
  }
}
source
CryptoExchangeAPIs.Kucoin.Spot.Ticker.ticker_allFunction
ticker_all(client::KucoinClient, query::TickerQuery)
ticker_all(client::KucoinClient = Kucoin.Spot.public_client; kw...)

Request market tickers for all the trading pairs in the market (including 24h volume).

GET api/v1/market/allTickers

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Spot.ticker_all()

to_pretty_json(result.result)

Result:

{
"code":200000,
  "data":{
    "time":"2024-09-23T15:54:48.020999936",
    "ticker":[
      {
        "symbol":"HLG-USDT",
        "averagePrice":0.0015635,
        "buy":0.00156,
        "changePrice":3.0e-5,
        "changeRate":0.0194,
        "high":0.00161,
        "last":0.00157,
        "low":0.00152,
        "makerCoefficient":2.0,
        "makerFeeRate":0.001,
        "sell":0.00158,
        "takerCoefficient":2.0,
        "takerFeeRate":0.001,
        "time":null,
        "vol":1.6744577e6,
        "volValue":2626.113078
      },
      ...
      ]
    }
}
source

Futures

CryptoExchangeAPIs.Kucoin.Futures.Candle.candleFunction
candle(client::KucoinClient, query::CandleQuery)
candle(client::KucoinClient = Kucoin.Futures.public_client; kw...)

Request via this endpoint to get the kline of the specified symbol.

GET api/v1/kline/query

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue
granularityTimeIntervaltruem1 m5 m15 m30 h1 h2 h4 h8 h12 d1 w1
fromNanoDatefalse
toNanoDatefalse

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Futures.candle(;
    symbol = ".KXBT",
    granularity = Kucoin.Futures.Candle.m1,
)

to_pretty_json(result.result)

Result:

{
  "code":200000,
  "data":[
    {
      "time":"2024-05-14T20:37:00",
      "open":61593.03,
      "close":61593.82,
      "high":61593.02,
      "low":61593.82,
      "volume":0.0
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Kucoin.Futures.Contract.contractFunction
contract(client::KucoinClient, query::ContractQuery)
contract(client::KucoinClient = Kucoin.Futures.public_client; kw...)

Submit request to get the info of all open contracts.

GET api/v1/contracts/active

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Futures.contract()

to_pretty_json(result.result)

Result:

{
  "code":200000,
  "data":[
    {
      "symbol":"XEMUSDTM",
      "rootSymbol":"USDT",
      "type":"FFWCSX",
      "firstOpenDate":"2021-04-09T08:00:00",
      "expireDate":null,
      "settleDate":null,
      "baseCurrency":"XEM",
      "quoteCurrency":"USDT",
      "settleCurrency":"USDT",
      "maxOrderQty":1000000,
      "maxPrice":1.0e6,
      "lotSize":1,
      "tickSize":1.0e-5,
      "indexPriceTickSize":1.0e-5,
      "multiplier":1.0,
      "initialMargin":0.034,
      "maintainMargin":0.017,
      "maxRiskLimit":10000,
      "minRiskLimit":10000,
      "riskStep":5000,
      "makerFeeRate":0.0002,
      "takerFeeRate":0.0006,
      "takerFixFee":0.0,
      "makerFixFee":0.0,
      "settlementFee":null,
      "isDeleverage":true,
      "isQuanto":false,
      "isInverse":false,
      "markMethod":"FairPrice",
      "fairMethod":"FundingRate",
      "fundingBaseSymbol":".XEMINT8H",
      "fundingQuoteSymbol":".USDTINT8H",
      "fundingRateSymbol":".XEMUSDTMFPI8H",
      "indexSymbol":".KXEMUSDT",
      "settlementSymbol":"",
      "status":"Open",
      "fundingFeeRate":7.2e-5,
      "predictedFundingFeeRate":-1.5e-5,
      "openInterest":"14240708",
      "turnoverOf24h":39512.89870461,
      "volumeOf24h":1.114053e6,
      "markPrice":0.03541,
      "indexPrice":0.03541,
      "lastTradePrice":0.03535,
      "nextFundingRateTime":12755619,
      "maxLeverage":30,
      "sourceExchanges":[
        "binance",
        "okex",
        "kucoin",
        "bitget",
        "gateio"
      ],
      "premiumsSymbol1M":".XEMUSDTMPI",
      "premiumsSymbol8H":".XEMUSDTMPI8H",
      "fundingBaseSymbol1M":".XEMINT",
      "fundingQuoteSymbol1M":".USDTINT",
      "lowPrice":0.03469,
      "highPrice":0.03585,
      "priceChgPct":-0.0106,
      "priceChg":-0.00038
    },
   ...
  ]
}
source
CryptoExchangeAPIs.Kucoin.Futures.PrivateFundingHistory.private_funding_historyFunction
private_funding_history(client::KucoinClient, query::PrivateFundingHistoryQuery)
private_funding_history(client::KucoinClient; kw...)

Submit request to get the funding history.

GET api/v1/funding-history

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue
startAtNanoDatefalse
endAtNanoDatefalse
reverseBoolfalse
offsetInt64false
forwardBoolfalse
maxCountInt64false
passphraseStringfalse
signatureStringfalse
timestampDateTimefalse

Code samples:

using Serde
using CryptoExchangeAPIs.Kucoin

kucoin_client = KucoinClient(;
    base_url = "https://api-futures.kucoin.com",
    public_key = ENV["KUCOIN_PUBLIC_KEY"],
    secret_key = ENV["KUCOIN_SECRET_KEY"],
    passphrase = ENV["KUCOIN_PASSPHRASE"],
)

result = Kucoin.Futures.private_funding_history(
    kucoin_client;
    symbol = "XBTUSDM",
)

to_pretty_json(result.result)

Result:

{
  "dataList":[
    {
      "id":36275152660006,
      "symbol":"XBTUSDM",
      "timePoint":"2019-05-15T11:00:00",
      "fundingRate":13e-5,
      "markPrice":8058.27,
      "positionQty":10,
      "positionCost":-0.001241,
      "funding":-464e-6,
      "settleCurrency":"XBT"
    },
    ...
  ],
  "hasMore":true
}
source
CryptoExchangeAPIs.Kucoin.Futures.PublicFundingHistory.public_funding_historyFunction
public_funding_history(client::KucoinClient, query::PublicFundingHistoryQuery)
public_funding_history(client::KucoinClient = Kucoin.Futures.public_client; kw...)

Query the funding rate at each settlement time point within a certain time range of the corresponding contract.

GET api/v1/contract/funding-rates

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue
fromNanoDatefalse
toNanoDatefalse

Code samples:

using Serde
using NanoDates
using CryptoExchangeAPIs.Kucoin

result = Kucoin.Futures.public_funding_history(; 
    symbol = "IDUSDTM",
    from = NanoDate("2023-11-18T12:31:40"),
    to = NanoDate("2023-12-11T16:05:00"),
)

to_pretty_json(result.result)

Result:

{
  "code":200000,
  "data":[
    {
      "symbol":"IDUSDTM",
      "timepoint":"2023-12-11T12:00:00",
      "fundingRate":0.000226
    },
   ...
  ]
}
source