更新日志
生效时间(UTC +8) | 接口 | 变化 | 摘要 |
---|---|---|---|
2018.6.10 | - | 初始化 | 初始化当前版本接口 |
Release Time(UTC +8) | API | Initialize / Update | Description |
---|---|---|---|
2018.6.10 | - | Initialize | Initializes the current version of the interface |
Welcome to Hotcoin API!
This is the official Hotcoin API document, and will be continue updating. Hotcoin will also publish API announcement in advance for any API change. Please subscribe to our announcements so that you can get the latest updates.
Below is the content for Spot API document:
Before you use API, you need to login the website to create API Key with proper permissions. The API key is shared for all instruments in Huobi including spot, futures, swap, options.
The permissions are described as follows:
AccessKey is the access key to API,SecretKey is the secret key of user signature for requests. Important note: These two keys are closely related to account security, and should not be disclosed to others at any time
Demo
Java | Python3 | Php |
Based on the consideration of security, all API request must be calculated by signature algorithm except market API. A legel request consists of below parts:
Request-URI Method, i.e. the address access to server: hkapi.hotcoin.top followed by method name, take hkapi.hotcoin.top/v1/order/place for instance.
API AccessKeyId is the The AccessKey in the APIKEY you requested.
Signature Method is the hash-based protocol of calculating signatures by users, HmacSHA256 is applied here.
SignatureVersion is the version of the signature protocol, 2 is applied here.
Timestamp is the time you made the request (UTC Time Zone). Including the value in query request helps preventing third parties from interception of your request.For example:2017-05-11T16:22:06.123Z.Again,(UTC Time Zone) is stressed here.For required parameters and optional parameters ,these parameters and their meanings can be viewed in the description of each method.
Signature the value calculated by signature is used for ensuring that the signature is valid and not tampered.
https://api.hotcoinfin.com/v1/order/place?
AccessKeyId=AccessKeyHotcoin123456789
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&Signature=calculated value
API request can be tempered at great risk while it is sent through the Internet. To ensure that the request is not tempered, we will require users to sign in every request (except market API) for verifying the authticity of parameters or the values of parameters.
Sign Steps:
Standards for Requests of Calculating Signatures:
Establish a standard for requests of calculating signatures because when using HMAC to calculate signature, total different results will be achieved as different contents are calculated. So before calculating signatures, please make a standard. Examples of the request of order placement will be given as follows.
https://api.hotcoinfin.com/v1/order/place?
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
The request Method (GET or POST, WebSocket use GET), append line break “\n”
GET\n
The host with lower case, append line break \n.
api.hotcoinfin.com\n.
The path, append line break “\n”
/v1/order/place\n
Sorting parameters by order of ASCII code (Encoding by UTF-8 format and URI format,hexadecimal characters must be capitalized,for example‘:’ will be encoded as ‘%3A’,space key will be encoded as ‘%20’).
For example,here is the original order of the request parameters after encoded.
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
Above parameter should be ordered like below:
AccessKeyId=AccessKeyHotcoin123456789
SignatureMethod=HmacSHA256
SignatureVersion=2
Timestamp=2017-05-11T16%3A22%3A06.123Z&
symbol=btc_gavc
tradeAmount=0.01
tradePrice=40000
type=buy
Use char “&” to concatenate all parameters.
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
The final strings for signature calculation is as follows:
GET\n
api.hotcoinfin.com\n
/v1/order/place\n
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
Calculation of signature algorithm,transfer the following two parameters to the cryptographic hash function:
Strings for signature calculation
GET\n
api.hotcoinfin.com\n
/v1/order/place\n
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
SecretKey for execute signature
SecretKeyHotcoin123456789
Obtained result of signature calculation and encoded with Base64
2oEC+yhkHTsNkgPUq4ZB/5mlY7EZAtUDWOQ5EO01D+I=
Add the above values as the value of parameter Signature to the API request. The value must be encoded with URI when this parameter is added to the request.
symbol rules:base currency + quote currency.In BTC/USDT,symbol is btc_usdt;While in ETH/BTC, symbol is eth_btc, and so on.
Finally, the API request sent to the server should be:
https://api.hotcoinfin.com/v1/order/place
?AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000&type=buy
&Signature=2oEC%2ByhkHTsNkgPUq4ZB%2F5mlY7EZAtUDWOQ5EO01D%2BI%3D
https://hkapi.hotcoin.top/v1/common/symbols
curl "https://hkapi.hotcoin.top/v1/common/symbols"
Request parameters:
Response data:
Parameter | Mandatory | Data Type | Description | Default | Value Range |
---|---|---|---|---|---|
code | y | int | Status code | success:200 | |
msg | y | string | message | ||
time | y | long | Current millisseconds | ||
data | y | array | symbols list |
data:
{
"code":"200",
"time":1567045034,
"data":[
{
"baseCurrency":"etc",
"quoteCurrency":"usdt",
"pricePrecision":6,
"amountPrecision":4,
"symbolPartition":"main",
"symbol":"etc_usdt",
"state":"online",
"minOrderCount":0.001,
"maxOrderCount":10000,
"minOrderPrice":0.0001,
"maxOrderPrice":10000
},
{
"baseCurrency":"ltc",
"quoteCurrency":"usdt",
"pricePrecision":6,
"amountPrecision":4,
"symbolPartition":"innovation",
"symbol":"ltc_usdt",
"state":"online",
"minOrderCount":0.001,
"maxOrderCount":10000,
"minOrderPrice":0.0001,
"maxOrderPrice":10000
}
]
}
Field Type | Data Type | description |
---|---|---|
baseCurrency | string | baseCurrency code |
quoteCurrency | string | quoteCurrency code |
pricePrecision | integer | price precision |
amountPrecision | integer | quantity precision |
symbolPartition | string | symbol Partition, example:[main,innovation] |
symbol | string | trade pair code |
state | string | trade pair status [enable,disable] |
minOrderCount | decimal | min order count |
maxOrderCount | decimal | max order count |
minOrderPrice | decimal | min order price |
maxOrderPrice | decimal | max order price |
https://hkapi.hotcoin.top/v1/balance?AccessKeyId=""
curl "https://hkapi.hotcoin.top/v1/balance?AccessKeyId=''"
Request parameters:
Parameter | Mandatory | Data Type | Description | Default | Value Range |
---|---|---|---|---|---|
AccessKeyId | y | string | Access key |
Response data:
{
"code": 200,
"msg": "success",
"time": 1527835756743,
"data": {
"netassets": 0,
"wallet": [
{
"uid":1100011,
"coinId":1,
"symbol":"BTC",
"total":1000.0000000000,
"frozen":1000.0000000000,
"coinName":"BTC",
"shortName":"BTC"
},
{
"uid":1100011,
"coinId":2,
"symbol":"LTC",
"total":1000.0000000000,
"frozen":1000.0000000000,
"coinName":"LTC",
"shortName":"LTC"
},
{
"uid":1100011,
"coinId":4,
"symbol":"ETH",
"total":1000.0000000000,
"frozen":0E-10,
"coinName":"ETH",
"shortName":"ETH"
}
],
"totalassets": 0
}
}
Parameter | Mandatory | Data Type | Description | Default | Value Range |
---|---|---|---|---|---|
code | y | int | Status code | ||
msg | n | string | Return message | ||
time | y | long | Current millisseconds | ||
data | y | object | Transaction deep data |
data:
Parameter | Mandatory | Data Type | Description | Default | Value Range |
---|---|---|---|---|---|
netassets | y | number | net assets,unit: gavc | ||
totalassets | y | number | total assets,unit:gavc | ||
wallet | y | array(object) | wallet list |
wallet:
Parameter | Mandatory | Data Type | Description | Default | Value Range |
---|---|---|---|---|---|
coinName | y | long | Currency | ||
uid | y | int | User ID | ||
coinId | y | int | Currency ID | ||
total | y | number | Available | ||
frozen | y | number | On orders | ||
symbol | y | string | Currency symbol | ||
shortName | y | string | Abbreviation |
生效时间(UTC +8) | 接口 | 变化 | 摘要 |
---|---|---|---|
2018.6.10 | - | 初始化 | 初始化当前版本接口 |
欢迎使用热币 API!
此文档是热币API的唯一官方文档,热币API提供的功能和服务会在此文档持续更新,并会发布公告进行通知,建议您关注和订阅我们的公告,及时获取相关信息。
以下是现货API文档各章节主要内容:
如需使用API ,请先登录网页端,完成API key的申请和权限配置,再据此文档详情进行开发和交易。
权限说明如下:
AccessKey为API 访问密钥,SecretKey为用户对请求进行签名的密钥。 重要提示:这两个密钥与账号安全紧密相关,无论何时都请勿向其它人透露
示例
Java | Python3 | Php |
基于安全考虑,除行情API 外的 API 请求都必须进行签名运算。一个合法的请求由以下几部分组成:
方法请求地址,即访问服务器地址:api.hotcoinfin.com后面跟上方法名,比如api.hotcoinfin.com/v1/order/place。
API 访问密钥(AccessKeyId) 您申请的 APIKEY 中的AccessKey。
签名方法(SignatureMethod) 用户计算签名的基于哈希的协议,此处使用 HmacSHA256。
签名版本(SignatureVersion) 签名协议的版本,此处使用2。
时间戳(Timestamp) 您发出请求的时间 (UTC 时区)。在查询请求中包含此值有助于防止第三方截取您的请求。如:2017-05-11T16:22:06.123Z。再次强调是 (UTC 时区) 调用的必需参数和可选参数。可以在每个方法的说明中查看这些参数及其含义。
签名计算得出的值,用于确保签名有效和未被篡改。
https://api.hotcoinfin.com/v1/order/place?
AccessKeyId=AccessKeyHotcoin123456789
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&Signature=calculated value
API 请求在通过 Internet 发送的过程中极有可能被篡改。为了确保请求未被更改,我们会要求用户在每个请求中带上签名,来校验参数或参数值在传输途中是否发生了更改。
计算签名所需的步骤: 规范要计算签名的请求 因为使用 HMAC 进行签名计算时,使用不同内容计算得到的结果会完全不同。所以在进行签名计算前,请先对请求进行规范化处理。下面以下单请求为例进行说明
https://api.hotcoinfin.com/v1/order/place?
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
请求方法(GET 或 POST),后面添加换行符\n。
GET\n
添加小写的访问地址,后面添加换行符\n。
api.hotcoinfin.com\n
访问方法的路径,后面添加换行符\n。
/v1/order/place\n
按照ASCII码的顺序对参数名进行排序(使用 UTF-8 编码,且进行了 URI 编码,十六进制字符必须大写,如‘:’会被编码为’%3A’,空格被编码为’%20’)。
例如,下面是请求参数的原始顺序,进行过编码后。
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16:22:06.123Z
&symbol=btc_gavc
&type=buy
&tradePrice=40000
&tradeAmount=0.1
这些参数会被排序为:
AccessKeyId=AccessKeyHotcoin123456789
SignatureMethod=HmacSHA256
SignatureVersion=2
Timestamp=2017-05-11T16%3A22%3A06.123Z&
symbol=btc_gavc
tradeAmount=0.01
tradePrice=40000
type=buy
按照以上顺序,将各参数使用字符’&’连接。
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
组成最终的要进行签名计算的字符串如下:
GET\n
api.hotcoinfin.com\n
/v1/order/place\n
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
计算签名,将以下两个参数传入加密哈希函数:
要进行签名计算的字符串
GET\n
api.hotcoinfin.com\n
/v1/order/place\n
AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000
&type=buy
进行签名的密钥(SecretKey)
SecretKeyHotcoin123456789
得到签名计算结果并进行 Base64编码
2oEC+yhkHTsNkgPUq4ZB/5mlY7EZAtUDWOQ5EO01D+I=
将上述值作为参数Signature的取值添加到 API 请求中。 将此参数添加到请求时,必须将该值进行 URI 编码。
symbol 规则: 基础币种+计价币种。如BTC/USDT,symbol为btc_usdt;ETH/BTC, symbol为eth_btc。以此类推。
最终,发送到服务器的 API 请求应该为:
https://api.hotcoinfin.com/v1/order/place
?AccessKeyId=AccessKeyHotcoin123456789
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2017-05-11T16%3A22%3A06.123Z
&symbol=btc_gavc
&tradeAmount=0.1
&tradePrice=40000&type=buy
&Signature=2oEC%2ByhkHTsNkgPUq4ZB%2F5mlY7EZAtUDWOQ5EO01D%2BI%3D
https://hkapi.hotcoin.top/v1/common/symbols
curl "https://hkapi.hotcoin.top/v1/common/symbols"
请求参数:
响应数据:
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
code | y | int | 状态码 | 成功:200 | |
msg | y | string | 消息 | ||
time | y | long | 当前毫秒数 | ||
data | y | array | symbols列表 |
data:
{
"code": "200",
"time": 1567045034,
"data": [
{"baseCurrency":"etc",
"quoteCurrency":"usdt",
"pricePrecision":6,
"amountPrecision":4,
"symbolPartition":"main",
"symbol":"etc_usdt",
"state":"online",
"minOrderCount":0.001,
"maxOrderCount":10000,
"minOrderPrice":0.0001,
"maxOrderPrice":10000
},
{
"baseCurrency":"ltc",
"quoteCurrency":"usdt",
"pricePrecision":6,
"amountPrecision":4,
"symbolPartition":"innovation",
"symbol":"ltc_usdt",
"state":"online",
"minOrderCount":0.001,
"maxOrderCount":10000,
"minOrderPrice":0.0001,
"maxOrderPrice":10000
}
]
}
字段类型 | 数据类型 | 描述 | description(英文) |
---|---|---|---|
baseCurrency | string | 交易中的基础币种 | baseCurrency code |
quoteCurrency | string | 交易中的报价币种 | quoteCurrency code |
pricePrecision | integer | 交易对报价的精度(小数点后位数) | price precision |
amountPrecision | integer | 交易对基础币种计数精度(小数点) | quantity precision |
symbolPartition | string | 交易区,可能值: [main,innovation] | symbol Partition, example:[main,innovation] |
symbol | string | 交易对 | trade pair code |
state | string | 交易对状态 enable - 正常;disable-禁用 | trade pair status [enable,disable] |
minOrderCount | decimal | 交易对最小下单量 (下单量指当订单类型为限价单时,下单接口传的’tradeAmount’) | min order count |
maxOrderCount | decimal | 交易对最大下单量 (下单量指当订单类型为限价单时,下单接口传的’tradeAmount’) | max order count |
minOrderPrice | decimal | 最小下单价格(下单金额指当订单类型为限价单时,下单接口传入的‘price’) | min order price |
maxOrderPrice | decimal | 最大下单价格(下单金额指当订单类型为限价单时,下单接口传入的‘price’) | max order price |
https://hkapi.hotcoin.top/v1/balance?AccessKeyId=""
curl "https://hkapi.hotcoin.top/v1/balance?AccessKeyId=''"
请求参数:
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
AccessKeyId | y | string | 访问key |
响应数据:
{
"code": 200,
"msg": "成功",
"time": 1527835756743,
"data": {
"netassets": 0,
"wallet": [
{
"uid":1100011,
"coinId":1,
"symbol":"BTC",
"total":1000.0000000000,
"frozen":1000.0000000000,
"coinName":"比特币",
"shortName":"BTC"
},
{
"uid":1100011,
"coinId":2,
"symbol":"LTC",
"total":1000.0000000000,
"frozen":1000.0000000000,
"coinName":"莱特币",
"shortName":"LTC"
},
{
"uid":1100011,
"coinId":4,
"symbol":"ETH",
"total":1000.0000000000,
"frozen":0E-10,
"coinName":"以太坊",
"shortName":"ETH"
}
],
"totalassets": 0
}
}
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
code | y | int | 状态码 | ||
msg | n | string | 返回消息 | ||
time | y | long | 当前毫秒数 | ||
data | y | object | 交易深度数据 |
data:
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
netassets | y | number | 净资产,单位为gavc | ||
totalassets | y | number | 总资产,单位为gavc | ||
wallet | y | array(object) | 钱包列表 |
wallet:
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coinName | y | long | 币种名称 | ||
uid | y | int | 用户ID | ||
coinId | y | int | 币种ID | ||
total | y | number | 可用 | ||
frozen | y | number | 冻结 | ||
symbol | y | string | 币种symbol | ||
shortName | y | string | 币种简称 |
生效时间(UTC +8) | 接口 | 变化 | 摘要 |
---|---|---|---|
2018.6.10 | - | 初始化 | 初始化当前版本接口 |