Huobi
CryptoExchangeAPIs.Huobi.HuobiClient
— TypeHuobiClient <: 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.
CryptoExchangeAPIs.Huobi.HuobiAPIError
— TypeHuobiAPIError{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.
CryptoExchangeAPIs.Huobi.Data
— TypeData{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.
CryptoExchangeAPIs.Huobi.DataTick
— TypeDataTick{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.
Spot
CryptoExchangeAPIs.Huobi.Spot.public_client
— Constantpublic_client = HuobiClient(; base_url = "https://api.huobi.pro")
CryptoExchangeAPIs.Huobi.Spot.Candle.candle
— Functioncandle(client::HuobiClient, query::CandleQuery)
candle(client::HuobiClient = Huobi.Spot.public_client; kw...)
This endpoint retrieves all klines in a specific range.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
period | TimeInterval | true | |
symbol | String | true | |
size | Int64 | false | Default: 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
},
...
]
}
CryptoExchangeAPIs.Huobi.Spot.Currency.currency
— Functioncurrency(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).
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
AccessKeyId | String | false | |
Signature | String | false | |
SignatureMethod | String | false | |
SignatureVersion | String | false | |
Timestamp | DateTime | false | |
authorizedUser | Bool | false | |
currency | String | false |
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"
},
...
]
}
CryptoExchangeAPIs.Huobi.Spot.DepositWithdrawal.deposit_withdrawal
— Functiondeposit_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.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
type | String | true | |
AccessKeyId | String | false | |
Signature | String | false | |
SignatureMethod | String | false | |
SignatureVersion | String | false | |
Timestamp | DateTime | false | |
currency | String | false | |
direct | DirectQuery | false | prev next |
from | String | false | |
size | Int64 | false |
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"
},
...
]
}
CryptoExchangeAPIs.Huobi.Spot.OrderBook.order_book
— Functionorder_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.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
symbol | String | true | |
depth | Int64 | false | |
type | StepType | false | Default: 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
}
}
CryptoExchangeAPIs.Huobi.Spot.OrderLog.order_log
— Functionorder_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.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
AccessKeyId | String | false | |
Signature | String | false | |
SignatureMethod | String | false | |
SignatureVersion | String | false | |
Timestamp | DateTime | false | |
direct | DirectQuery | false | prev next |
end_time | DateTime | false | |
size | Int64 | false | |
start_time | DateTime | false | |
symbol | String | false | |
size | Int64 | false |
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
},
...
]
}
CryptoExchangeAPIs.Huobi.Spot.SymbolInfo.symbols_info
— Functionsymbols_info(client::HuobiClient, query::SymbolInfoQuery)
symbols_info(client::HuobiClient = Huobi.Spot.public_client; kw...)
Get all Supported Trading Symbol.
GET v1/settings/common/symbols
Parameter | Type | Required | Description |
---|---|---|---|
ts | Int64 | false |
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
},
...
]
}
CryptoExchangeAPIs.Huobi.Spot.Ticker.ticker
— Functionticker(client::HuobiClient, query::TickerQuery)
ticker(client::HuobiClient = Huobi.Spot.public_client; kw...)
This endpoint retrieves the latest tickers for all supported pairs.
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
},
...
]
}