Huobi

CryptoExchangeAPIs.Huobi.HuobiClientType
HuobiClient <: 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.Huobi.HuobiAPIErrorType
HuobiAPIError{T} <: AbstractAPIsError

Exception thrown when an API method fails with code T.

Required fields

  • err_code::String: Error code.
  • err_msg::String: Error message.

Optional fields

  • ts::NanoDate: he UTC timestamp when API respond.
  • status::String: Status of API response.
  • code::Int64: Response code.
source
CryptoExchangeAPIs.Huobi.DataType
Data{D} <: AbstractAPIsData

Required fields

  • data::D: The body data in response.

Optional fields

  • status::Status: Status of API response.
  • ch::String: The data stream. It may be empty as some API doesn't have data stream.
  • ts::NanoDate: The UTC timestamp when API respond, the unit is millisecond.
  • code::Int64: Response code.
source
CryptoExchangeAPIs.Huobi.DataTickType
DataTick{D} <: AbstractAPIsData

Required fields

  • tick::D: The body tick in response.
  • status::Status: Status of API response.
  • ch::String: The data stream. It may be empty as some API doesn't have data stream.
  • ts::NanoDate: The UTC timestamp when API respond.
source

Spot

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

This endpoint retrieves all klines in a specific range.

GET market/history/kline

Parameters:

ParameterTypeRequiredDescription
periodTimeIntervaltrue
symbolStringtrue
sizeInt64falseDefault: 150

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

result = Huobi.Spot.candle(;
    symbol = "btcusdt",
    period = CryptoExchangeAPIs.Huobi.Spot.Candle.m1,
)

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "ch":"market.btcusdt.kline.1min",
  "ts":"2024-05-16T12:50:25.071000064",
  "code":null,
  "data":[
    {
      "amount":0.298096,
      "close":66300.0,
      "count":34,
      "high":66318.86,
      "id":"2024-05-16T12:50:00",
      "low":66268.18,
      "open":66268.18,
      "vol":19766.85497792
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Huobi.Spot.Currency.currencyFunction
currency(client::HuobiClient, query::CurrencyQuery)
currency(client::HuobiClient; kw...)

API user could query static reference information for each currency, as well as its corresponding chain(s).

GET v2/reference/currencies

Parameters:

ParameterTypeRequiredDescription
AccessKeyIdStringfalse
SignatureStringfalse
SignatureMethodStringfalse
SignatureVersionStringfalse
TimestampDateTimefalse
authorizedUserBoolfalse
currencyStringfalse

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

huobi_client = CryptoExchangeAPIs.Huobi.HuobiClient(;
    base_url = "https://api.huobi.pro",
    public_key = ENV["HUOBI_PUBLIC_KEY"],
    secret_key = ENV["HUOBI_SECRET_KEY"],
)

result = Huobi.Spot.currency(
    huobi_client;
    currency = "usdt",
    authorizedUser = true,
)

to_pretty_json(result.result)

Result:

{
  "code":200
  "data":[
    {
      "chains":[
        {
          "chain":"trc20usdt",
          "displayName":"",
          "baseChain":"TRX",
          "baseChainProtocol":"TRC20",
          "isDynamic":false,
          "depositStatus":"allowed",
          "maxTransactFeeWithdraw":1.0,
          "maxWithdrawAmt":280000.0,
          "minDepositAmt":100.0,
          "minTransactFeeWithdraw":0.1,
          "minWithdrawAmt":0.01,
          "numOfConfirmations":999.0,
          "numOfFastConfirmations":999.0,
          "withdrawFeeType":"circulated",
          "withdrawPrecision":5.0,
          "withdrawQuotaPerDay":280000.0,
          "withdrawQuotaPerYear":2800000.0,
          "withdrawQuotaTotal":2800000.0,
          "withdrawStatus":"allowed",
        },
        ...
      ]
      "currency":"usdt"
      "instStatus":"normal"
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Huobi.Spot.DepositWithdrawal.deposit_withdrawalFunction
deposit_withdrawal(client::HuobiClient, query::DepositWithdrawalQuery)
deposit_withdrawal(client::HuobiClient; kw...)

Parent user and sub user search for all existed withdraws and deposits and return their latest status.

GET v1/query/deposit-withdraw

Parameters:

ParameterTypeRequiredDescription
typeStringtrue
AccessKeyIdStringfalse
SignatureStringfalse
SignatureMethodStringfalse
SignatureVersionStringfalse
TimestampDateTimefalse
currencyStringfalse
directDirectQueryfalseprev next
fromStringfalse
sizeInt64false

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

huobi_client = CryptoExchangeAPIs.Huobi.HuobiClient(;
    base_url = "https://api.huobi.pro",
    public_key = ENV["HUOBI_PUBLIC_KEY"],
    secret_key = ENV["HUOBI_SECRET_KEY"],
)

result = Huobi.Spot.deposit_withdrawal(
    huobi_client;
    currency = "usdt",
    from = "1",
    size = 500,
    type = "withdraw",
)

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "data":[
    {
      "id":45182894,
      "type":"withdraw",
      "sub-type":"FAST",
      "currency":"usdt",
      "chain":"trc20usdt",
      "tx-hash":"",
      "amount":400,
      "from-addr-tag":"",
      "address":"TRwkUYHWgUh23jbKpgTcYHgE9CcBzhGno9",
      "address-tag":"",
      "fee":0,
      "state":"confirmed",
      "created-at":"2021-02-02T10:22:10",
      "updated-at":"2021-02-02T10:23:09"
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Huobi.Spot.OrderBook.order_bookFunction
order_book(client::HuobiClient, query::OrderBookQuery)
order_book(client::HuobiClient = Huobi.Spot.public_client; kw...)

This endpoint retrieves the current order book of a specific pair.

GET market/depth

Parameters:

ParameterTypeRequiredDescription
symbolStringtrue
depthInt64false
typeStepTypefalseDefault: step0, Available: step1, step2, step3, step4, step5

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

result = Huobi.Spot.order_book(;
    symbol = "btcusdt",
)

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "ch":"market.btcusdt.depth.step0",
  "ts":"2024-05-16T12:57:01.596999936",
  "tick":{
    "asks":[
      {
        "price":66089.57,
        "size":0.256781
      },
      ...
    ],
    "bids":[
      {
        "price":66089.56,
        "size":0.170774
      },
      ...
    ],
    "ts":"2024-05-16T12:57:01.400999936",
    "version":170820034651
  }
}
source
CryptoExchangeAPIs.Huobi.Spot.OrderLog.order_logFunction
order_log(client::HuobiClient, query::OrderLogQuery)
order_log(client::HuobiClient; kw...)

This endpoint returns orders based on a specific searching criteria. The orders created via API will no longer be queryable after being cancelled for more than 2 hours.

GET v1/order/history

Parameters:

ParameterTypeRequiredDescription
AccessKeyIdStringfalse
SignatureStringfalse
SignatureMethodStringfalse
SignatureVersionStringfalse
TimestampDateTimefalse
directDirectQueryfalseprev next
end_timeDateTimefalse
sizeInt64false
start_timeDateTimefalse
symbolStringfalse
sizeInt64false

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

huobi_client = CryptoExchangeAPIs.Huobi.HuobiClient(;
    base_url = "https://api.huobi.pro",
    public_key = ENV["HUOBI_PUBLIC_KEY"],
    secret_key = ENV["HUOBI_SECRET_KEY"],
)

result = Huobi.Spot.order_log(
    huobi_client;
    start_time = now(UTC) - Day(1),
    end_time = now(UTC) - Hour(1),
    size = 1000,
)

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "data":[
    {
      "id":345487249132375,
      "symbol":"polyusdt",
      "account-id":13496526,
      "client-order-id":"",
      "amount":50.0,
      "price":0.0,
      "created-at":"2021-02-02T10:22:10",
      "type":"buy-market",
      "field-amount":147.92899,
      "field-cash-amount":49.99999,
      "field-fees":0.29585,
      "finished-at":1629443051838,
      "source":"spot-web",
      "state":"filled",
      "canceled-at":0
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Huobi.Spot.SymbolInfo.symbols_infoFunction
symbols_info(client::HuobiClient, query::SymbolInfoQuery)
symbols_info(client::HuobiClient = Huobi.Spot.public_client; kw...)

Get all Supported Trading Symbol.

GET v1/settings/common/symbols

ParameterTypeRequiredDescription
tsInt64false

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

result = Huobi.Spot.symbols_info()

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "ch":null,
  "ts":"2024-09-26T13:42:55.368999936",
  "code":null,
  "data":[
    {
      "symbol":"letusdt",
      "bcdn":"LET",
      "qcdn":"USDT",
      "bc":"let",
      "qc":"usdt",
      "state":"offline",
      "cd":false,
      "te":false,
      "toa":"2018-01-01T04:00:00",
      "sp":"st",
      "w":950000000,
      "ttp":8.0,
      "tap":4.0,
      "tpp":6.0,
      "fp":8.0,
      "tags":"",
      "d":null,
      "elr":null
    },
    ...
  ]
}
source
CryptoExchangeAPIs.Huobi.Spot.Ticker.tickerFunction
ticker(client::HuobiClient, query::TickerQuery)
ticker(client::HuobiClient = Huobi.Spot.public_client; kw...)

This endpoint retrieves the latest tickers for all supported pairs.

GET market/tickers

Code samples:

using Serde
using CryptoExchangeAPIs.Huobi

result = Huobi.Spot.ticker()

to_pretty_json(result.result)

Result:

{
  "status":"ok",
  "ch":null,
  "ts":"2024-05-16T12:50:57.844",
  "code":null,
  "data":[
    {
      "symbol":"sylousdt",
      "amount":5.379805390589e8,
      "ask":0.001716,
      "askSize":90895.4464,
      "bid":0.001697,
      "bidSize":53912.9097,
      "close":0.001706,
      "count":12134,
      "high":0.001773,
      "low":0.001683,
      "open":0.001716,
      "vol":924950.6866947605
    },
    ...
  ]
}
source