├── README.md ├── readme_en.md ├── rest_api.md ├── rest_api_en.md ├── update_log.md ├── update_log_en.md ├── websocket_api.md └── websocket_api_en.md /README.md: -------------------------------------------------------------------------------- 1 | # hotbit.io-api-docs 2 | Official Documentation for the hotbit.io APIs. https://www.hotbit.io/ 3 | 4 | # 入门指引 5 | 6 | ## API概述     7 | 8 | HOTBIT为用户提供了一整套简单而又强大的开发工具,旨在帮助用户快速、高效地将HOTBIT交易功能整合到自己的应用当中。     9 | 10 | HOTBIT接口是提供服务的基础,开发者在HOTBIT网站创建账号后,可以根据自身需求建立不同权限的API,并利用API进行自动交易或者提现。   11 | 12 | 通过API可以快速实现以下功能: 13 | - 获取市场最新行情 14 | - 获取买卖深度信息 15 | - 查询可用和冻结金额 16 | - 查询自己当前尚未成交的挂单 17 | - 快速买进卖出 18 | - 批量撤单 19 | - 快速提现到您的认证地址 20 | 21 | 获取接口权限后,可以通过阅读本接口文档来帮助开发。 22 | 23 | ## 接口调用方式说明 24 | 25 | HOTBIT为用户提供了两种调用接口的方式,开发者可根据自己的使用场景和偏好选择适合自己的方式来查询行情、进行交易或提现。 26 | 27 | #### REST API 28 | 29 | REST,即Representational State Transfer的缩写,是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、扩展方便,正得到越来越多网站的采用。其优点如下: 30 | - 在RESTful架构中,每一个URL代表一种资源; 31 | - 客户端和服务器之间,传递这种资源的某种表现层; 32 | - 客户端通过四个HTTP指令,对服务器端资源进行操作,实现“表现层状态转化”。 33 | 34 | 建议开发者使用REST API进行币币交易或者资产提现等操作。 35 | 36 | #### WebSocket API     37 | 38 | WebSocket是HTML5一种新的协议(Protocol)。它实现了客户端与服务器全双工通信,使得数据可以快速地双向传播。通过一次简单的握手就可以建立客户端和服务器连接,服务器根据业务规则可以主动推送信息给客户端。其优点如下: 39 | - 客户端和服务器进行数据传输时,请求头信息比较小,大概2个字节; 40 | - 客户端和服务器皆可以主动地发送数据给对方; 41 | - 不需要多次创建TCP请求和销毁,节约宽带和服务器的资源。 42 | 43 | **_注意:websocket 反馈数据采取zlib压缩算法进行压缩。_** 44 | 45 | 强烈建议开发者使用WebSocket API获取市场行情和买卖深度等信息。 46 | 47 | ## 开启API权限     48 | 49 | 用户的API权限在网站的账户管理->API管理内获取。点击申请API即可获得,其中apiKey是HOTBIT提供给API用户的访问密钥,secretKey用于对请求参数签名的私钥。 50 | 51 | **_注意: 请勿向任何人泄露这两个参数,这两个参数关乎您账号的安全。_** 52 | 53 | ## 参数签名     54 | 55 | 用户提交的参数除sign外,都要参与签名。 56 | 57 | 首先,**将待签名字符串要求按照参数名进行排序(首先比较所有参数名的第一个字母,按abcd顺序排列,若遇到相同首字母,则看第二个字母,以此类推)。** 58 | 59 | 例如:资产查询接口balance.query(参见HTTP接口说明)的请求参数 60 | 61 | | 参数名 | 参数类型 | 描述 | 示例 | 62 | | --- | --- | --- | --- | 63 | | api_key | string | 用户申请的API KEY | 6b97d781-5ffd-958f-576d96d0bbebc8c6 | 64 | | sign | string | 请求字符串的签名值 | C88F04701D3349D0A93A0164DC5A4CD9 | 65 | | assets | json array | 代币符号数组,空数组表示获取全部代币资产 | ["BTC","ETH"]| 66 | 67 | 上述请求生成签名的过程如下 68 | 69 | - 生成待签名的字符串 70 | 71 | ``` 72 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"] 73 | ``` 74 | 75 | - 将待签名字符串添加私钥参数生成最终待签名字符串。例如: 76 | 77 | ``` 78 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&secret_key=de8063ea6e99bc967ba6395d06fabf50 79 | ``` 80 | 81 | - 计算MD5值 82 | 83 | ``` 84 | MD5("api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&secret_key=de8063ea6e99bc967ba6395d06fabf50") 85 | ``` 86 | 87 | 算出的MD5值是:c88f04701d3349d0a93a0164dc5a4cd9 88 | 89 | - 将MD5值转为大写 90 | 91 | ``` 92 | to_upper(c88f04701d3349d0a93a0164dc5a4cd9) 93 | ``` 94 | 95 | 得到最终的签名值是:C88F04701D3349D0A93A0164DC5A4CD9 96 | 97 | 上述过程完成后,balance.query发送的请求参数是: 98 | 99 | ``` 100 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&sign=C88F04701D3349D0A93A0164DC5A4CD9 101 | ``` 102 | 103 | 说明:上述API Key和Secret Key仅为示例,在使用的时候替换为用户自己申请的API Key。     104 | -------------------------------------------------------------------------------- /readme_en.md: -------------------------------------------------------------------------------- 1 | # hotbit.io-api-docs 2 | Official Documentation for the hotbit.io APIs. https://www.hotbit.io/ 3 | 4 | # Instructions 5 | 6 | ## API Guidelines     7 | 8 | Hotbit provides all users with a complete set of simple yet powerful development tools, which aims to support all users to rapidly and efficiently intergrate all trading functions of Hotbit into their own Apps. 9 | 10 | Hotbit interface plays the role as the foundation regarding the provision of all services. After creating their own accounts on Hotbit website, developers may establish API with different permission levels based on their own needs, and then conduct automatic transactions or withdrawals by using their API. 11 | 12 | 13 | The following functions can be rapidly deployed by the use of API: 14 | - Obtain latest market trends 15 | Obtain relevant information regarding the depth of buy and sell transactions. 16 | - Check the volume of available and frozen assets 17 | - Check all currently unsettled order(s) that the user placed 18 | Buy and sell rapidly 19 | - Cancel orders in large quantities 20 | - Rapidly withdraw assets from Hotbit to your verified address(es) 21 | 22 | After obtaining interface permission(s), users may start their own development processes by reading and following the instructions of this document. 23 | 24 | ## Instructions Regarding the Methods of Interface Call 25 | 26 | Hotbit provides its users with two methods of interface call, between which developers may select the appropriate method that suits themselves to check market trends, conduct transactions or withdrawals based on their own application scenarios or preferences. 27 | 28 | #### REST API 29 | 30 | REST,which is the abbreviation of "Representational State Transfer",is currently one of the most popular types of Internet software frameworks. REST is currently being adopted by an increasing number of websites due to its clear structure, compliance with standards, simpleness and outstanding scalability. The advantages of REST are listed as follows: 31 | - Each URL represents one type of resource in the framework of RESTful; 32 | - A certain type of presentation layer of the resource is delivered between the client end and the server; 33 | - The client end conduct operations on the resources of server end through four HTTP instructions for the "transformation on the status of presentation layer". 34 | 35 | The developers are recommended to use REST API for operations such as the transactions between different types of cryptocurrency tokens or asset withdrawals. 36 | 37 | #### WebSocket API     38 | 39 | WebSocket is a new type of HTML5 protocol. WebSocket enables the full-duplex communication between client end and server end, which allows data to be transferred rapidly through two-way communications. By adopting WebSocket, the connection between the client end and the server end can be established through a simple handshake, and that the server may actively push information to the client end based on relevant business rules and regulations. The advantages of WebSocket are listed as below: 40 | - During the data transfers between the client end and server end, the size of the information in the request header is comparatively small, which is approximately 2 bytes only; 41 | - Both the client end and the server end may actively send data to each other. 42 | - No need to establish multiple TCP requests and destroys, which saves the resources of broadband connections and servers. 43 | 44 | **_Attention:The feedback data of websocket is compressed by the compression algorithm of zlib._** 45 | 46 | The developers are strongly recommended to obtain relevant information such as market trends and the depth of buy and sell transactions by adopting WebSocket API 47 | 48 | ## Enable API Permission 49 | 50 | Users may obtain their API permissions by visiting "Account Management->API Management" section of our website. By clicking "Apply For API", our users will obtain their API permissions. The apiKey is the encrypted access key that Hotbit provides for all API users, and the secretKey functions as the private key that allows users to sign the requested parameters. 51 | 52 | **_Attention: Please do not disclose these two parameters to anyone, as these two parameters determines the security of your account(s)._** 53 | 54 | ## Parameter Signature   55 | 56 | Apart from "sign", all data that users submitted must participate in the signature. 57 | 58 | First,**sort the strings that require to be signed according to the parameter names(first compare the first letter of all parameter names and sort them based on alphabetical order; in case that the first letter of more than one parameters is the same, sort these parameters based on the second letter of their names according to alphabetical order, and so on).** 59 | 60 | For example: the requested parameter of asset inquiry interface balance.query(please refer to the instructions of HTTP interface) 61 | 62 | | Parameter Name | Type of Parameter | Description | Examples | 63 | | --- | --- | --- | --- | 64 | | api_key | string | The API KEY applied by the user | 6b97d781-5ffd-958f-576d96d0bbebc8c6 | 65 | | sign | string | The signature value of the requested string | C88F04701D3349D0A93A0164DC5A4CD9 | 66 | | assets | json array | The array of token abbreviation, blank array means obtain all token assets | ["BTC","ETH"]| 67 | 68 | The process of the abovementioned requests on signature generation is listed as below 69 | 70 | - Generate strings to be signed 71 | 72 | ``` 73 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"] 74 | ``` 75 | 76 | - Add parameter of private key to the strings to be signed and generate final strings to be signed. For example: 77 | 78 | ``` 79 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&secret_key=de8063ea6e99bc967ba6395d06fabf50 80 | ``` 81 | 82 | - Calculate MD5 value 83 | 84 | ``` 85 | MD5("api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&secret_key=de8063ea6e99bc967ba6395d06fabf50") 86 | ``` 87 | 88 | The calculated MD5 value is:c88f04701d3349d0a93a0164dc5a4cd9 89 | 90 | - Change MD5 value into capital letters 91 | 92 | ``` 93 | to_upper(c88f04701d3349d0a93a0164dc5a4cd9) 94 | ``` 95 | 96 | The final signature value generated is:C88F04701D3349D0A93A0164DC5A4CD9 97 | 98 | After finishing above processes,the requested parameter sent by balance.query is: 99 | 100 | ``` 101 | api_key=6b97d781-5ffd-958f-576d96d0bbebc8c6&assets=["BTC","ETH"]&sign=C88F04701D3349D0A93A0164DC5A4CD9 102 | ``` 103 | 104 | Description: The API Key and Secret Key mentioned above are examples only, during the actual adoption, users are required to substitute all API Key and Secret Key mentioned in the example with their own API Key. 105 | -------------------------------------------------------------------------------- /rest_api.md: -------------------------------------------------------------------------------- 1 | # REST API     2 | 3 | ## 开始使用     4 | 5 | REST,即Representational State Transfer的缩写,是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、扩展方便,正得到越来越多网站的采用。其优点如下: 6 | - 在RESTful架构中,每一个URL代表一种资源; 7 | - 客户端和服务器之间,传递这种资源的某种表现层; 8 | - 客户端通过四个HTTP指令,对服务器端资源进行操作,实现“表现层状态转化”。 9 | 10 | 建议开发者使用REST API进行币币交易或者资产提现等操作。 11 | 12 | ## 请求交互     13 | 14 | REST访问的根URL:   15 | 16 | 所有请求基于Https协议,请求头信息中contentType需要统一设置为:application/x-www-form-urlencoded 17 | 18 | 请求交互说明 19 | 20 | 1. 请求参数:根据接口请求参数规定进行参数封装。 21 | 2. 提交请求参数:将封装好的请求参数通过GET或者POST方式提交至服务器。 22 | 3. 服务器响应:服务器首先对用户请求数据进行参数安全校验,通过校验后根据业务逻辑将响应数据以JSON格式返回给用户。 23 | 4. 数据处理:对服务器响应数据进行处理。 24 | 25 | ## 请求 26 | 27 | |参数名|描述| 28 | | ----- | ----- | 29 | |method|API方法名| 30 | |params|参数| 31 | 32 | 33 | ## 函数列表 34 | 35 | |函数名|描述|url| 36 | | :----- | :----- | :----- | 37 | |[server.time](#servertime)| 获取系统时间 |https://api.hotbit.io/api/v1/server.time| | 38 | |[balance.query](#balancequery)| 获取用户资产 |https://api.hotbit.io/api/v1/balance.query| api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&assets=["BTC","ETH"]| 39 | |[asset.list](#assetlist)|获取平台所有资产类型和精度,prec为精确到小数点后多少位|https://api.hotbit.io/api/v1/asset.list| | 40 | |[order.put_limit](#orderput_limit)|限价交易|https://api.hotbit.io/api/v1/order.put_limit|api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&side=1&amount=10&price=100&isfee=0 | 41 | |[order.cancel](#ordercancel)|取消交易|https://api.hotbit.io/api/v1/order.cancel| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=BTC/ETH&order_id=1| 42 | |[order.batch_cancel](#orderbatch_cancel)|批量取消交易|https://api.hotbit.io/api/v1/order.batch_cancel| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=BTC/ETH&orders_id=[1,2]| 43 | |[order.deals](#orderdeals)|获取已成交的订单细节|https://api.hotbit.io/api/v1/order.deals| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=100&limit=10&offset=0| 44 | |[order.finished_detail](#orderfinished_detail)|根据订单号查询已完成订单|https://api.hotbit.io/api/v1/order.finished_detail| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=1| 45 | |[order.book](#orderbook)|获取交易列表|https://api.hotbit.io/api/v1/order.book|market=ETH/BTC&side=1&offset=0&limit=10 | 46 | |[order.depth](#orderdepth)|获取交易深度|https://api.hotbit.io/api/v1/order.depth|market=ETH/BTC&limit=100&interval=1e-8 | 47 | |[order.pending](#orderpending)|查询未实施订单|https://api.hotbit.io/api/v1/order.pending| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&offset=0&limit=100| 48 | |[order.finished](#orderfinished)|查询用户的已完成订单|https://api.hotbit.io/api/v1/order.finished|api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&start_time=1511967657&end_time =1512050400&offset=0&limit=100&side=1 | 49 | |[market.list](#marketlist)|获取交易对列表|https://api.hotbit.io/api/v1/market.list| | 50 | |[market.last](#marketlast)|获取指定交易对的最新价格|https://api.hotbit.io/api/v1/market.last| market=ETH/BTC| 51 | |[market.deals](#marketdeals)|查询交易对交易记录|https://api.hotbit.io/api/v1/market.deals| market=ETH/BTC&limit=10&last_id=1521100930| 52 | |[market.user_deals](#marketuser_deals)|查询用户交易记录|https://api.hotbit.io/api/v1/market.user_deals| | 53 | |[market.kline](#marketkline)|k线查询|https://api.hotbit.io/api/v1/market.kline|market=ETH/BTC&start_time=1521100000&end_time=1521101193&interval=60 | 54 | |[market.status](#marketstatus)|获取过去指定时间段market当前最新涨跌幅,交易量,最高/最低价格等状态|https://api.hotbit.io/api/v1/market.status|market=ETH/BTC&period=10 | 55 | |[market.status_today](#marketstatus_today)|获取今天market状态|https://api.hotbit.io/api/v1/market.status_today|market=ETH/BTC | 56 | |[market.status24h](#marketstatus24h)|获取过去24小时内的market涨跌幅,交易量,最高/最低价格等状态|https://api.hotbit.io/api/v1/market.status24h|| 57 | |[market.summary](#marketsummary)|market概要|https://api.hotbit.io/api/v1/market.summary|| 58 | |[allticker](#allticker)|获取全市场交易对的最新成交信息|https://api.hotbit.io/api/v1/allticker|| 59 | 60 | ## 应答 61 | 应答位于"200 ok"的body部分,共有三个参数组成: 62 | 63 | |参数名|参数类型|描述| 64 | | :----- | :----- | :----- | 65 | |result|json object| API调用结果,结果出错时为null| 66 | |error|json object| API调用错误内容,正确时为null| 67 | |id|Integer|Request id| 68 | 69 | ``` 70 | 结果正确示例: 71 | { 72 | "error": null, 73 | "result": {.....}, 74 | "id": 123 75 | } 76 | 77 | 结果错误示例: 78 | { 79 | "error": { 80 | "code": 1, 81 | "message": "invalid argument" 82 | }, 83 | "result": null, 84 | "id": 123 85 | } 86 | ``` 87 | 88 | 89 | 90 | ## API参考 91 | 92 | **系统类API,获取系统资源** 93 | 94 | 95 | 96 | ### server.time 97 | 98 | | 方法名 | 方法类型 | 描述 | 99 | | --- | --- | --- | 100 | | server.time | get | 获取系统时间 | 101 | 102 | 请求参数:无 103 | 104 | 示例: 105 | 106 | | url | body | 107 | | --- | --- | 108 | | https://api.hotbit.io/api/v1/server.time | | 109 | 110 | 响应数据: 111 | 112 | 113 | | 参数名称 | 数据类型 | 是否必须 | 描述 | 114 | | --- | --- | --- | --- | 115 | | result | long | true | 获取系统时间 | 116 | 117 | 示例: 118 | 119 | ``` 120 | Response:{"error": null, "result": 1520919059} 121 | ``` 122 | 123 | 124 | 125 | ## Asset API 126 | 127 | **用户资产类API,实现针对各种类型用户资产的查询,更新,所有和用户资产相关操作历史记录获取等。** 128 | 129 | ### balance.query 130 | 131 | | 方法名 | 方法类型 | 描述 | 132 | | --- | --- | --- | 133 | | balance.query | post | 获取用户资产 | 134 | 135 | 请求参数: 136 | 137 | | 参数名 | 参数类型 | 描述 | 138 | | --- | --- | --- | 139 | | api_key | string | 用户申请的API KEY | 140 | | sign | string | 请求字符串的签名值 | 141 | | assets | json array | 代币符号数组,空数组表示获取全部代币资产 | 142 | 143 | 示例: 144 | 145 | | url | body | 146 | | --- | --- | 147 | | https://api.hotbit.io/api/v1/balance.query | api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&assets=["BTC","ETH"] | 148 | 149 | 150 | 151 | ### balance.history 152 | 153 | | 方法名 | 方法类型 | 描述 | 154 | | --- | --- | --- | 155 | | balance.history | post | 获取用户资金变动流水 | 156 | 157 | 请求参数: 158 | 159 | | 参数名 | 参数类型 | 描述 | 160 | | --- | --- | --- | 161 | | api_key | string | 用户API KEY | 162 | | sign | string | 用户签名值 | 163 | | asset | string | 资产名称,如:"BTC","ETH"等,""表示所有资产名称 | 164 | | business | string | 业务名称,如:"deposit"或"trade",""表示所有业务名称 | 165 | | start_time | Integer(无符号64位) | 开始时间(秒) | 166 | | end_time | Integer(无符号64位) | 截止时间(秒) | 167 | | offset | Integer(32位) | 偏移位置,如果设置为0,表示从最新近一笔业务开始算起,往之前时间的所有交易记录,总笔数不能大于limit;。如果设置为1,表示从次新一笔业务开始算起,往之前时间的所有交易记录总笔数不能大于limit;以此类推 | 168 | | limit | Integer(32位) | 返回的最大交易笔数 | 169 | 170 | 示例: 171 | 172 | | url | body | 173 | | --- | --- | 174 | | https://api.hotbit.io/api/v1/balance.history | api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&asset=BTC&business=deposit&start_time=1511967657&end_time =1512050400&offset=0&limit=100 | 175 | 176 | 177 | 178 | ### asset.list 179 | 180 | | 方法名 | 方法类型 | 描述 | 181 | | --- | --- | --- | 182 | | asset.list | get | 获取平台所有资产类型和精度,prec为精确到小数点后多少位 | 183 | 184 | 请求参数:无 185 | 186 | 示例: 187 | 188 | | url | body | 189 | | --- | --- | 190 | | https://api.hotbit.io/api/v1/asset.list | | 191 | 192 | 响应数据: 193 | 194 | 示例: 195 | 196 | 197 | ``` 198 | Response: 199 | { 200 | "error": null, 201 | "result": [ 202 | { 203 | "name": "BTC", 204 | "prec": 8 205 | }, 206 | { 207 | "name": "ETH", 208 | "prec": 8 209 | } 210 | ], 211 | "id": 1521164549 212 | } 213 | ``` 214 | 215 | 216 | 217 | ## Trade API 218 | 219 | **交易类API** 220 | 221 | ### order.put_limit 222 | 223 | | 方法名 | 方法类型 | 描述 | 224 | | --- | --- | --- | 225 | | order.put_limit | post | 限价交易 | 226 | 227 | 请求参数: 228 | 229 | | 参数名 | 参数类型 | 描述 | 230 | | --- | --- | --- | 231 | | api_key | string | 用户API KEY | 232 | | sign | string | 用户签名值 | 233 | | market | string | market名称,如:"BTC/USDT","ETH/USDT" | 234 | | side | Integer | 1 = "sell",2="buy" | 235 | | amount | double | 申请交易的数量 (**注意必须是最小量的倍数**)| 236 | | price | double | 交易价格 | 237 | | isfee | Integer | 是否使用折扣币抵扣 0 = "否(no)",1="是(yes)"| 238 | 239 | **同一交易对下面只能同时存在200个挂单** 240 | 241 | 示例: 242 | 243 | | url | body | 244 | | --- | --- | 245 | | https://api.hotbit.io/api/v1/order.put_limit | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&side=1&amount=10&price=100&isfee=0 | 246 | 响应数据: 247 | 248 | 示例: 249 | 250 | 251 | ``` 252 | Response: 253 | { 254 | "error": null, 255 | "result": 256 | { 257 | "id":8688803, #order-ID 258 | "market":"ETHBTC", 259 | "source":"web", #数据请求来源标识 260 | "type":1, #下单类型 1-限价单 261 | "side":2, #买卖方标识 1-卖方,2-买方 262 | "user":15731, 263 | "ctime":1526971722.164765, #订单创建时间(秒) 264 | "mtime":1526971722.164765, #订单更新时间(秒) 265 | "price":"0.080003", 266 | "amount":"0.4", 267 | "taker_fee":"0.0025", 268 | "maker_fee":"0", 269 | "left":"0.4", 270 | "deal_stock":"0", 271 | "deal_money":"0", 272 | "deal_fee":"0", 273 | "status":0 , #订单状态标志 当与0x8为真的时候表示当前订单是取消的,当与0x80为真的时候表示当前订单是使用抵扣折扣的 274 | "fee_stock":"HTB", #抵扣币名 275 | "alt_fee":"0.5", #抵扣币的折扣 276 | "deal_fee_alt":"0.123" #折扣抵扣的数量 277 | }, 278 | "id": 1521169460 279 | } 280 | ``` 281 | 282 | 283 | ### order.cancel 284 | 285 | | 方法名 | 方法类型 | 描述 | 286 | | --- | --- | --- | 287 | | order.cancel | post | 取消交易 | 288 | 289 | 请求参数: 290 | 291 | | 参数名 | 参数类型 | 描述 | 292 | | --- | --- | --- | 293 | | api_key | string | 用户API KEY | 294 | | sign | string | 用户签名值 | 295 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 296 | | order_id | Integer(无符号64位) | 要取消交易的id。参看"order.put_limit"方法的返回结果。| 297 | 298 | 示例: 299 | 300 | | url | body | 301 | | --- | --- | 302 | | https://api.hotbit.io/api/v1/order.cancel | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&order_id=1 | 303 | 304 | 响应数据: 305 | 306 | 示例: 307 | 308 | 309 | ``` 310 | Response: 311 | { 312 | "error": null, 313 | "result": 314 | { 315 | "id":8688803, #order-ID 316 | "market":"ETHBTC", 317 | "source":"web", #数据请求来源标识 318 | "type":1, #下单类型 1-限价单 319 | "side":2, #买卖方标识 1-卖方,2-买方 320 | "user":15731, 321 | "ctime":1526971722.164765, #订单创建时间(秒) 322 | "mtime":1526971722.164765, #订单更新时间(秒) 323 | "price":"0.080003", 324 | "amount":"0.4", 325 | "taker_fee":"0.0025", 326 | "maker_fee":"0", 327 | "left":"0.4", 328 | "deal_stock":"0", 329 | "deal_money":"0", 330 | "deal_fee":"0", 331 | "status":0 , #订单状态标志 当与0x8为真的时候表示当前订单是取消的,当与0x80为真的时候表示当前订单是使用抵扣折扣的 332 | "fee_stock":"HTB", #抵扣币名 333 | "alt_fee":"0.5", #抵扣币的折扣 334 | "deal_fee_alt":"0.123" #折扣抵扣的数量 335 | }, 336 | "id": 1521169460 337 | } 338 | ``` 339 | 340 | ### order.batch_cancel 341 | 342 | | 方法名 | 方法类型 | 描述 | 343 | | --- | --- | --- | 344 | | order.batch_cancel | post | 批量取消交易 | 345 | 346 | 请求参数: 347 | 348 | | 参数名 | 参数类型 | 描述 | 349 | | --- | --- | --- | 350 | | api_key | string | 用户API KEY | 351 | | sign | string | 用户签名值 | 352 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 353 | | orders_id | arrary | 要取消交易的id(无符号64位),数量最多10个订单取消,参看"order.put_limit"方法的返回结果。| 354 | 355 | 示例: 356 | 357 | | url | body | 358 | | --- | --- | 359 | | https://api.hotbit.io/api/v1/order.batch_cancel | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&orders_id=[1,2] | 360 | 361 | 响应数据: 362 | 363 | 示例: 364 | 365 | 366 | ``` 367 | Response: 368 | { 369 | "error": null, 370 | "result": 371 | [ 372 | {#正确反馈 373 | "id":8688803, #order-ID(无符号64位) 374 | "market":"ETHBTC", 375 | "source":"web", #数据请求来源标识 376 | "type":1, #下单类型 1-限价单 377 | "side":2, #买卖方标识 1-卖方,2-买方 378 | "user":15731, 379 | "ctime":1526971722.164765, #订单创建时间(秒) 380 | "mtime":1526971722.164765, #订单更新时间(秒) 381 | "price":"0.080003", 382 | "amount":"0.4", 383 | "taker_fee":"0.0025", 384 | "maker_fee":"0", 385 | "left":"0.4", 386 | "deal_stock":"0", 387 | "deal_money":"0", 388 | "deal_fee":"0", 389 | "status":0 , #订单状态标志 当与0x8为真的时候表示当前订单是取消的,当与0x80为真的时候表示当前订单是使用抵扣折扣的 390 | "fee_stock":"HTB", #抵扣币名 391 | "alt_fee":"0.5", #抵扣币的折扣 392 | "deal_fee_alt":"0.123" #折扣抵扣的数量 393 | }, 394 | { #发生错误反馈 395 | "error": { 396 | "code":10 397 | "message":"order not found" 398 | } 399 | "result":null, 400 | "id": 1521169460 401 | } 402 | ], 403 | "id": 1521169460 404 | } 405 | ``` 406 | 407 | ### order.deals 408 | 409 | | 方法名 | 方法类型 | 描述 | 410 | | --- | --- | --- | 411 | | order.deals | post | 获取已成交的订单细节 | 412 | 413 | 请求参数: 414 | 415 | | 参数名 | 参数类型 | 描述 | 416 | | --- | --- | --- | 417 | | api_key | string | 用户API KEY | 418 | | sign | string | 用户签名值 | 419 | | order_id | Integer(无符号64位) | 交易ID,参看 "order.put_limit"方法的返回结果| 420 | | offset | Integer(32位) | 等于0,表示从最近一次交易往之前查找 | 421 | | limit | Integer(32位) | 最多返回 "records"的数量 | 422 | 423 | 示例: 424 | 425 | | url | body | 426 | | --- | --- | 427 | | https://api.hotbit.io/api/v1/order.deals | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=100&limit=10&offset=0 | 428 | 429 | 响应数据: 430 | 431 | 示例: 432 | 433 | 434 | ``` 435 | Response: 436 | { 437 | "error": null, 438 | "result": { 439 | "offset": 10, 440 | "limit": 10, 441 | "records": [ 442 | { 443 | "time": 1521107411.116817, 444 | "user": 15643,(无符号32位) 445 | "id": 1385154,(无符号64位) 446 | "role": 1, 447 | "price": "0.02", 448 | "amount": "0.071", 449 | "deal": "0.00142", 450 | "fee": "0", 451 | "deal_order_id": 2337658 452 | }, 453 | { 454 | "time": 1521107410.357024,#(秒) 455 | "user": 15643,(无符号32位) 456 | "id": 1385151,(无符号64位) 457 | "role": 1, 458 | "price": "0.02", 459 | "amount": "0.081", 460 | "deal": "0.00162", 461 | "fee": "0", 462 | "deal_order_id": 2337653 463 | } 464 | ] 465 | }, 466 | "id": 1521169460 467 | } 468 | ``` 469 | 470 | 471 | ### order.finished_detail 472 | 473 | | 方法名 | 方法类型 | 描述 | 474 | | --- | --- | --- | 475 | | order.finished_detail | post | 根据订单号查询已完成订单 | 476 | 477 | 请求参数: 478 | 479 | | 参数名 | 参数类型 | 描述 | 480 | | --- | --- | --- | 481 | | api_key | string | 用户API KEY | 482 | | sign | string | 用户签名值 | 483 | | order_id | Integer(无符号64位) | 交易ID,参看 "order.put_limit"方法的返回结果| 484 | 485 | 486 | 示例: 487 | 488 | | url | body | 489 | | --- | --- | 490 | | https://api.hotbit.io/api/v1/order.finished_detail | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=1 | 491 | 492 | 响应数据: 493 | 494 | 示例: 495 | 496 | 497 | ``` 498 | Response: 499 | { 500 | "error": null, 501 | "result": { 502 | "id": 1,(无符号64位) 503 | "ctime": 1535545564.4409361,#(秒) 504 | "ftime": 1535545564.525017,#(秒) 505 | "user": 15731,(无符号32位) 506 | "market": "YCCETH", 507 | "source": "test", 508 | "type": 1, 509 | "side": 2, 510 | "price": "0.0000509", 511 | "amount": "1", 512 | "taker_fee": "0.001", 513 | "maker_fee": "0.001", 514 | "deal_stock": "1", 515 | "deal_money": "0.0000509", 516 | "deal_fee": "0.001", 517 | "status":0 , #订单状态标志 当与0x8为真的时候表示当前订单是取消的,当与0x80为真的时候表示当前订单是使用抵扣折扣的 518 | "fee_stock":"HTB", #抵扣币名 519 | "alt_fee":"0.5", #抵扣币的折扣 520 | "deal_fee_alt":"0.123" #折扣抵扣的数量 521 | }, 522 | "id": 1536050997 523 | } 524 | ``` 525 | 526 | 527 | ### order.book 528 | 529 | | 方法名 | 方法类型 | 描述 | 530 | | --- | --- | --- | 531 | | order.book | get | 获取交易列表 | 532 | 533 | 请求参数: 534 | 535 | | 参数名 | 参数类型 | 描述 | 536 | | --- | --- | --- | 537 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 538 | | side | Integer(无符号32位) | 1 = "sell",2="buy" | 539 | | offset | Integer(无符号32位) | 偏移位置,如果设置为0,表示从最新近一笔业务开始算起,往之前时间的所有交易记录,总笔数不能大于limit;。如果设置为1,表示从次新一笔业务开始算起,往之前时间的所有交易记录总笔数不能大于limit;以此类推..... | 540 | | limit | Integer(无符号32位) | 最多返回 "records"的数量 | 541 | 542 | 示例: 543 | 544 | | url | body | 545 | | --- | --- | 546 | | https://api.hotbit.io/api/v1/order.book?market=ETH/BTC&side=1&offset=0&limit=10 | | 547 | 548 | 响应数据: 549 | 550 | 示例: 551 | 552 | 553 | ``` 554 | Response: 555 | { 556 | "error": null, 557 | "result": { 558 | "offset": 0, 559 | "limit": 10, 560 | "total": 0, 561 | "orders": [] 562 | }, 563 | "id": 1521169117 564 | } 565 | ``` 566 | 567 | 568 | 569 | ### order.depth 570 | 571 | | 方法名 | 方法类型 | 描述 | 572 | | --- | --- | --- | 573 | | order.depth | get | 获取交易深度 | 574 | 575 | 请求参数: 576 | 577 | | 参数名 | 参数类型 | 描述 | 578 | | --- | --- | --- | 579 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 580 | | limit | Integer(无符号32位) | 最多返回 "records"的数量,可取值:1, 5, 10, 20, 30, 50, 100 | 581 | | interval | string | 价格精度,可取值:0,0.1,0.01,0.001,……,0.0000000001 | 582 | 583 | 示例: 584 | 585 | | url | body | 586 | | --- | --- | 587 | | https://api.hotbit.io/api/v1/order.depth?market=ETH/BTC&limit=100&interval=1e-8 | | 588 | 589 | 响应数据: 590 | 591 | 示例: 592 | 593 | 594 | ``` 595 | Response: 596 | { 597 | "error": null, 598 | "result": 599 | { 600 | "asks": [["0.0733858", "0.319"], ["0.0741178", "0.252"], ["0.0742609", "0.03"], ... ["0.1250465", "0.272"]], 601 | "bids": [["0.0730197", "0.275"], ["0.0723", "1.052"], ["0.0722876", "0.302"], ... ["2.0e-7", "1"]]}, 602 | "id": 1527559250 603 | } 604 | ``` 605 | 606 | 607 | 608 | ### order.pending 609 | 610 | | 方法名 | 方法类型 | 描述 | 611 | | --- | --- | --- | 612 | | order.pending | post | 查询未实施订单 | 613 | 614 | 请求参数: 615 | 616 | | 参数名 | 参数类型 | 描述 | 617 | | --- | --- | --- | 618 | | api_key | string | 用户API KEY | 619 | | sign | string | 用户签名值 | 620 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 621 | | offset | Integer(32位) | 偏移位置,如果设置为0,表示从最新近一笔业务开始算起,往之前时间的所有交易记录,总笔数不能大于limit;。如果设置为1,表示从次新一笔业务开始算起,往之前时间的所有交易记录总笔数不能大于limit;以此类推..... | 622 | | limit | Integer(32位) | 最多返回 "records"的数量 | 623 | 示例: 624 | 625 | | url | body | 626 | | --- | --- | 627 | | https://api.hotbit.io/api/v1/order.pending | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=fdcafaf85a38970e4d84f6f286a2879e&market=ETH/BTC&offset=0&limit=100 | 628 | 629 | 响应数据: 630 | 631 | 示例: 632 | 633 | ``` 634 | { 635 | "error":null, 636 | "result":{ 637 | "ETHBTC":{ 638 | "limit":50, 639 | "offset":0, 640 | "total":1, 641 | "records":[ 642 | { 643 | "id":8688803, #order-ID 644 | "market":"ETHBTC", 645 | "source":"web", #数据请求来源标识 646 | "type":1, #下单类型 1-限价单 647 | "side":2, #买卖方标识 1-卖方,2-买方 648 | "user":15731, 649 | "ctime":1526971722.164765, #订单创建时间 650 | "mtime":1526971722.164765, #订单更新时间 651 | "price":"0.080003", 652 | "amount":"0.4", 653 | "taker_fee":"0.0025", 654 | "maker_fee":"0", 655 | "left":"0.4", 656 | "deal_stock":"0", 657 | "deal_money":"0", 658 | "deal_fee":"0", 659 | "status":0 , #订单状态标志 当与0x8为真的时候表示当前订单是取消的,当与0x80为真的时候表示当前订单是使用抵扣折扣的 660 | "fee_stock":"HTB", #抵扣币名 661 | "alt_fee":"0.5", #抵扣币的折扣 662 | "deal_fee_alt":"0.123" #折扣抵扣的数量 663 | } 664 | ] 665 | } 666 | }, 667 | "id":1526971756 668 | } 669 | ``` 670 | 671 | 672 | ### order.finished 673 | 674 | | 方法名 | 方法类型 | 描述 | 675 | | --- | --- | --- | 676 | | order.finished | post | 查询用户的已完成订单 | 677 | 678 | 请求参数: 679 | 680 | | 参数名 | 参数类型 | 描述 | 681 | | --- | --- | --- | 682 | | api_key | string | 用户API KEY | 683 | | sign | string | 用户签名值 | 684 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 685 | | start_time | Integer(无符号64位) | 开始时间(秒) | 686 | | end_time | Integer(无符号64位) | 截止时间(秒) | 687 | | offset | Integer(32位) | 偏移位置,如果设置为0,表示从最新近一笔业务开始算起,往之前时间的所有交易记录,总笔数不能大于limit;。如果设置为1,表示从次新一笔业务开始算起,往之前时间的所有交易记录总笔数不能大于limit;以此类推 | 688 | | limit | Integer(32位) | 最多返回 "records"的数量 | 689 | | side | Integer(32位) | 1 = "sell",2="buy" | 690 | 691 | 示例: 692 | 693 | | url | body | 694 | | --- | --- | 695 | | https://api.hotbit.io/api/v1/order.finished | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&start_time=1511967657&end_time =1512050400&offset=0&limit=100&side=1 | 696 | 697 | 698 | 699 | ## Market API 700 | 701 | **市场类API** 702 | 703 | ### market.list 704 | 705 | | 方法名 | 方法类型 | 描述 | 706 | | --- | --- | --- | 707 | | market.list | get | 获取交易对列表 | 708 | 709 | 请求参数:无 710 | 711 | 示例: 712 | 713 | | url | body | 714 | | --- | --- | 715 | | https://api.hotbit.io/api/v1/market.list | | 716 | 717 | 响应数据: 718 | 719 | 示例: 720 | 721 | 722 | ``` 723 | Response: 724 | { 725 | "error": null, 726 | "result": [ 727 | { 728 | "name": "QASHBTC", 729 | "stock": "QASH", 730 | "money": "BTC", 731 | "fee_prec": 4, #税率精度4位小数 732 | "stock_prec": 2, #stock精度 733 | "money_prec": 8, #money精度 734 | "min_amount": "0.1" #下单最小值 735 | }, 736 | { 737 | "name": "QASHETH", 738 | "stock": "QASH", 739 | "money": "ETH", 740 | "fee_prec": 4, 741 | "stock_prec": 2, 742 | "money_prec": 8, 743 | "min_amount": "0.0001" 744 | } 745 | ], 746 | "id": 1521169333 747 | } 748 | ``` 749 | 750 | 751 | 752 | ### market.last 753 | | 方法名 | 方法类型 | 描述 | 754 | | --- | --- | --- | 755 | | market.last | get | 获取指定交易对的最新价格 | 756 | 757 | 请求参数: 758 | 759 | | 参数名 | 参数类型 | 描述 | 760 | | --- | --- | --- | 761 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 762 | 763 | 示例: 764 | 765 | | url | body | 766 | | --- | --- | 767 | | https://api.hotbit.io/api/v1/market.last?market=ETH/BTC | | 768 | 769 | 响应数据: 770 | 771 | 示例: 772 | 773 | 774 | ``` 775 | Response: 776 | { 777 | "error": null, 778 | "result": "0.07413600", 779 | "id": 1521169525 780 | } 781 | ``` 782 | 783 | 784 | 785 | ### market.deals 786 | 787 | | 方法名 | 方法类型 | 描述 | 788 | | --- | --- | --- | 789 | | market.deals | get | 查询交易对交易记录 | 790 | 791 | 请求参数: 792 | 793 | | 参数名 | 参数类型 | 描述 | 794 | | --- | --- | --- | 795 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 796 | | limit | Integer | 查询个数限制(limit <= 1000) | 797 | | last_id | Integer(无符号64位) | 返回大于order_id > last_id的交易数据 | 798 | 799 | 示例: 800 | 801 | | url | body | 802 | | --- | --- | 803 | | https://api.hotbit.io/api/v1/market.deals?market=ETH/BTC&limit=10&last_id=1521100930 | | 804 | 805 | 响应数据: 806 | 807 | 示例: 808 | 809 | 810 | ``` 811 | Response: 812 | { 813 | "error": null, 814 | "result": [], 815 | "id": 1521169562 816 | } 817 | ``` 818 | 819 | 820 | 821 | ### market.user_deals 822 | 823 | | 方法名 | 方法类型 | 描述 | 824 | | --- | --- | --- | 825 | | market.user_deals | post | 查询用户交易记录 | 826 | 827 | 请求参数: 828 | 829 | | 参数名 | 参数类型 | 描述 | 830 | | --- | --- | --- | 831 | | api_key | string | 用户API KEY | 832 | | sign | string | 用户签名值 | 833 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 834 | | offset | Integer(32位) |偏移位置,如果设置为0,表示从最新一个订单开始算起,往之前时间的所有交易记录,总笔数不能大于limit;如果设置为1,表示从次新一个订单开始算起,往之前时间的所有满足条件订单记录,总数不能大于limit;以此类推..... | 835 | | limit | Integer(32位) | 查询个数限制(limit <= 1000) | 836 | 837 | 示例: 838 | 839 | | url | body | 840 | | --- | --- | 841 | | https://api.hotbit.io/api/v1/market.user_deals |api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&offset=0&limit=100 | 842 | 843 | 844 | ### market.kline 845 | 846 | | 方法名 | 方法类型 | 描述 | 847 | | --- | --- | --- | 848 | | market.kline | get | k线查询 | 849 | 850 | 请求参数: 851 | 852 | | 参数名 | 参数类型 | 描述 | 853 | | --- | --- | --- | 854 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 855 | | start_time | Integer(无符号64位) | 起始时间戳(秒) | 856 | | end_time | Integer(无符号64位) | 结束时间戳(秒) | 857 | | interval | Integer(32位) | 周期间隔,单位秒, (起始时间到结束时间,总周期数) < 1000 | 858 | 859 | 示例: 860 | 861 | | url | body | 862 | | --- | --- | 863 | | https://api.hotbit.io/api/v1/market.kline?market=ETH/BTC&start_time=1521100000&end_time=1521101193&interval=60 | | 864 | 865 | 响应数据: 866 | 867 | 示例: 868 | 869 | 870 | ``` 871 | Response: 872 | { 873 | "error": null, 874 | "result": [ 875 | [1525067600, "11714.04", "11710.01", "11778.69", "11697.18", "13.604065", "159329.23062211", "BTCUSDT"], 876 | [1565067660, "11703.47", "11716.65", "11720.55", "11703.47", "14.401973", "168649.82127032", "BTCUSDT"], 877 | [1565067720, "11714.24", "11715.09", "11724.5", "11707.78", "12.287975", "143952.77384769", "BTCUSDT"]],#time ,open, close, high, low ,volume, deal, market 878 | "id": 1521169586 879 | } 880 | ``` 881 | 882 | 883 | 884 | ### market.status 885 | 886 | | 方法名 | 方法类型 | 描述 | 887 | | --- | --- | --- | 888 | | market.status | get | 获取过去指定时间段market当前最新涨跌幅,交易量,最高/最低价格等状态 | 889 | 890 | 请求参数: 891 | 892 | | 参数名 | 参数类型 | 描述 | 893 | | --- | --- | --- | 894 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 895 | | period | Integer(32位) | 查询周期,以秒为单位。即从现在开始往前推的时间,例如:86400,是过去24小时。 | 896 | 897 | 示例: 898 | 899 | | url | body | 900 | | --- | --- | 901 | | https://api.hotbit.io/api/v1/market.status?market=ETH/BTC&period=10 | | 902 | 903 | 响应数据: 904 | 905 | 示例: 906 | 907 | 908 | ``` 909 | Response: 910 | { 911 | "error": null, 912 | "result": { 913 | "period": 10, 914 | "last": "0.0743", 915 | "open": "0.074162", 916 | "close": "0.0743", 917 | "high": "0.0743", 918 | "low": "0.074162", 919 | "volume": "0.314", 920 | "deal": "0.023315531" 921 | }, 922 | "id": 1521169247 923 | } 924 | ``` 925 | 926 | 927 | 928 | ### market.status_today 929 | 930 | | 方法名 | 方法类型 | 描述 | 931 | | --- | --- | --- | 932 | | market.status_today | get | 获取今天market状态 | 933 | 934 | 请求参数: 935 | 936 | | 参数名 | 参数类型 | 描述 | 937 | | --- | --- | --- | 938 | | market | string | market名称,如:"BTC/USDT","BCC/USDT" | 939 | 940 | 示例: 941 | 942 | | url | body | 943 | | --- | --- | 944 | | https://api.hotbit.io/api/v1/market.status_today?market=ETH/BTC | | 945 | 946 | 响应数据: 947 | 948 | 示例: 949 | 950 | 951 | ``` 952 | Response: 953 | { 954 | "error": null, 955 | "result": { 956 | "open": "0.074015", 957 | "last": "0.074287", 958 | "high": "0.074485", 959 | "low": "0.073", 960 | "volume": "1141.63", 961 | "deal": "83.11985574" 962 | }, 963 | "id": 1521169293 964 | } 965 | ``` 966 | 967 | 968 | 969 | ### market.status24h 970 | 971 | | 方法名 | 方法类型 | 描述 | 972 | | ---------------- | -------- | ----------------------------------------------------------- | 973 | | market.status24h | get | 获取过去24小时内的market涨跌幅,交易量,最高/最低价格等状态 | 974 | 975 | 请求参数:无 976 | 977 | 示例: 978 | 979 | | url | body | 980 | | --------------------------------------------- | ---- | 981 | | https://api.hotbit.io/api/v1/market.status24h | | 982 | 983 | 响应数据: 984 | 985 | 示例: 986 | 987 | 988 | ``` 989 | Response: 990 | { 991 | "TRXETH": { 992 | "period": 86400, 993 | "last": "0.00013199", 994 | "open": "0.00013523", 995 | "close": "0.00013199", 996 | "high": "0.00013723", 997 | "low": "0.00013199", 998 | "volume": "887054.18", 999 | "deal": "119.2565600483" 1000 | }, 1001 | "ATNETH": { 1002 | "period": 86400, 1003 | "last": "0.00069484", 1004 | "open": "0.00069776", 1005 | "close": "0.00069484", 1006 | "high": "0.00069952", 1007 | "low": "0.00069449", 1008 | "volume": "153483.514", 1009 | "deal": "106.97614821094" 1010 | }, 1011 | "TNBETH": { 1012 | "period": 86400, 1013 | "last": "0.00010258", 1014 | "open": "0.00009194", 1015 | "close": "0.00010258", 1016 | "high": "0.00010538", 1017 | "low": "0.00008869", 1018 | "volume": "761802.93", 1019 | "deal": "73.4726442434" 1020 | }, 1021 | …… 1022 | "GVTETH": { 1023 | "period": 86400, 1024 | "last": "0.034525", 1025 | "open": "0.032989", 1026 | "close": "0.034525", 1027 | "high": "0.034567", 1028 | "low": "0.032878", 1029 | "volume": "612.44", 1030 | "deal": "20.60413469" 1031 | } 1032 | } 1033 | ``` 1034 | 1035 | 1036 | 1037 | ### market.summary 1038 | 1039 | | 方法名 | 方法类型 | 描述 | 1040 | | --- | --- | --- | 1041 | | market.summary | get | market概要 | 1042 | 1043 | 请求参数: 1044 | 1045 | | 参数名 | 参数类型 | 描述 | 1046 | | --- | --- | --- | 1047 | | markets | json array | market名称json array,如:["BTCUSD","BCCUSD"],如为空数组:[],返回所有market。 | 1048 | 1049 | 示例: 1050 | 1051 | | url | body | 1052 | | --- | --- | 1053 | | https://api.hotbit.io/api/v1/market.summary | | 1054 | 1055 | 1056 | 响应数据: 1057 | 1058 | 示例: 1059 | 1060 | 1061 | ``` 1062 | Response: 1063 | { 1064 | "error": null, 1065 | "result": [ 1066 | { 1067 | "name": "ETHBTC", 1068 | "ask_count": 0, 1069 | "ask_amount": "0", 1070 | "bid_count": 0, 1071 | "bid_amount": "0" 1072 | }, 1073 | { 1074 | "name": "QUNBTC", 1075 | "ask_count": 2, 1076 | "ask_amount": "28", 1077 | "bid_count": 2, 1078 | "bid_amount": "23" 1079 | } 1080 | ], 1081 | "id": 1521169429 1082 | } 1083 | ``` 1084 | 1085 | ### allticker 1086 | 1087 | | 方法名 | 方法类型 | 描述 | 1088 | | --- | --- | --- | 1089 | | allticker | get | 获取全市场交易对的最新成交信息 | 1090 | 1091 | 1092 | 请求参数: 1093 | 1094 | 无 1095 | 1096 | 示例: 1097 | 1098 | | url | body | 1099 | | --- | --- | 1100 | | https://api.hotbit.io/api/v1/allticker | | 1101 | 1102 | 1103 | 响应数据: 1104 | 1105 | 示例: 1106 | 1107 | 1108 | ``` 1109 | Response: 1110 | { 1111 | ticker: [ 1112 | { 1113 | symbol: "HTB_ETH", # 交易对名称 1114 | buy: "0.0000077393", # 买一价 1115 | sell: "0.0000078169", # 卖一价 1116 | open: "0.0000078205", # 开盘价 1117 | close: "0.0000077506", # 收盘价 1118 | high: "0.0000080946", # 最高价 1119 | low: "0.000007551", # 最低价 1120 | last: "0.0000077506", # 最新价 1121 | vol: "98842592" # 成交量 1122 | }, 1123 | { 1124 | symbol: "DELTA_ETH", 1125 | buy: "6.86e-8", 1126 | sell: "6.89e-8", 1127 | open: "7.13e-8", 1128 | close: "6.87e-8", 1129 | high: "7.19e-8", 1130 | low: "6.87e-8", 1131 | last: "6.87e-8", 1132 | vol: "143957900" 1133 | }] 1134 | } 1135 | ``` 1136 | -------------------------------------------------------------------------------- /rest_api_en.md: -------------------------------------------------------------------------------- 1 | # REST API     2 | 3 | ## Begin to Use 4 | 5 | REST is the abbreviation of Representational State Transfer, which is one of the most popular types of Internet software frameworks. REST is currently being adopted by an increasing number of websites due to its clear structure, compliance with standards, simpleness and outstanding scalability. The advantages of REST are listed as follows: 6 | - Each URL represents one type of resource in the framework of RESTful; 7 | - A certain type of presentation layer of the resource is delivered between the client end and the server; 8 | - The client end conduct operations on the resources of server end through four HTTP instructions for the "transformation on the status of presentation layer". 9 | The developers are recommended to use REST API for operations such as the transactions between different types of cryptocurrency tokens or asset withdrawals. 10 | 11 | ## Interaction Request 12 | 13 | The root URL that REST visits: 14 | All requests are based on Https protocol, the contentType of request header information is required to be configured as: application/x-www-form-urlencoded 15 | 16 | Description of Interaction Request 17 | 18 | 1. Request parameter: conduct parameter encapsulation according to the parameter regulated by interface request. 19 | 2. Submit the requested parameter: Submit the encapsulated parameter to the server through GET or POST. 20 | 3. Server Response: Firsrt, the server conducts parameter security verification on the data requested by the user, after the verification, the server returns the responded data to the user in JSON format based on business logic. 21 | 4. Data Process: Process the data responded by the server 22 | 23 | ## Request 24 | 25 | |Parameter Name|Description| 26 | | ----- | ----- | 27 | |method|Name of API Method| 28 | |params|Parameters| 29 | 30 | 31 | ## List of Functions 32 | 33 | |Function Name|Description|url| 34 | | :----- | :----- | :----- | 35 | |[server.time](#servertime)| Obtain System Time |https://api.hotbit.io/api/v1/server.time| | 36 | |[balance.query](#balancequery)| Obtain User Assets |https://api.hotbit.io/api/v1/balance.query| api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&assets=["BTC","ETH"]| 37 | |[asset.list](#assetlist)|Obtain the types and precisions of all assets on the platform, prec refers to the number of decimal digits after the decimal point|https://api.hotbit.io/api/v1/asset.list| | 38 | |[order.put_limit](#orderput_limit)|Limit Order Transaction|https://api.hotbit.io/api/v1/order.put_limit|api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&side=1&amount=10&price=100&isfee=0 | 39 | |[order.cancel](#ordercancel)|Cancel Transaction|https://api.hotbit.io/api/v1/order.cancel| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=BTC/ETH&order_id=1| 40 | |[order.batch_cancel](#orderbatch_cancel)|Cancel transactions in large quantities|https://api.hotbit.io/api/v1/order.batch_cancel| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=BTC/ETH&orders_id=[1,2]| 41 | |[order.deals](#orderdeals)|Obtain the details of settled orders|https://api.hotbit.io/api/v1/order.deals| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=100&limit=10&offset=0| 42 | |[order.finished_detail](#orderfinished_detail)|Check finished order according to order number|https://api.hotbit.io/api/v1/order.finished_detail| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=1| 43 | |[order.book](#orderbook)|Obtain Transaction List|https://api.hotbit.io/api/v1/order.book|market=ETH/BTC&side=1&offset=0&limit=10 | 44 | |[order.depth](#orderdepth)|Obtain Transaction Depth|https://api.hotbit.io/api/v1/order.depth|market=ETH/BTC&limit=100&interval=1e-8 | 45 | |[order.pending](#orderpending)|Check unexecuted orders|https://api.hotbit.io/api/v1/order.pending| api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&offset=0&limit=100| 46 | |[order.finished](#orderfinished)|Check the user's finished orders|https://api.hotbit.io/api/v1/order.finished|api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&start_time=1511967657&end_time =1512050400&offset=0&limit=100&side=1 | 47 | |[market.list](#marketlist)|Obtain the list of transaction pairs|https://api.hotbit.io/api/v1/market.list| | 48 | |[market.last](#marketlast)|Obtain the latest price of designated transaction pair|https://api.hotbit.io/api/v1/market.last| market=ETH/BTC| 49 | |[market.deals](#marketdeals)|Check the transaction records of the transaction pair|https://api.hotbit.io/api/v1/market.deals| market=ETH/BTC&limit=10&last_id=1521100930| 50 | |[market.user_deals](#marketuser_deals)|Check the user's transaction records|https://api.hotbit.io/api/v1/market.user_deals|api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&offset=0&limit=100 | 51 | |[market.kline](#marketkline)|Check K Chart|https://api.hotbit.io/api/v1/market.kline|market=ETH/BTC&start_time=1521100000&end_time=1521101193&interval=60 | 52 | |[market.status](#marketstatus)|Obtain latest market status within designated period in the past, such as latest range of increase and decline, transaction volume, highest/lowest price etc.|https://api.hotbit.io/api/v1/market.status|market=ETH/BTC&period=10 | 53 | |[market.status_today](#marketstatus_today)|Obtain today's market status|https://api.hotbit.io/api/v1/market.status_today|market=ETH/BTC | 54 | |[market.status24h](#marketstatus24h)|Obtain the market status within the previous 24 hours, such as range of increase and decline, transaction volume, highest and lowest price etc.|https://api.hotbit.io/api/v1/market.status24h|| 55 | |[market.summary](#marketsummary)|Market summary|https://api.hotbit.io/api/v1/market.summary|| 56 | |[allticker](#allticker)|Obtain the latest trading information of all transaction pairs|https://api.hotbit.io/api/v1/allticker|| 57 | 58 | ## Response 59 | Response can be found in the body section of "200 ok", which consists of three parameters: 60 | |Parameter Name|Parameter Type|Description| 61 | | :----- | :----- | :----- | 62 | |result|json object| The result of API call, when error occurs, the result is null| 63 | |error|json object| The information of API call error, when API call is correct, the information is null| 64 | |id|Integer|Request id| 65 | 66 | ``` 67 | Example of correct result: 68 | { 69 | "error": null, 70 | "result": {.....}, 71 | "id": 123 72 | } 73 | 74 | Example of incorrect result: 75 | { 76 | "error": { 77 | "code": 1, 78 | "message": "invalid argument" 79 | }, 80 | "result": null, 81 | "id": 123 82 | } 83 | ``` 84 | 85 | 86 | 87 | ## API Reference 88 | 89 | **System API, obtains system resource** 90 | 91 | 92 | 93 | ### server.time 94 | 95 | | Name of Method | Type of Method | Description | 96 | | --- | --- | --- | 97 | | server.time | get | Obtain System Time | 98 | 99 | Parameter requested: No 100 | 101 | Example: 102 | 103 | | url | body | 104 | | --- | --- | 105 | | https://api.hotbit.io/api/v1/server.time | | 106 | 107 | Data Responded: 108 | 109 | 110 | | Name of Parameter | Type of Data | Must or not | Description | 111 | | --- | --- | --- | --- | 112 | | result | long | true | Obtain System Time | 113 | 114 | Example: 115 | 116 | ``` 117 | Response:{"error": null, "result": 1520919059} 118 | ``` 119 | 120 | 121 | 122 | ## Asset API 123 | 124 | **User asset API enables the checking and update of all types of user assets and the obtention of all history records of any operations that are related to the user's assets** 125 | 126 | ### balance.query 127 | 128 | | Name of Method | Type of Method | Description | 129 | | --- | --- | --- | 130 | | balance.query | post | Obtain User Assets | 131 | 132 | Requested parameter: 133 | 134 | | Name of Parameter | Type of Parameter | Description | 135 | | --- | --- | --- | 136 | | api_key | string | The API KEY applied by the user | 137 | | sign | string | Request the signature value of the string | 138 | | assets | json array | The array of token abbreviation, empty arran means to obtain all token assets | 139 | 140 | Example: 141 | 142 | | url | body | 143 | | --- | --- | 144 | | https://api.hotbit.io/api/v1/balance.query | api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&assets=["BTC","ETH"] | 145 | 146 | 147 | 148 | ### balance.history 149 | 150 | | Name of Method | Type of Method | Description | 151 | | --- | --- | --- | 152 | | balance.history | post | Obtain the records regarding the changes in user assets | 153 | 154 | Requested Parameter: 155 | 156 | | Parameter Name | Parameter Type | Description | 157 | | --- | --- | --- | 158 | | api_key | string | User's API KEY | 159 | | sign | string | User's signature value | 160 | | asset | string | Asset name, such as: "BTC","ETH",""means the names of all assets | 161 | | business | string | Business name, such as:"deposit"or"trade",""means all business names | 162 | | start_time | Integer(unsigned 64bit) | Start time(second) | 163 | | end_time | Integer(unsigned 64bit) | End Time(second) | 164 | | offset | Integer(32bit) | Offset position,if value set as 0,it means that the total number of transactions from the earliest transaction to the most recent transaction cannot be greater than limit;。if value set as 1, it means that the total number of transactions from the earliest transaction to the second most recent transaction cannot be greater than limit; and so on | 165 | | limit | Integer | Maximum number of transactions returned | 166 | 167 | Example: 168 | 169 | | url | body | 170 | | --- | --- | 171 | | https://api.hotbit.io/api/v1/balance.history | api_key=5eae7322-6f92-873a-9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&asset=BTC&business=deposit&start_time=1511967657&end_time =1512050400&offset=0&limit=100 | 172 | 173 | 174 | 175 | ### asset.list 176 | 177 | | Name of Method | Type of Method | Description | 178 | | --- | --- | --- | 179 | | asset.list | get | Obtain the types and precisions of all assets on the platform, prec refers to the number of decimal digits after the decimal point| 180 | 181 | Parameter Requested: No 182 | 183 | Example: 184 | 185 | | url | body | 186 | | --- | --- | 187 | | https://api.hotbit.io/api/v1/asset.list | | 188 | 189 | ata Responded: 190 | 191 | Example: 192 | 193 | 194 | ``` 195 | Response: 196 | { 197 | "error": null, 198 | "result": [ 199 | { 200 | "name": "BTC", 201 | "prec": 8 202 | }, 203 | { 204 | "name": "ETH", 205 | "prec": 8 206 | } 207 | ], 208 | "id": 1521164549 209 | } 210 | ``` 211 | 212 | 213 | 214 | ## Trade API 215 | 216 | **Trade API** 217 | 218 | ### order.put_limit 219 | 220 | | Name of Method | Type of Method | Description | 221 | | --- | --- | --- | 222 | | order.put_limit | post | Limit Order Transaction | 223 | 224 | Requested Parameter: 225 | 226 | | Name of Parameter | Type of Parameter | Description | 227 | | --- | --- | --- | 228 | | api_key | string | User's API KEY | 229 | | sign | string | User's signature value | 230 | | market | string | market name,such as:"BTC/USDT","ETH/USDT" | 231 | | side | Integer(32bit) | 1 = "sell",2="buy" | 232 | | amount | string | Amount of tokens applied for trading (**Note that the amount must be the multiple of minimum amount**)| 233 | | price | string | Trading price | 234 | | isfee | Integer(32bit) | Use deductable token to deduct or not 0 = "no(no)",1="yes(yes)"| 235 | 236 | **Only 200 orders are allowed to be placed simultaneously under the same transaction pair** 237 | 238 | Example: 239 | 240 | | url | body | 241 | | --- | --- | 242 | | https://api.hotbit.io/api/v1/order.put_limit | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&side=1&amount=10&price=100&isfee=0 | 243 | Data Responded: 244 | 245 | Example: 246 | 247 | 248 | ``` 249 | Response: 250 | { 251 | "error": null, 252 | "result": 253 | { 254 | "id":8688803, #order-ID 255 | "market":"ETHBTC", 256 | "source":"web", #The source identification of data request 257 | "type":1, #Type of order pladement 1-limit order 258 | "side":2, #Identification of buyers and sellers 1-Seller,2-buyer 259 | "user":15731, 260 | "ctime":1526971722.164765, #Time of order establishment(second) 261 | "mtime":1526971722.164765, #Time of order update(second) 262 | "price":"0.080003", 263 | "amount":"0.4", 264 | "taker_fee":"0.0025", 265 | "maker_fee":"0", 266 | "left":"0.4", 267 | "deal_stock":"0", 268 | "deal_money":"0", 269 | "deal_fee":"0", 270 | "status":0 , #Sign of order status when 0x8 is true, it means the current order is cancelled, when 0x80 is true, it means that the current order is deducted by deductable tokens "fee_stock":"HTB", #Name of deductable token 271 | "alt_fee":"0.5", #The discount of deductable tokens 272 | "deal_fee_alt":"0.123" #Amount deducted 273 | }, 274 | "id": 1521169460 275 | } 276 | ``` 277 | 278 | 279 | ### order.cancel 280 | 281 | | Name of Method | Type of Method | Description | 282 | | --- | --- | --- | 283 | | order.cancel | post | Cancel Transaction | 284 | 285 | Parameter Requested: 286 | 287 | | Name of Parameter | Type of Parameter | Description | 288 | | --- | --- | --- | 289 | | api_key | string | User's API KEY | 290 | | sign | string | User's signature value | 291 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 292 | | order_id | Integer(unsigned 64bit) | The id whose transactions are required to be cancelled 。Refer to"order.put_limit"for the returned result of the method。| 293 | 294 | Example: 295 | 296 | | url | body | 297 | | --- | --- | 298 | | https://api.hotbit.io/api/v1/order.cancel | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&order_id=1 | 299 | 300 | Data Responded: 301 | 302 | Example: 303 | 304 | 305 | ``` 306 | Response: 307 | { 308 | "error": null, 309 | "result": 310 | { 311 | "id":8688803, #order-ID 312 | "market":"ETHBTC", 313 | "source":"web", #The source identification of data request 314 | "type":1, #Type of order pladement 1-limit order 315 | "side":2, #The sign of buyer and seller 1-seller,2-buyer 316 | "user":15731, 317 | "ctime":1526971722.164765, #Time of order establishment(second) 318 | "mtime":1526971722.164765, #Time of order update(second) 319 | "price":"0.080003", 320 | "amount":"0.4", 321 | "taker_fee":"0.0025", 322 | "maker_fee":"0", 323 | "left":"0.4", 324 | "deal_stock":"0", 325 | "deal_money":"0", 326 | "deal_fee":"0", 327 | "status":0 , #Sign of order status when 0x8 is true, it means the current order is cancelled, when 0x80 is true, it means that the current order is deducted by deductable tokens "fee_stock":"HTB", #Name of deductable token 328 | "alt_fee":"0.5", #The discount of deductable tokens 329 | "deal_fee_alt":"0.123" #The amount deducted 330 | }, 331 | "id": 1521169460 332 | } 333 | ``` 334 | 335 | ### order.batch_cancel 336 | 337 | | Name of Method | Type of Method | Description | 338 | | --- | --- | --- | 339 | | order.batch_cancel | post | Cancel transactions in large quantities | 340 | 341 | Parameter requested: 342 | 343 | | Name of Parameter | Type of parameter | Description | 344 | | --- | --- | --- | 345 | | api_key | string | User's API KEY | 346 | | sign | string | User's signature value | 347 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 348 | | orders_id | arrary | For those id(unsigned 64bit) that requires to cancel transactions, the maximum number of orders allowed to be cancelled is 10,refer to"order.put_limit"for the returned result of the method.| 349 | 350 | Example: 351 | 352 | | url | body | 353 | | --- | --- | 354 | | https://api.hotbit.io/api/v1/order.batch_cancel | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&orders_id=[1,2] | 355 | 356 | Data Responded: 357 | 358 | Example: 359 | 360 | 361 | ``` 362 | Response: 363 | { 364 | "error": null, 365 | "result": 366 | [ 367 | {#Correct feedback 368 | "id":8688803, #order-ID(unsigned 64bit) 369 | "market":"ETHBTC", 370 | "source":"web", #The source identification of data request 371 | "type":1, #Type of order placement 1-limit order 372 | "side":2, #sign of buyer and seller 1-seller,2-buyer 373 | "user":15731, 374 | "ctime":1526971722.164765, #Time of order establishment(second) 375 | "mtime":1526971722.164765, #Time of order update(second) 376 | "price":"0.080003", 377 | "amount":"0.4", 378 | "taker_fee":"0.0025", 379 | "maker_fee":"0", 380 | "left":"0.4", 381 | "deal_stock":"0", 382 | "deal_money":"0", 383 | "deal_fee":"0", 384 | "status":0 , #Sign of order status when 0x8 is true, it means the current order is cancelled, when 0x80 is true, it means that the current order is deducted by deductable tokens "fee_stock":"HTB", #Name of deductable token 385 | "alt_fee":"0.5", #The discount of deductable token 386 | "deal_fee_alt":"0.123" #The amount deducted 387 | }, 388 | { #Error feedback occured 389 | "error": { 390 | "code":10 391 | "message":"order not found" 392 | } 393 | "result":null, 394 | "id": 1521169460 395 | } 396 | ], 397 | "id": 1521169460 398 | } 399 | ``` 400 | 401 | ### order.deals 402 | 403 | | Name of method | Type of method | Description | 404 | | --- | --- | --- | 405 | | order.deals | post | Obtain the details of settled orders | 406 | 407 | Parameter requested: 408 | 409 | | Name of parameter | Type of parameter | Description | 410 | | --- | --- | --- | 411 | | api_key | string | User's API KEY | 412 | | sign | string | User's signature value | 413 | | order_id | Integer(unsigned 64bit) | Transaction ID,refer to "order.put_limit"for the returned result of the method| 414 | | offset | Integer(32bit) | equals to 0,means search from the latest transaction to previous transactions | 415 | | limit | Integer(32bit) | Maximum number of "records" returned | 416 | 417 | Example: 418 | 419 | | url | body | 420 | | --- | --- | 421 | | https://api.hotbit.io/api/v1/order.deals | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=100&limit=10&offset=0 | 422 | 423 | Data responded: 424 | 425 | Example: 426 | 427 | 428 | ``` 429 | Response: 430 | { 431 | "error": null, 432 | "result": { 433 | "offset": 10, 434 | "limit": 10, 435 | "records": [ 436 | { 437 | "time": 1521107411.116817, 438 | "user": 15643, 439 | "id": 1385154, 440 | "role": 1, 441 | "price": "0.02", 442 | "amount": "0.071", 443 | "deal": "0.00142", 444 | "fee": "0", 445 | "deal_order_id": 2337658 446 | }, 447 | { 448 | "time": 1521107410.357024,#(秒) 449 | "user": 15643, 450 | "id": 1385151, 451 | "role": 1, 452 | "price": "0.02", 453 | "amount": "0.081", 454 | "deal": "0.00162", 455 | "fee": "0", 456 | "deal_order_id": 2337653 457 | } 458 | ] 459 | }, 460 | "id": 1521169460 461 | } 462 | ``` 463 | 464 | 465 | ### order.finished_detail 466 | 467 | | Name of method | Type of method | Description | 468 | | --- | --- | --- | 469 | | order.finished_detail | post | Check finished orders according to order number | 470 | 471 | 请求参数:Parameter requested: 472 | 473 | | Name of parameter | Type of parameter | Description | 474 | | --- | --- | --- | 475 | | api_key | string | User's API KEY | 476 | | sign | string | User's signature value | 477 | | order_id | Integer(unsigned 64bit) | Transaction ID,refer to "order.put_limit"for the returned result of the method| 478 | 479 | 480 | Example: 481 | 482 | | url | body | 483 | | --- | --- | 484 | | https://api.hotbit.io/api/v1/order.finished_detail | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&order_id=1 | 485 | 486 | Data responded: 487 | 488 | Example: 489 | 490 | 491 | ``` 492 | Response: 493 | { 494 | "error": null, 495 | "result": { 496 | "id": 1, 497 | "ctime": 1535545564.4409361,#(秒) 498 | "ftime": 1535545564.525017,#(秒) 499 | "user": 15731, 500 | "market": "YCCETH", 501 | "source": "test", 502 | "type": 1, 503 | "side": 2, 504 | "price": "0.0000509", 505 | "amount": "1", 506 | "taker_fee": "0.001", 507 | "maker_fee": "0.001", 508 | "deal_stock": "1", 509 | "deal_money": "0.0000509", 510 | "deal_fee": "0.001", 511 | "status":0 , #Sign of order status when 0x8 is true, it means the current order is cancelled, when 0x80 is true, it means that the current order is deducted by deductable tokens "fee_stock":"HTB", #Name of deductable token 512 | "alt_fee":"0.5", #The discount of deductable token 513 | "deal_fee_alt":"0.123" #Amount deducted 514 | }, 515 | "id": 1536050997 516 | } 517 | ``` 518 | 519 | 520 | ### order.book 521 | 522 | | Name of the method | type of method | description | 523 | | --- | --- | --- | 524 | | order.book | get | obtain list of transaction | 525 | 526 | Requested parameter: 527 | 528 | | name of parameter | type of parameter | description | 529 | | --- | --- | --- | 530 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 531 | | side | Integer(32bit) | 1 = "sell",2="buy" | 532 | | offset | Integer(32bit) | Offset position,if value set as 0,it means that the total number of transactions from the earliest transaction to the most recent transaction cannot be greater than limit;。if value set as 1, it means that the total number of transactions from the earliest transaction to the second most recent transaction cannot be greater than limit; and so on.....| 533 | | limit | Integer(32bit) | The maximum number of "records"to be returned | 534 | 535 | Example: 536 | 537 | | url | body | 538 | | --- | --- | 539 | | https://api.hotbit.io/api/v1/order.book?market=ETH/BTC&side=1&offset=0&limit=10 | | 540 | 541 | Data responded 542 | 543 | Example: 544 | 545 | 546 | ``` 547 | Response: 548 | { 549 | "error": null, 550 | "result": { 551 | "offset": 0, 552 | "limit": 10, 553 | "total": 0, 554 | "orders": [] 555 | }, 556 | "id": 1521169117 557 | } 558 | ``` 559 | 560 | 561 | 562 | ### order.depth 563 | 564 | | Name of method | type of method | description | 565 | | --- | --- | --- | 566 | | order.depth | get | obtain trading depth | 567 | 568 | parameter requested: 569 | 570 | | name of parameter | type of parameter | description | 571 | | --- | --- | --- | 572 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 573 | | limit | Integer(32bit) | maximum number of "records"to be returned,value allowed:1, 5, 10, 20, 30, 50, 100 | 574 | | interval | string | price precision,value allowed:0,0.1,0.01,0.001,……,0.0000000001 | 575 | 576 | Example: 577 | 578 | | url | body | 579 | | --- | --- | 580 | | https://api.hotbit.io/api/v1/order.depth?market=ETH/BTC&limit=100&interval=1e-8 | | 581 | 582 | data responded: 583 | 584 | Example: 585 | 586 | 587 | ``` 588 | Response: 589 | { 590 | "error": null, 591 | "result": 592 | { 593 | "asks": [["0.0733858", "0.319"], ["0.0741178", "0.252"], ["0.0742609", "0.03"], ... ["0.1250465", "0.272"]], 594 | "bids": [["0.0730197", "0.275"], ["0.0723", "1.052"], ["0.0722876", "0.302"], ... ["2.0e-7", "1"]]}, 595 | "id": 1527559250 596 | } 597 | ``` 598 | 599 | 600 | 601 | ### order.pending 602 | 603 | | name of method | type of method | description | 604 | | --- | --- | --- | 605 | | order.pending | post | Check unexecuted order | 606 | 607 | parameter requested: 608 | 609 | | name of parameter | type of parameter | description | 610 | | --- | --- | --- | 611 | | api_key | string | user's API KEY | 612 | | sign | string | user's signature value | 613 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 614 | | offset | Integer(32bit) | Offset position,if value set as 0,it means that the total number of transactions from the earliest transaction to the most recent transaction cannot be greater than limit;。if value set as 1, it means that the total number of transactions from the earliest transaction to the second most recent transaction cannot be greater than limit; and so on.....| 615 | | limit | Integer(32bit) | maximum number of "records"to be returned | 616 | Example: 617 | 618 | | url | body | 619 | | --- | --- | 620 | | https://api.hotbit.io/api/v1/order.pending | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=fdcafaf85a38970e4d84f6f286a2879e&market=ETH/BTC&offset=0&limit=100 | 621 | 622 | Data responded: 623 | 624 | Example: 625 | 626 | ``` 627 | { 628 | "error":null, 629 | "result":{ 630 | "ETHBTC":{ 631 | "limit":50, 632 | "offset":0, 633 | "total":1, 634 | "records":[ 635 | { 636 | "id":8688803, #order-ID 637 | "market":"ETHBTC", 638 | "source":"web", #source identification of data request 639 | "type":1, #type of order placement 1-limit order 640 | "side":2, #sign of buyer and seller 1-seller,2-buyer 641 | "user":15731, 642 | "ctime":1526971722.164765, #Time of order establishment 643 | "mtime":1526971722.164765, #Time of order establishment 644 | "price":"0.080003", 645 | "amount":"0.4", 646 | "taker_fee":"0.0025", 647 | "maker_fee":"0", 648 | "left":"0.4", 649 | "deal_stock":"0", 650 | "deal_money":"0", 651 | "deal_fee":"0", 652 | "status":0 , #Sign of order status when 0x8 is true, it means the current order is cancelled, when 0x80 is true, it means that the current order is deducted by deductable tokens "fee_stock":"HTB", #name of deductable token 653 | "alt_fee":"0.5", #Discount of the deductable token 654 | "deal_fee_alt":"0.123" #amount deducted 655 | } 656 | ] 657 | } 658 | }, 659 | "id":1526971756 660 | } 661 | ``` 662 | 663 | 664 | ### order.finished 665 | 666 | | name of method | type of method | description | 667 | | --- | --- | --- | 668 | | order.finished | post | Check the user's finished orders | 669 | 670 | parameter requested: 671 | 672 | | name of parameter | type of parameter | description | 673 | | --- | --- | --- | 674 | | api_key | string | user's API KEY | 675 | | sign | string | user's signature value | 676 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 677 | | start_time | Integer(unsigned 64bit) | starting time(second) | 678 | | end_time | Integer(unsigned 64bit) | ending time(second) | 679 | | offset | Integer(32bit) | Offset position,if value set as 0,it means that the total number of transactions from the earliest transaction to the most recent transaction cannot be greater than limit;。if value set as 1, it means that the total number of transactions from the earliest transaction to the second most recent transaction cannot be greater than limit; and so on | 680 | | limit | Integer(32bit) | Maximum number of "records"returned | 681 | | side | Integer(32bit) | 1 = "sell",2="buy" | 682 | 683 | Example: 684 | 685 | | url | body | 686 | | --- | --- | 687 | | https://api.hotbit.io/api/v1/order.finished | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&start_time=1511967657&end_time =1512050400&offset=0&limit=100&side=1 | 688 | 689 | 690 | 691 | ## Market API 692 | 693 | **Market API** 694 | 695 | ### market.list 696 | 697 | | Name of method | type of method | description | 698 | | --- | --- | --- | 699 | | market.list | get | Obtain the list of transaction pairs | 700 | 701 | Parameter requested: no 702 | 703 | Example: 704 | 705 | | url | body | 706 | | --- | --- | 707 | | https://api.hotbit.io/api/v1/market.list | | 708 | 709 | Data responded: 710 | 711 | Example: 712 | 713 | 714 | ``` 715 | Response: 716 | { 717 | "error": null, 718 | "result": [ 719 | { 720 | "name": "QASHBTC", 721 | "stock": "QASH", 722 | "money": "BTC", 723 | "fee_prec": 4, #the precision of the rate of transaction fee is 4 digits after decimal point 724 | "stock_prec": 2, #stock precision 725 | "money_prec": 8, #money precision 726 | "min_amount": "0.1" #Minimum value of order placement 727 | }, 728 | { 729 | "name": "QASHETH", 730 | "stock": "QASH", 731 | "money": "ETH", 732 | "fee_prec": 4, 733 | "stock_prec": 2, 734 | "money_prec": 8, 735 | "min_amount": "0.0001" 736 | } 737 | ], 738 | "id": 1521169333 739 | } 740 | ``` 741 | 742 | 743 | 744 | ### market.last 745 | | name of method | type of method | description | 746 | | --- | --- | --- | 747 | | market.last | get | obtain the latest price of designated transaction pair | 748 | 749 | parameter requested: 750 | 751 | | name of parameter | type of parameter | description | 752 | | --- | --- | --- | 753 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 754 | 755 | Example: 756 | 757 | | url | body | 758 | | --- | --- | 759 | | https://api.hotbit.io/api/v1/market.last?market=ETH/BTC | | 760 | 761 | Data responded: 762 | 763 | Example: 764 | 765 | 766 | ``` 767 | Response: 768 | { 769 | "error": null, 770 | "result": "0.07413600", 771 | "id": 1521169525 772 | } 773 | ``` 774 | 775 | 776 | 777 | ### market.deals 778 | 779 | | name of method | type of method | description | 780 | | --- | --- | --- | 781 | | market.deals | get | check the transaction records of the transaction pair | 782 | 783 | parameter requested: 784 | 785 | | name of parameter | type of parameter | description | 786 | | --- | --- | --- | 787 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 788 | | limit | Integer(32bit) | check limit in number(limit <= 1000) | 789 | | last_id | Integer(32bit) | return to the trading data which is greater than order_id > last_id | 790 | 791 | Example: 792 | 793 | | url | body | 794 | | --- | --- | 795 | | https://api.hotbit.io/api/v1/market.deals?market=ETH/BTC&limit=10&last_id=1521100930 | | 796 | 797 | Data responded: 798 | 799 | Example: 800 | 801 | 802 | ``` 803 | Response: 804 | { 805 | "error": null, 806 | "result": [], 807 | "id": 1521169562 808 | } 809 | ``` 810 | 811 | 812 | 813 | ### market.user_deals 814 | 815 | | name of method | type of method | description | 816 | | --- | --- | --- | 817 | | market.user_deals | post | check the user's transaction records | 818 | 819 | requested parameter: 820 | 821 | | name of parameter | type of parameter | description | 822 | | --- | --- | --- | 823 | | api_key | string | user's API KEY | 824 | | sign | string | user's signature value | 825 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 826 | | offset | Integer(32bit) | Offset position,if value set as 0,it means that the total number of transactions from the earliest transaction to the most recent transaction cannot be greater than limit;。if value set as 1, it means that the total number of all orders that meet the requirements from the second most recent order to the earliest order cannot be greater than limit; and so on.....| 827 | | limit | Integer(32bit) | Check limit in number(limit <= 1000) | 828 | 829 | Example: 830 | 831 | | url | body | 832 | | --- | --- | 833 | | https://api.hotbit.io/api/v1/market.user_deals | api_key=5eae7322-6f92-873a-e9bc214fd61517ec&sign=FDCAFAF85A38970E4D84F6F286A2879E&market=ETH/BTC&offset=0&limit=100| 834 | 835 | 836 | ### market.kline 837 | 838 | | name of method | type of method | description | 839 | | --- | --- | --- | 840 | | market.kline | get | Check K Chart | 841 | 842 | Parameter requested: 843 | 844 | | name of parameter | type of parameter | description | 845 | | --- | --- | --- | 846 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 847 | | start_time | Integer(unsigned 64bit) | Starting timestamp(second) | 848 | | end_time | Integer(unsigned 64bit) | ending timestamp(second) | 849 | | interval | Integer(32bit) | interval of periods,unit second, (starting time to ending time,total number of periods) < 1000 | 850 | 851 | Example: 852 | 853 | | url | body | 854 | | --- | --- | 855 | | https://api.hotbit.io/api/v1/market.kline?market=ETH/BTC&start_time=1521100000&end_time=1521101193&interval=60 | | 856 | 857 | Data responded: 858 | 859 | Example: 860 | 861 | 862 | ``` 863 | Response: 864 | { 865 | "error": null, 866 | "result": [ 867 | [1525067600, "11714.04", "11710.01", "11778.69", "11697.18", "13.604065", "159329.23062211", "BTCUSDT"], 868 | [1565067660, "11703.47", "11716.65", "11720.55", "11703.47", "14.401973", "168649.82127032", "BTCUSDT"], 869 | [1565067720, "11714.24", "11715.09", "11724.5", "11707.78", "12.287975", "143952.77384769", "BTCUSDT"]],#time ,open, close, high, low ,volume, deal, market 870 | "id": 1521169586 871 | } 872 | ``` 873 | 874 | 875 | 876 | ### market.status 877 | 878 | | name of method | type of method | description | 879 | | --- | --- | --- | 880 | | market.status | get | obtain the latest status of the market during the designated period of time in the past,l such as latest range of increase and decline, trading volume, highest/lowest price etc. | 881 | 882 | parameter requested: 883 | 884 | | name of parameter | type of parameter | description | 885 | | --- | --- | --- | 886 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 887 | | period | Integer(32bit) | period of inquiry,unit is second. It refers to the time from now on to the past,for example:86400,means the previous 24 hours. | 888 | 889 | Example: 890 | 891 | | url | body | 892 | | --- | --- | 893 | | https://api.hotbit.io/api/v1/market.status?market=ETH/BTC&period=10 | | 894 | 895 | Data responded: 896 | 897 | example: 898 | 899 | 900 | ``` 901 | Response: 902 | { 903 | "error": null, 904 | "result": { 905 | "period": 10, 906 | "last": "0.0743", 907 | "open": "0.074162", 908 | "close": "0.0743", 909 | "high": "0.0743", 910 | "low": "0.074162", 911 | "volume": "0.314", 912 | "deal": "0.023315531" 913 | }, 914 | "id": 1521169247 915 | } 916 | ``` 917 | 918 | 919 | 920 | ### market.status_today 921 | 922 | | name of method | type of method | description | 923 | | --- | --- | --- | 924 | | market.status_today | get | obtain today's market status | 925 | 926 | parameter requested: 927 | 928 | | name of parameter | type of parameter | description | 929 | | --- | --- | --- | 930 | | market | string | market name,such as:"BTC/USDT","BCC/USDT" | 931 | 932 | example: 933 | 934 | | url | body | 935 | | --- | --- | 936 | | https://api.hotbit.io/api/v1/market.status_today?market=ETH/BTC | | 937 | 938 | data responded: 939 | 940 | example: 941 | 942 | 943 | ``` 944 | Response: 945 | { 946 | "error": null, 947 | "result": { 948 | "open": "0.074015", 949 | "last": "0.074287", 950 | "high": "0.074485", 951 | "low": "0.073", 952 | "volume": "1141.63", 953 | "deal": "83.11985574" 954 | }, 955 | "id": 1521169293 956 | } 957 | ``` 958 | 959 | 960 | 961 | ### market.status24h 962 | 963 | | name of method | type of method | description | 964 | | ---------------- | -------- | ----------------------------------------------------------- | 965 | | market.status24h | get | Obtain the market status within the previous 24 hours, such as the range of increase and decline, trading volume, highest/lowest price etc. | 966 | 967 | Requested parameter: no 968 | 969 | Example: 970 | 971 | | url | body | 972 | | --------------------------------------------- | ---- | 973 | | https://api.hotbit.io/api/v1/market.status24h | | 974 | 975 | data responded: 976 | 977 | example: 978 | 979 | 980 | ``` 981 | Response: 982 | { 983 | "TRXETH": { 984 | "period": 86400, 985 | "last": "0.00013199", 986 | "open": "0.00013523", 987 | "close": "0.00013199", 988 | "high": "0.00013723", 989 | "low": "0.00013199", 990 | "volume": "887054.18", 991 | "deal": "119.2565600483" 992 | }, 993 | "ATNETH": { 994 | "period": 86400, 995 | "last": "0.00069484", 996 | "open": "0.00069776", 997 | "close": "0.00069484", 998 | "high": "0.00069952", 999 | "low": "0.00069449", 1000 | "volume": "153483.514", 1001 | "deal": "106.97614821094" 1002 | }, 1003 | "TNBETH": { 1004 | "period": 86400, 1005 | "last": "0.00010258", 1006 | "open": "0.00009194", 1007 | "close": "0.00010258", 1008 | "high": "0.00010538", 1009 | "low": "0.00008869", 1010 | "volume": "761802.93", 1011 | "deal": "73.4726442434" 1012 | }, 1013 | …… 1014 | "GVTETH": { 1015 | "period": 86400, 1016 | "last": "0.034525", 1017 | "open": "0.032989", 1018 | "close": "0.034525", 1019 | "high": "0.034567", 1020 | "low": "0.032878", 1021 | "volume": "612.44", 1022 | "deal": "20.60413469" 1023 | } 1024 | } 1025 | ``` 1026 | 1027 | 1028 | 1029 | ### market.summary 1030 | 1031 | | name of method | type of method | description | 1032 | | --- | --- | --- | 1033 | | market.summary | get | market summary | 1034 | 1035 | parameter requested: 1036 | 1037 | | name of parameter | type of parameter | description | 1038 | | --- | --- | --- | 1039 | | markets | json array | marketnamejson array,such as:["BTCUSD","BCCUSD"],in case of empty array:[],return to all market。 | 1040 | 1041 | example: 1042 | 1043 | | url | body | 1044 | | --- | --- | 1045 | | https://api.hotbit.io/api/v1/market.summary | | 1046 | 1047 | 1048 | data responded: 1049 | 1050 | example: 1051 | 1052 | 1053 | ``` 1054 | Response: 1055 | { 1056 | "error": null, 1057 | "result": [ 1058 | { 1059 | "name": "ETHBTC", 1060 | "ask_count": 0, 1061 | "ask_amount": "0", 1062 | "bid_count": 0, 1063 | "bid_amount": "0" 1064 | }, 1065 | { 1066 | "name": "QUNBTC", 1067 | "ask_count": 2, 1068 | "ask_amount": "28", 1069 | "bid_count": 2, 1070 | "bid_amount": "23" 1071 | } 1072 | ], 1073 | "id": 1521169429 1074 | } 1075 | ``` 1076 | 1077 | ### allticker 1078 | 1079 | | name of method | type of method | description | 1080 | | --- | --- | --- | 1081 | | allticker | get | obtain the latest trading informnation of all transaction pairs in the market | 1082 | 1083 | 1084 | requested parameter: 1085 | 1086 | no 1087 | 1088 | example: 1089 | 1090 | | url | body | 1091 | | --- | --- | 1092 | | https://api.hotbit.io/api/v1/allticker | | 1093 | 1094 | 1095 | data responded: 1096 | 1097 | example: 1098 | 1099 | 1100 | ``` 1101 | Response: 1102 | { 1103 | ticker: [ 1104 | { 1105 | symbol: "HTB_ETH", # name of transaction pair 1106 | buy: "0.0000077393", # buy one price 1107 | sell: "0.0000078169", # sell one price 1108 | open: "0.0000078205", # open price 1109 | close: "0.0000077506", # close price 1110 | high: "0.0000080946", # highest price 1111 | low: "0.000007551", # lowest price 1112 | last: "0.0000077506", # latest price 1113 | vol: "98842592" # transaction volume 1114 | }, 1115 | { 1116 | symbol: "DELTA_ETH", 1117 | buy: "6.86e-8", 1118 | sell: "6.89e-8", 1119 | open: "7.13e-8", 1120 | close: "6.87e-8", 1121 | high: "7.19e-8", 1122 | low: "6.87e-8", 1123 | last: "6.87e-8", 1124 | vol: "143957900" 1125 | }] 1126 | } 1127 | ``` 1128 | -------------------------------------------------------------------------------- /update_log.md: -------------------------------------------------------------------------------- 1 | # 更新日志 2 | 3 | 2019.3.28 4 | 5 | 对订单增加了status字段用于表示订单状态标志 6 | 当(status &(与) 0x8)为真的时候表示当前订单是取消的 7 | 8 | 2019.5.9 9 | 10 | 明确接口里面涉及的时间单位为秒 11 | 12 | 2019.5.10 13 | 14 | 修改market.deals接口参数传输错误提示,此接口不需要签名认证 15 | 16 | 2019.6.3 17 | 18 | 修改order.put_limit接口,增加了is_fee字段,用于标记是否需要使用抵扣折扣币,1-表示使用抵扣折扣币,0-表示不使用 19 | 20 | 订单详情增加了3个字段fee_stock,alt_fee, deal_fee_alt。 21 | 22 | fee_stock:抵扣币的名称 23 | 24 | alt_fee:抵扣币的优惠折扣 25 | 26 | deal_fee_alt:已经抵扣的抵扣币 27 | 28 | 修改了status字段状态,增加了与0x80取真的判断代表是否使用了抵扣币,(status&0x80)TRUE-使用了抵扣币,FALSE-未使用抵扣币 29 | 30 | 2019.7.31 31 | 32 | 更正market.user_deals接口的错误 33 | 34 | 2019.8.8 35 | 36 | 增加depths.subscribe接口,用于批量订单深度订阅,避免建立多个socket监听 37 | -------------------------------------------------------------------------------- /update_log_en.md: -------------------------------------------------------------------------------- 1 | # Update Log 2 | 3 | 2019.3.28 4 | 5 | Added status field to order for the representation of the sign of order status 6 | When (status & 0x8) is true, it means the current order is cancelled 7 | 2019.5.9 8 | 9 | Defined that the unit of time involved in the interface is second 10 | 11 | 2019.5.10 12 | 13 | Modified the notice regarding the incorrect parameter of market.deals interface, this interface does not require signature verification 14 | 15 | 2019.6.3 16 | 17 | Modified the interface of order.put\_limit, added is\_fee field as the signal of showing whether the use of deductable tokens is required or not, 1-means use deductable tokens, 0-means do not use 18 | fee\_stock,alt\_fee, deal\_fee\_alt Added 3 fields fee\_stock,alt\_fee, deal\_fee\_alt into order details 19 | 20 | fee\_stock:Name of deductable token 21 | 22 | alt\_fee:The discount of deductable token 23 | 24 | deal\_fee\_alt:The deductable tokens that are already deducted 25 | 26 | Modified the status of status field, added the judgment of &0x80 to determine whether deductable tokens are used or not, (status&0x80)TRUE-deductable tokens are used, FALSE-deductable tokens are not used 27 | 28 | 2019.7.31 29 | 30 | Correct the interface of market.user\_deals 31 | 32 | 2019.8.8 33 | 34 | add depths.subscribe interface for the bulk subscription of order depth and avoid the establishment of the listening of multiple sockets 35 | -------------------------------------------------------------------------------- /websocket_api.md: -------------------------------------------------------------------------------- 1 | # WebSocket API 2 | 3 | **WebSocket**是一种在TCP连接上进行通讯的协议。WebSocket通信协议于2011年被[IETF](https://zh.wikipedia.org/wiki/Internet_Engineering_Task_Force)定为标准RFC 6455,并由RFC7936补充规范。 4 | 5 | WebSocket使得客户端和服务器之间的数据交换变得更加简单,允许服务端主动向客户端推送数据。在WebSocket API中,浏览器和服务器只需要完成一次握手,两者之间就直接可以创建持久性的连接,并进行双向数据传输。参见[WebSocket](https://zh.wikipedia.org/wiki/WebSocket)详细介绍。 6 | 7 | 本协议描述Hotbit交易系统对外提供的WebSocket API接口,大致可分为三类: 8 | 9 | - 系统接口:用于客户端发送心跳、获取交易系统时间、用户验证等操作。 10 | - 交易数据查询接口:提供K线、行情、市场状态、成交和定单数据的条件查询。 11 | - 订阅/取消订阅接口:包括行情、成交、K线和市场状态等数据的订阅和取消订阅接口。调用订阅接口以后,交易系统会持续推送数据到客户端,直到客户端调用相应的取消订阅接口。 12 | 13 | **_注意:websocket 反馈数据采取zlib压缩算法进行压缩_** 14 | 15 | ## 请求地址 16 | 17 | - wss://ws.hotbit.io 18 | 19 | ## 请求数据格式 20 | 21 | WebSocket请求分为三部分 22 | 23 | | 字 段 | 字段类型 | 描述 | 24 | | ------ | ---------- | ---- | 25 | | method | String | API的方法名 | 26 | | params | Json Array | API的参数数组,可以为空数组,但不能为null | 27 | | id | Integer | 详细描述见下面说明 | 28 | 29 | **说明**: 30 | 31 | - 没有包含"id"成员的请求对象为通知,服务端不回复一个通知。 32 | - 如果id成员存在,必须为一个无符号的整形数值,表示本次请求的标识码,远程返回时数据的标识码应该与本次请求标识码相同。 33 | 34 | 请求示例1: 35 | 36 | ``` 37 | { 38 | "method":kline.query, 39 | "params":[ 40 | "BTCBCC", 41 | 145231637, 42 | 145232657, 43 | 5 44 | ], 45 | "id":100 46 | } 47 | ``` 48 | 49 | 请求示例2: 50 | 51 | ``` 52 | { 53 | "method":"server.ping", 54 | "params":[], 55 | "id":100 56 | } 57 | ``` 58 | 59 | ## 应答数据格式 60 | 61 | 应答同样也分为三个部分 62 | 63 | | 字段 | 字段类型 | 描述 | 64 | | ------ | ----------- | ------------------------------- | 65 | | result | json object | API调用结果,结果出错时为null。 | 66 | | error | json object | API调用错误内容,正确时为null。 | 67 | | id | request id | integer | 68 | 69 | 结果正确示例: 70 | 71 | ``` 72 | { 73 | "error":null, 74 | "result":[.........], 75 | "id":100 76 | } 77 | ``` 78 | 79 | 结果错误示例: 80 | 81 | ``` 82 | { 83 | "error":{ 84 | "code": 1, 85 | "message":"invalid argument" 86 | }, 87 | "result":null, 88 | "id":100 89 | } 90 | ``` 91 | 92 | 93 | # API Reference 94 | 95 | ## 系统接口 96 | 97 | ### 发送心跳 98 | 99 | 请求 100 | 101 | - method: server.ping 102 | - params: [] 103 | 104 | 示例: 105 | 106 | ``` 107 | { 108 | "method":"server.ping", 109 | "params":[], 110 | "id":100 111 | } 112 | ``` 113 | 114 | 响应: 115 | 116 | ``` 117 | { 118 | "error":null, 119 | "result":"pong", 120 | "id":100 121 | } 122 | ``` 123 | 124 | 125 | 126 | ### 获取系统时间 127 | 128 | 请求 129 | 130 | - method: system.time 131 | - params: [] 132 | 133 | 示例: 134 | 135 | ``` 136 | { 137 | "method":"server.time", 138 | "params":[], 139 | "id":100 140 | } 141 | ``` 142 | 143 | 144 | 145 | 响应: 146 | 147 | ``` 148 | { 149 | "error":null, 150 | "result":1511941406, 151 | "id":100 152 | } 153 | ``` 154 | 155 | 156 | 157 | ### 用户验证 158 | 159 | 请求 160 | 161 | - method: server.auth 162 | - params: 163 | 164 | 请求参数: 165 | 166 | | 参数名 | 参数类型 | 必填 | 描述 | 167 | | ------- | -------- | ---- | ----------- | 168 | | api_key | String | 是 | 用户api_key | 169 | | sign | String | 是 | 签名值 | 170 | 171 | 示例: 172 | 173 | ``` 174 | { 175 | "method":"server.auth", 176 | "params":[api_key,sign], 177 | "id":100 178 | } 179 | ``` 180 | 181 | 响应: 182 | 183 | ``` 184 | { 185 | "error": null, 186 | "result": { 187 | "status": "success" 188 | }, 189 | "id": 100 190 | } 191 | ``` 192 | 193 | 194 | 195 | ## 查询接口 196 | 197 | ### K线数据查询 198 | 199 | - method: kline.query 200 | - params: 201 | 202 | 请求参数: 203 | 204 | | 参数名 | 参数类型 | 必填 | 描述 | 205 | | -------- | -------- | ---- | ------------ | 206 | | market | String | 是 | 市场名 | 207 | | start | Integer | 是 | 开始时间 | 208 | | end | Integer | 是 | 结束时间 | 209 | | interval | Integer | 是 | 数据获取周期 | 210 | 211 | 示例: 212 | 213 | ``` 214 | { 215 | "method":"kline.query", 216 | "params":["EOSETH",145231637,145232657,5], 217 | "id":100 218 | } 219 | ``` 220 | 221 | 返回值: 222 | 223 | ``` 224 | { 225 | "error": null, 226 | "result": [ 227 | [ 228 | 1525798800, # 时间戳 229 | "0.00001790", # 开盘价 230 | "0.00001881", # 收盘价 231 | "0.00001886", # 最高价 232 | "0.00001790", # 最低价 233 | "169033000", # 成交量 234 | "3025.69", # 成交额 235 | "ACATETH" # 交易对市场名称 236 | ], 237 | ...], 238 | "id": 123 239 | } 240 | ``` 241 | 242 | ### 最新价格查询 243 | 244 | - method: price.query 245 | - params: ["market_name"] 246 | 247 | 示例: 248 | 249 | ``` 250 | { 251 | "method":"price.query", 252 | "params":["BTCBCC"], 253 | "id":100 254 | } 255 | ``` 256 | 257 | 响应: 258 | 259 | ``` 260 | { 261 | "error": null, 262 | "result": "8000.00000000", 263 | "id": 100 264 | } 265 | ``` 266 | 267 | ### 当前市场状态查询 268 | 269 | - method: state.query 270 | - params: 271 | 272 | 请求参数: 273 | 274 | | 参数名 | 参数类型 | 必填 | 描述 | 275 | | -------- | -------- | ---- | ------------ | 276 | | market list | json array | 是 | 交易对市场名称列表 | 277 | | interval | Integer | 是 | 周期,单位:秒,例如:86400表示24小时 | 278 | 279 | 示例: 280 | 281 | ``` 282 | { 283 | "method":"state.query", 284 | "params":["BTCBCC",86400], 285 | "id":100 286 | } 287 | ``` 288 | 289 | 响应: 290 | 291 | ``` 292 | { 293 | "period": 86400, # 周期,单位秒 294 | "last": "8000", # 最新价 295 | "open": "0", # 开盘价 296 | "close": "0", # 收盘价 297 | "high": "0", # 最高价 298 | "low": "0", # 最低价 299 | "volume": "0", # 成交量 300 | "deal": "0" # 成交额 301 | }, 302 | ``` 303 | 304 | ### 当天的市场状态查询 305 | 306 | **该接口查询自然日的市场状态,例如当前时间是2017-12-20 14:21:35,调用该接口返回的是2017-12-20这一天的数据,这点和state.query接口不同,state.query返回的是指定时间内的数据,可以跨自然日** 307 | 308 | - method: today.query 309 | - params: 310 | 311 | 312 | 请求参数: 313 | 314 | | 参数名 | 参数类型 | 必填 | 描述 | 315 | | ------ | -------- | ---- | ------ | 316 | | market | String | 是 | 市场名 | 317 | 318 | 示例: 319 | 320 | ``` 321 | { 322 | "method":"today.query", 323 | "params":["BTCBCC"], 324 | "id":100 325 | } 326 | ``` 327 | 328 | 响应: 329 | 330 | ``` 331 | { 332 | "last": "8000", # 最新价 333 | "open": "0", # 开盘价 334 | "close": "0", # 收盘价 335 | "high": "0", # 最高价 336 | "low": "0", # 最低价 337 | "volume": "0", # 成交量 338 | "deal": "0" # 成交额 339 | }, 340 | ``` 341 | 342 | ### 用户成交查询 343 | 344 | - method: deals.query 345 | - params: 346 | 347 | 请求参数: 348 | 349 | | 参数名 | 参数类型 | 必填 | 描述 | 350 | | -------- | -------- | ---- | ------------------------------------------------------------ | 351 | | market | String | 是 | 市场名 | 352 | | limit | Integer | 是 | 最大返回数量 | 353 | | last\_id | integer | 是 | 从最近一个订单id开始往前(id从大到小)最后一个id,例如一共有1,2,3,4,5,一共5个id,last\_id设为3,limit即使设为5也只返回id为4,5两组数据。 | 354 | 355 | 请求: 356 | 357 | ``` 358 | { 359 | "method":"deals.query", 360 | "params":["BTCBCC",5,1], 361 | "id":100 362 | } 363 | ``` 364 | 365 | 响应: 366 | 367 | ``` 368 | { 369 | "error": null, 370 | "result": [ 371 | { "id": 26, "time": 1512454847.188796, "price": "8000", "amount": "1", "type": "buy" }, 372 | { "id": 25, "time": 1512445625.751971, "price": "8000", "amount": "0.125", "type": "buy" }, 373 | { "id": 24, "time": 1512442938.956193, "price": "8000", "amount": "0.125", "type": "buy" }, 374 | { "id": 23, "time": 1512442929.0405071, "price": "8000", "amount": "0.125", "type": "buy" }, 375 | { "id": 22, "time": 1512442927.2021289, "price": "8000", "amount": "0.125", "type": "buy" } ], 376 | "id": 100 377 | } 378 | ``` 379 | 380 | 返回值说明: 381 | 382 | ``` 383 | "result": [ 384 | { 385 | "id": 26, # deal_id 386 | "time": 1512454847.188796, # 交易时间 387 | "price": "8000", # 交易价格 388 | "amount": "1", # 成交数量 389 | "type": "buy" # 成交类型 390 | }, 391 | ...... ] 392 | ``` 393 | 394 | ### 定单深度查询 395 | 396 | - method: depth.query 397 | - params: 398 | 399 | 请求参数: 400 | 401 | | 参数名 | 参数类型 | 必填 | 描述 | 402 | | ------------ | -------- | ---- | ----- | 403 | | market | String | 是 | 市场名 | 404 | | limit | Integer | 是 | 最大返回数量 | 405 | | **interval** | String | 是 | 精度,比如"0.001",获取的数据就是:12.975这样的数字。再比如"5",就会得到"15" "20" "10" 这样的数字。 | 406 | 407 | 示例: 408 | 409 | ``` 410 | { 411 | "method":"depth.query", 412 | "params":["EOSUSDT",100,"1"], 413 | "id":100 414 | } 415 | ``` 416 | 417 | 响应: 418 | 419 | ``` 420 | { 421 | "error": null, 422 | "result": { "asks": [[ "8000", "20"] ], "bids": [[ "800", "4"] ] }, 423 | "id": 100 424 | } 425 | ``` 426 | 427 | 返回结果: 428 | 429 | ``` 430 | "result": { 431 | "asks": [ [ "8000", "20" ] ], 432 | "bids": [ ["800", "4"] ] 433 | } 434 | ``` 435 | 436 | ### 用户未完成定单查询 437 | 438 | **Order API 调用需要auth认证,请先调用server.auth方法请求认证,然后再调用。** 439 | - method: order.query 440 | - params: 441 | 442 | 请求参数: 443 | 444 | | 参数名 | 参数类型 | 必填 | 描述 | 445 | | ------ | -------- | ---- | -------------------- | 446 | | market list | list | 是 | 市场名列表,如果为空的话,返回所有市场的数据| 447 | | offset | Integer | 是 | offset | 448 | | limit | Integer | 是 | 最大返回数量,小于101 | 449 | 450 | 451 | 示例: 452 | 453 | ``` 454 | { 455 | "method":"order.query", 456 | "params":[["BTCBCC","BTCETH"],0,50], 457 | "id":100 458 | } 459 | 或 460 | { 461 | "method":"order.query", 462 | "params":[[],0,50], 463 | "id":100 464 | } 465 | ``` 466 | 467 | 响应: 468 | 469 | ``` 470 | { 471 | "error": null, 472 | "result": { "limit": 50, "offset": 0, "total": 0, "records": [] }, 473 | "id": 100 474 | } 475 | ``` 476 | 477 | 返回值说明: 478 | 479 | ``` 480 | { 481 | "error": null, 482 | "result": { 483 | "ACATETH": { 484 | "limit": 100, 485 | "offset": 0, 486 | "total": 3, 487 | "records": [ 488 | { 489 | "id": 8675864, # 定单ID 490 | "market": "ACATETH", # 市场名称 491 | "type": 1, # 定单类型 1-限价单 2-市价单 492 | "side": 1, # 买卖方向 1-ASK 2-Bid 493 | "user": 15731, # 用户ID 494 | "ctime": 1524482296.075341, # 定单创建时间 495 | "mtime": 1524482296.075341, # 定单修改时间 496 | "price": "0.00001899", # 价格 497 | "amount": "1", # 数量 498 | "taker_fee": "0", # taker的费率 499 | "maker_fee": "0", # maker的费率 500 | "left": "1", # 剩余未成交量 501 | "deal_stock": "0e-8", # 成交量 502 | "deal_money": "0e-16", # 成交金额 503 | "deal_fee": "0e-12" # 成交费用 504 | }, 505 | ... 506 | ] 507 | }, 508 | ……, 509 | "SPHTXBTC":{……} 510 | } 511 | "id": 13 512 | } 513 | ``` 514 | 515 | ### 用户已完成定单查询 516 | 517 | - method: order.history 518 | - params: 519 | 520 | 请求参数: 521 | 522 | | 参数名 | 参数类型 | 必填 | 描述 | 523 | | ----------- | -------- | ---- | -------------------- | 524 | | market | String | 是 | 市场名 | 525 | | start\_time | Integer | 是 | 开始时间 | 526 | | end\_time | Integer | 是 | 结束时间 | 527 | | offset | Integer | 是 | offset | 528 | | limit | Integer | 是 | 最大返回数量,小于101 | 529 | 530 | 示例: 531 | 532 | ``` 533 | { 534 | "method":"order.history", 535 | "params":["BTCBCC",1511941006,1511941406,0,50], 536 | "id":100} 537 | ``` 538 | 539 | 响应: 540 | 541 | ``` 542 | { 543 | "error": null, 544 | "result": { "limit": 50, "offset": 0, "total": 0, "records": [] }, 545 | "id": 100 546 | } 547 | ``` 548 | 549 | **返回值:参考order.query方法返回值。** 550 | 551 | ### 用户资产查询 552 | 553 | **调用需要auth认证,请先调用server.auth方法请求认证,然后再调用。** 554 | 555 | - method: asset.query 556 | - params: [] 557 | 558 | 示例: 559 | 560 | ``` 561 | { 562 | "method":"asset.query", 563 | "params":["ETH","BTC"], 564 | "id":100 565 | } 566 | ``` 567 | 568 | 响应: 569 | 570 | ``` 571 | { 572 | "error": null, 573 | "result": { 574 | "ETH": { 575 | "available": "0", # 可用资金 576 | "freeze": "0" # 冻结资金 577 | }, 578 | "BTC": { "available": "0", "freeze": "0" } 579 | }, 580 | "id": 100 581 | } 582 | ``` 583 | 584 | 请求参数:asset list。 585 | 586 | 返回值:参考上面示例。 587 | 588 | 589 | ### 用户资产变动历史查询 590 | 591 | - method: asset.history 592 | - params: 593 | 594 | 请求参数: 595 | 596 | | 参数名 | 参数类型 | 必填 | 描述 | 597 | | ----------- | -------- | ---- | ----------------------------- | 598 | | asset | String | 是 | asset name, which can be null | 599 | | business | String | 是 | 业务名 | 600 | | start\_time | Integer | 是 | 开始时间 | 601 | | end\_time | Integer | 是 | 结束时间 | 602 | | offset | Integer | 是 | offset | 603 | | limit | Integer | 是 | 最大返回数量,小于101 | 604 | 605 | 示例: 606 | 607 | ``` 608 | { 609 | "method":"asset.history", 610 | "params":["BTC","deposit",1501940406,1513328112,0,100], 611 | "id":100 612 | } 613 | ``` 614 | 615 | 响应: 616 | 617 | ``` 618 | { 619 | "error": null, 620 | "result": { 621 | "offset": 0, 622 | "limit": 100, 623 | "records": [ 624 | { 625 | "time": 1511856143.3754101, # 时间戳 626 | "asset": "USD", # 资产类型 627 | "business":"deposit", # 业务标识 deposit-充值,freeze-冻结/解冻,withdraw-提币 628 | "change": "100000", # 变动金额 629 | "balance": "300000", # 变动后用户资金余额 630 | "detail": { "id": 10003 } # 其他详情 631 | }, 632 | ... 633 | ] 634 | }, 635 | "id": 100 636 | } 637 | ``` 638 | 639 | ## 订阅/取消订阅接口 640 | 641 | 642 | ### 行情订阅 643 | 644 | - method: kline.subscribe 645 | - params: 646 | 647 | 请求参数: 648 | 649 | | 参数名 | 参数类型 | 必填 | 描述 | 650 | | -------- | -------- | ---- | ------------ | 651 | | market | String | 是 | 市场名 | 652 | | interval | Integer | 是 | 数据获取周期 | 653 | 654 | 示例: 655 | 656 | ``` 657 | { 658 | "method":"kline.subscribe", 659 | "params":[ "BTCBCC", 60 ], 660 | "id":100 661 | } 662 | ``` 663 | 664 | 响应: 665 | 666 | ``` 667 | { 668 | "error": null, 669 | "result": { "status": "success" }, 670 | "id": 100 671 | } 672 | ``` 673 | 674 | 订阅成功后,订阅数据将会被推送到客户端。内容如 **[行情推送]** 所述。 675 | 676 | ### 行情推送 677 | 678 | 示例: 679 | 680 | ``` 681 | { 682 | "method": "kline.update", 683 | "params": [[1513135140, "8000", "8000", "8000", "8000", "0", "0", "BTCBCC"]], 684 | "id": null 685 | } 686 | ``` 687 | 688 | 参数说明: 689 | 690 | ``` 691 | "params": [ 692 | [ 693 | 1492358400, # 时间戳 694 | "7000.00", # 开盘价 695 | "8000.0", # 收盘价 696 | "8100.00", # 最高价 697 | "6800.00", # 最低价 698 | "1000.00" # 成交量 699 | "123456.00", # 成交金额 700 | "BTCBCC" # 交易币对市场名称 701 | ] 702 | ] 703 | ``` 704 | 705 | ### 取消行情订阅 706 | 707 | - method: kline.unsubscribe 708 | - params: [] 709 | 710 | 示例: 711 | 712 | ``` 713 | { 714 | "method":"kline.unsubscribe", 715 | "params":[], 716 | "id":100 717 | } 718 | ``` 719 | 720 | 响应: 721 | 722 | ``` 723 | { 724 | "error": null, 725 | "result": {"status": "success"}, 726 | "id": 100 727 | } 728 | ``` 729 | 730 | ### 最新价订阅 731 | 732 | - method: price.subscribe 733 | - params: 734 | 735 | 请求参数: 736 | 737 | | 参数名 | 参数类型 | 必填 | 描述 | 738 | | -------- | -------- | ---- | ------------ | 739 | | market | String | 是 | 市场名 | 740 | 741 | 请求 742 | 743 | ``` 744 | { 745 | "method":"price.subscribe", 746 | "params":["BTCBCC"], 747 | "id":100 748 | } 749 | ``` 750 | 751 | 响应 752 | 753 | ``` 754 | { 755 | "error": null, 756 | "result": { "status": "success" }, 757 | "id": 100 758 | } 759 | ``` 760 | 761 | ### 最新价推送 762 | 763 | **订阅成功后,向客户端主动推送数据内容。** 764 | 765 | - method: price.update 766 | 767 | 示例 768 | 769 | ``` 770 | { 771 | "method": "price.update", 772 | "params": ["BTCBCC", "8000.00000000"], 773 | "id": null 774 | } 775 | ``` 776 | 777 | 参数说明: 778 | 779 | ``` 780 | "params": [ 781 | "BTCBCC", # 市场名称 782 | "8000.00000000" # 最新价格 783 | ] 784 | ``` 785 | 786 | ### 取消最新价订阅 787 | 788 | - method: price.unsubscribe 789 | - params: [] 790 | 791 | 示例: 792 | 793 | ``` 794 | { 795 | "method":"price.unsubscribe", 796 | "params":[], 797 | "id":100 798 | } 799 | ``` 800 | 801 | 响应 802 | 803 | ``` 804 | { 805 | "error": null, 806 | "result": { "status": "success" }, 807 | "id": 100 808 | } 809 | ``` 810 | 811 | ### 市场状态订阅 812 | 813 | **24小时市场状态订阅。** 814 | 815 | - method: state.subscribe 816 | - params: 交易币对市场名称列表 817 | 818 | 请求 819 | 820 | ``` 821 | { 822 | "method":"state.subscribe", 823 | "params":["BTCBCC","BTCUSD"], 824 | "id":100 825 | } 826 | ``` 827 | 828 | 响应 829 | 830 | ``` 831 | { 832 | "error": null, 833 | "result": { "status": "success" }, 834 | "id": 100 835 | } 836 | ``` 837 | 838 | ### 市场状态推送 839 | 840 | **订阅成功后,状态数据会被交易服务器推送给客户端。** 841 | 842 | - method: state.update 843 | 844 | 示例: 845 | 846 | ``` 847 | { 848 | "method": "state.update", 849 | "params": [ 850 | "BTCBCC", { 851 | "period": 86400, 852 | "last": "8000", 853 | "open": "0", 854 | "close": "0", 855 | "high": "0", 856 | "low": "0", 857 | "volume": "0", 858 | "deal": "0" 859 | } 860 | ], 861 | "id": null 862 | } 863 | ``` 864 | 865 | 返回值参考state.query方法。 866 | 867 | ### 取消市场状态推送 868 | 869 | - method: state.unsubscribe 870 | - params: [] 871 | 872 | 请求 873 | 874 | ``` 875 | { 876 | "method":"state.unsubscribe", 877 | "params":[], 878 | "id":100 879 | } 880 | ``` 881 | 882 | 响应 883 | 884 | ``` 885 | { 886 | "error": null, 887 | "result": { "status": "success" }, 888 | "id": 100 889 | } 890 | ``` 891 | 892 | ### 当日市场状态订阅 893 | 894 | **当天market状态订阅。** 895 | 896 | - method: today.subscribe 897 | - params: 898 | 899 | 请求参数: 900 | 901 | | 参数名 | 参数类型 | 必填 | 描述 | 902 | | ----------- | -------- | ---- | ---------- | 903 | | market list | String | 是 | 市场名列表 | 904 | 905 | 请求 906 | 907 | ``` 908 | { 909 | "method":"today.subscribe", 910 | "params":["BTCUSD","BTCBCC"], 911 | "id":100 912 | } 913 | ``` 914 | 915 | 响应 916 | 917 | ``` 918 | { 919 | "error": null, 920 | "result": { "status": "success" }, 921 | "id": 100 922 | } 923 | ``` 924 | 925 | ### 当日市场状态推送 926 | 927 | 订阅成功后,服务器主动向客户端推送数据。 928 | 929 | - method: today.update 930 | 931 | 示例 932 | 933 | ``` 934 | { 935 | "method": "today.update", 936 | "params": [ 937 | "BTCBCC", { 938 | "open": "8000", 939 | "last": "8000", 940 | "high": "8000", 941 | "low": "8000", 942 | "volume": "0", 943 | "deal": "0" 944 | } 945 | ], 946 | "id": null 947 | } 948 | ``` 949 | 950 | 返回值参考state.query方法。 951 | 952 | ### 取消当日市场状态订阅 953 | 954 | - method: today.unsubscribe 955 | - params: [] 956 | 957 | 请求 958 | 959 | ``` 960 | { 961 | "method":"today.unsubscribe", 962 | "params":[], 963 | "id":100 964 | } 965 | ``` 966 | 967 | 响应 968 | 969 | ``` 970 | { 971 | "error": null, 972 | "result": { "status": "success" }, 973 | "id": 100 974 | } 975 | ``` 976 | 977 | ### 成交订阅 978 | 979 | - method: deals.subscribe 980 | - params: 交易币对市场名称列表 981 | 982 | 请求 983 | 984 | ``` 985 | { 986 | "method":"deals.subscribe", 987 | "params":["BTCBCC","BTCUSD"], 988 | "id":100 989 | } 990 | ``` 991 | 992 | 响应 993 | 994 | ``` 995 | { 996 | "error": null, 997 | "result": { "status": "success" }, 998 | "id": 100 999 | } 1000 | ``` 1001 | 1002 | ### 成交推送 1003 | 1004 | 示例: 1005 | 1006 | ``` 1007 | { 1008 | "method": "deals.update", 1009 | "params": [ 1010 | "BTCBCC", [ 1011 | {"id": 26, "time": 1512454847.188796, "price": "8000", "amount": "1", "type": "buy"}, 1012 | {"id": 25, "time": 1512445625.751971, "price": "8000", "amount": "0.125", "type": "buy"}, 1013 | {"id": 24, "time": 1512442938.956193, "price": "8000", "amount": "0.125", "type": "buy"}, 1014 | ... 1015 | {"id": 22, "time": 1512442927.2021289, "price": "8000", "amount": "0.125", "type": "buy"}, 1016 | {"id": 3, "time": 1512442109.0283101, "price": "8000", "amount": "0.125", "type": "buy"}, 1017 | {"id": 2, "time": 1512441964.500567, "price": "8000", "amount": "0.125", "type": "buy"}, 1018 | {"id": 1, "time": 1512441751.9356339, "price": "8000", "amount": "0.125", "type": "buy"} 1019 | ] 1020 | ], 1021 | "id": null 1022 | } 1023 | ``` 1024 | 1025 | 参考deals.query的返回结果。 1026 | 1027 | ### 取消成交订阅 1028 | 1029 | - method: deals.unsubscribe 1030 | - params: [] 1031 | 1032 | 请求 1033 | 1034 | ``` 1035 | { 1036 | "method":"deals.unsubscribe", 1037 | "params":[], 1038 | "id":100 1039 | } 1040 | ``` 1041 | 1042 | 响应 1043 | 1044 | ``` 1045 | { 1046 | "error": null, 1047 | "result": { "status": "success" }, 1048 | "id": 100 1049 | } 1050 | ``` 1051 | 1052 | #### 定单深度订阅 1053 | 1054 | - method: depth.subscribe 1055 | - params: 1056 | 1057 | 请求参数: 1058 | 1059 | ``` 1060 | "params":[ 1061 | "BTCBCC", # 市场名 1062 | 100, # 定单价格,取值:1, 5, 10, 20, 30, 50, 100 1063 | "0.0001" # 价格区间精度, 取值:"0","0.00000001","0.0000001","0.000001","0.00001", 1064 | # "0.0001", "0.001", "0.01", "0.1" 1065 | ] 1066 | ``` 1067 | 1068 | 请求 1069 | 1070 | ``` 1071 | { 1072 | "method":"depth.subscribe", 1073 | "params":["EOSUSDT",100,"0.1"], 1074 | "id":100 1075 | } 1076 | ``` 1077 | 1078 | 响应 1079 | 1080 | ``` 1081 | { 1082 | "error": null, 1083 | "result": { "status": "success" }, 1084 | "id": 100 1085 | } 1086 | ``` 1087 | 1088 | #### 定单批量深度订阅 1089 | 1090 | - method: depths.subscribe 1091 | - params: 1092 | 1093 | 请求参数: 1094 | 1095 | ``` 1096 | "params":[[ 1097 | "ETCBTC", # 市场名 1098 | 100, # 定单价格,取值:1, 5, 10, 20, 30, 50, 100 1099 | "0.0001" # 价格区间精度, 取值:"0","0.00000001","0.0000001","0.000001","0.00001", 1100 | # "0.0001", "0.001", "0.01", "0.1" 1101 | ],[ 1102 | "BTCBCC", # 市场名 1103 | 100, # 定单价格,取值:1, 5, 10, 20, 30, 50, 100 1104 | "0.0001" # 价格区间精度, 取值:"0","0.00000001","0.0000001","0.000001","0.00001", 1105 | # "0.0001", "0.001", "0.01", "0.1" 1106 | ]] 1107 | ``` 1108 | 1109 | 请求 1110 | 1111 | ``` 1112 | { 1113 | "method":"depths.subscribe", 1114 | "params":[["ETCUSDT",100,"0.1"],["EOSUSDT",100,"0.1"]], 1115 | "id":100 1116 | } 1117 | ``` 1118 | 1119 | 响应 1120 | 1121 | ``` 1122 | { 1123 | "error": null, 1124 | "result": { "status": "success" }, 1125 | "id": 100 1126 | } 1127 | ``` 1128 | 1129 | ### 定单深度数据推送 1130 | 1131 | - method: depth.update 1132 | 1133 | 示例: 1134 | 1135 | ``` 1136 | { 1137 | "method": "depth.update", 1138 | "params": [true, {"asks": [["8000", "20"]], "bids": [["800", "4"]]}, "BTCBCC"], 1139 | "id": null 1140 | } 1141 | ``` 1142 | 1143 | 返回结果说明: 1144 | 1145 | 以价格区间精度为0.1为例。 1146 | 1147 | ``` 1148 | "params": [ 1149 | true, #clean: Boolean, true: complete result,false: last returned updated result 1150 | { 1151 | "asks": [ 1152 | [ 1153 | "8000", # 价格 1154 | "20" # 数量 1155 | ], 1156 | [ 1157 | "8000.1", # 价格 1158 | "20" # **价格≥8000,小于8000.1的所有定单数量和之和** 1159 | ] 1160 | ], 1161 | "bids": 1162 | [ 1163 | [ 1164 | "800", 1165 | "4" 1166 | ], 1167 | [ 1168 | "800.1", 1169 | "5" 1170 | ] 1171 | ] 1172 | }, 1173 | "BTCBCC" # 交易币对的市场名称 1174 | ] 1175 | ``` 1176 | 1177 | ### 取消定单深度订阅 1178 | 1179 | - method: depth.unsubscribe 1180 | - params: [] 1181 | 1182 | 请求 1183 | 1184 | ``` 1185 | { 1186 | "method":"depth.unsubscribe", 1187 | "params":[], 1188 | "id":100 1189 | } 1190 | ``` 1191 | 1192 | 响应 1193 | 1194 | ``` 1195 | { 1196 | "error": null, 1197 | "result": { "status": "success" }, 1198 | "id": 100 1199 | } 1200 | ``` 1201 | 1202 | ### 用户定单状态订阅 1203 | 1204 | - method: order.subscribe 1205 | - params: 市场名称列表 1206 | 1207 | 请求 1208 | 1209 | ``` 1210 | { 1211 | "method":"order.subscribe", 1212 | "params":["BTCBCC","BTCETH"], 1213 | "id":100 1214 | } 1215 | ``` 1216 | 1217 | 响应 1218 | 1219 | ``` 1220 | { 1221 | "error": null, 1222 | "result": { "status": "success" }, 1223 | "id": 100 1224 | } 1225 | ``` 1226 | 1227 | ### 用户定单变化推送 1228 | 1229 | **定单的每次状态变化都会推送给用户端** 1230 | 1231 | 示例: 1232 | 1233 | ``` 1234 | { 1235 | "method": "order.update", 1236 | "params": [ 1237 | 1, # 定单状态变化事件类型,整数值 1-新定单, 2-更新定单, 3-完全成交 1238 | { 1239 | "id": 422458, 1240 | "market": "BTCBCC", 1241 | "source": "", 1242 | "type": 1, # 1-limit order 2 -market order 1243 | "side": 1, # 1-Ask 2-Bid 1244 | "user": 5, 1245 | "ctime": 1513819599.987308, # create_time 1246 | "mtime": 1513819599.987308, # update_time 1247 | "price": "8000", 1248 | "amount": "10", 1249 | "taker_fee": "0.002", 1250 | "maker_fee": "0.001", 1251 | "left": "10", 1252 | "deal_stock": "0", 1253 | "deal_money": "0", 1254 | "deal_fee": "0" } 1255 | ], 1256 | "id": 102 1257 | } 1258 | ``` 1259 | 1260 | 定单的详细字段说明参考order.query。 1261 | 1262 | ### 取消定单状态变化订阅 1263 | 1264 | - method: order.unsubscribe 1265 | - params: [] 1266 | 1267 | 请求 1268 | 1269 | ``` 1270 | { 1271 | "method":"order.unsubscribe", 1272 | "params":[], 1273 | "id":100 1274 | } 1275 | ``` 1276 | 1277 | 响应 1278 | 1279 | ``` 1280 | { 1281 | "error": null, 1282 | "result": { "status": "success" }, 1283 | "id": 100 1284 | } 1285 | ``` 1286 | 1287 | ### 用户资产信息订阅 1288 | 1289 | - method: asset.subscribe 1290 | - params: 资产名称列表 1291 | 1292 | 请求 1293 | 1294 | ``` 1295 | { 1296 | "method":"asset.subscribe", 1297 | "params":["BTC","ETH","BCC"], 1298 | "id":100 1299 | } 1300 | ``` 1301 | 1302 | 响应 1303 | 1304 | ``` 1305 | { 1306 | "error": null, 1307 | "result": { "status": "success" }, 1308 | "id": 100 1309 | } 1310 | ``` 1311 | 1312 | ### 用户资产变化信息推送 1313 | 1314 | - method: asset.update 1315 | 1316 | 示例: 1317 | 1318 | ``` 1319 | { 1320 | "method": "asset.update", 1321 | "params": { 1322 | "ETH": { "available": "0", "freeze": "0" }, 1323 | "BTC": { "available": "0", "freeze": "0" } 1324 | }, 1325 | "id": 100 1326 | } 1327 | ``` 1328 | 1329 | ### 用户资产信息订阅 1330 | 1331 | - method: asset.unsubscribe 1332 | 1333 | 请求 1334 | 1335 | ``` 1336 | { 1337 | "method":"asset.unsubscribe", 1338 | "params":[], 1339 | "id":100 1340 | } 1341 | ``` 1342 | 1343 | 响应 1344 | 1345 | ``` 1346 | { 1347 | "error": null, 1348 | "result": { "status": "success" }, 1349 | "id": 100 1350 | } 1351 | ``` 1352 | -------------------------------------------------------------------------------- /websocket_api_en.md: -------------------------------------------------------------------------------- 1 | # WebSocket API 2 | 3 | **WebSocket** is a type of protocol that conducts communication on TCP connection. WebSocket communication protocol is defined as standard RFC 6455 by [IETF](https://zh.wikipedia.org/wiki/Internet_Engineering_Task_Force) in 2011, and is complemented and standardized by RFC7936. 4 | 5 | WebSocket makes the data exchange between client end and server become more simple, and allows server end to actively push data to client end. In WebSocket API,by finishing one handshake only, a permanent connection can be directly established between browser and server, which also enables two-way data communication. Please refer to [WebSocket](https://zh.wikipedia.org/wiki/WebSocket) for detailed introduction. 6 | 7 | This protocol describes the WebSocket API interface that Hotbit trading system provides for external users, which can generally be categorized into three types: 8 | 9 | - System interface: used for operations of client end, such as sending HeartBeat, obtain the time of trading system and user verification etc. 10 | - Trading data inquiry interface: provides criteria queries of K Chart, market trend, market status, order settlement and number of orders. 11 | - Subscribe/unsubscribe interface: includes the subscription and unsubscription of the interfaces such as the interfaces of market trend, order settlement, K Chart and market status etc. After calling subscribed interface, the trading system will continuously push data to client end, until the client end calls relevant interface to cancel the subscription. 12 | 13 | **_Note:websocket feedback data is compressed by zlib compression algorithm_** 14 | 15 | ## Request Address 16 | 17 | - wss://ws.hotbit.io 18 | 19 | ## Request Data Format 20 | 21 | WebSocket request is divided into three sections 22 | 23 | | Field | Type of Field | Description | 24 | | ------ | ---------- | ---- | 25 | | method | String | Name of API Method | 26 | | params | Json Array | The array of API parameter can be empty, but cannot be null| 27 | | id | Integer | Please refer to the following instruction for detailed description | 28 | 29 | **Description**: 30 | 31 | - The requested object that does not include "id" member is notice, the server end does not reply to a notice. 32 | - If id member exists, it must be an integer value with no symbol that represents the identifier of the request. During the remote return process, the identifier of the data shall be the same as the identifier of the request. 33 | 34 | Request Example 1: 35 | 36 | ``` 37 | { 38 | "method":kline.query, 39 | "params":[ 40 | "BTCBCC", 41 | 145231637, 42 | 145232657, 43 | 5 44 | ], 45 | "id":100 46 | } 47 | ``` 48 | 49 | Request Exmaple 2: 50 | 51 | ``` 52 | { 53 | "method":"server.ping", 54 | "params":[], 55 | "id":100 56 | } 57 | ``` 58 | 59 | ## Format of Response Data 60 | 61 | The response is also divided into three sections 62 | 63 | | Field | Type of Field | Description | 64 | | ------ | ----------- | ------------------------------- | 65 | | result | json object | API result call,when the result is incorrect, it is null。 | 66 | | error | json object | API call for incorrect information,when correct, it is null。 | 67 | | id | request id | integer | 68 | 69 | Example for correct result: 70 | 71 | ``` 72 | { 73 | "error":null, 74 | "result":[.........], 75 | "id":100 76 | } 77 | ``` 78 | 79 | Example for incorrect result: 80 | 81 | ``` 82 | { 83 | "error":{ 84 | "code": 1, 85 | "message":"invalid argument" 86 | }, 87 | "result":null, 88 | "id":100 89 | } 90 | ``` 91 | 92 | 93 | # API Reference 94 | 95 | ## System Interfce 96 | 97 | ### Send HeartBeat 98 | 99 | Request 100 | 101 | - method: server.ping 102 | - params: [] 103 | 104 | Example: 105 | 106 | ``` 107 | { 108 | "method":"server.ping", 109 | "params":[], 110 | "id":100 111 | } 112 | ``` 113 | 114 | Response: 115 | 116 | ``` 117 | { 118 | "error":null, 119 | "result":"pong", 120 | "id":100 121 | } 122 | ``` 123 | 124 | 125 | 126 | ### Obtain System Time 127 | 128 | Request 129 | 130 | - method: system.time 131 | - params: [] 132 | 133 | Example: 134 | 135 | ``` 136 | { 137 | "method":"server.time", 138 | "params":[], 139 | "id":100 140 | } 141 | ``` 142 | 143 | 144 | 145 | Response: 146 | 147 | ``` 148 | { 149 | "error":null, 150 | "result":1511941406, 151 | "id":100 152 | } 153 | ``` 154 | 155 | 156 | 157 | ### User Verification 158 | 159 | Request 160 | 161 | - method: server.auth 162 | - params: 163 | 164 | Request Parameter: 165 | 166 | | Name of Parameter | Type of parameter | Mandatory | Description | 167 | | ------- | -------- | ---- | ----------- | 168 | | api_key | String | Yes | User api_key | 169 | | sign | String | Yes | Signature Value | 170 | 171 | Example: 172 | 173 | ``` 174 | { 175 | "method":"server.auth", 176 | "params":[api_key,sign], 177 | "id":100 178 | } 179 | ``` 180 | 181 | Response: 182 | 183 | ``` 184 | { 185 | "error": null, 186 | "result": { 187 | "status": "success" 188 | }, 189 | "id": 100 190 | } 191 | ``` 192 | 193 | 194 | 195 | ## Inquire Interface 196 | 197 | ### K Chart Data Inquiry 198 | 199 | - method: kline.query 200 | - params: 201 | 202 | Request Parameter: 203 | 204 | | Name of parameter | Type of parameter | Mandatory | Description | 205 | | -------- | -------- | ---- | ------------ | 206 | | market | String | Yes | Name of market | 207 | | start | Integer | Yes | Starting Time | 208 | | end | Integer | Yes | Ending Time | 209 | | interval | Integer | Yes | Period for data obtention | 210 | 211 | Example: 212 | 213 | ``` 214 | { 215 | "method":"kline.query", 216 | "params":["EOSETH",145231637,145232657,5], 217 | "id":100 218 | } 219 | ``` 220 | 221 | Return Value: 222 | 223 | ``` 224 | { 225 | "error": null, 226 | "result": [ 227 | [ 228 | 1525798800, # Timestamp 229 | "0.00001790", # Opening price 230 | "0.00001881", # Closing price 231 | "0.00001886", # Highest price 232 | "0.00001790", # Lowest price 233 | "169033000", # Trading volume 234 | "3025.69", # Turnover 235 | "ACATETH" # The name of transaction pair market 236 | ], 237 | ...], 238 | "id": 123 239 | } 240 | ``` 241 | 242 | ### Inquiry on Latest Price 243 | 244 | - method: price.query 245 | - params: ["market_name"] 246 | 247 | Example: 248 | 249 | ``` 250 | { 251 | "method":"price.query", 252 | "params":["BTCBCC"], 253 | "id":100 254 | } 255 | ``` 256 | 257 | Response: 258 | 259 | ``` 260 | { 261 | "error": null, 262 | "result": "8000.00000000", 263 | "id": 100 264 | } 265 | ``` 266 | 267 | ### Inquiry on Current Market Status 268 | 269 | - method: state.query 270 | - params: 271 | 272 | Request parameter: 273 | 274 | | name of parameter | type of parameter | mandatory | description | 275 | | -------- | -------- | ---- | ------------ | 276 | | market list | json array | yes | The list of the name of transaction pair market | 277 | | interval | Integer | yes | period,unit:second,for example:86400 means 24 hours | 278 | 279 | example: 280 | 281 | ``` 282 | { 283 | "method":"state.query", 284 | "params":["BTCBCC",86400], 285 | "id":100 286 | } 287 | ``` 288 | 289 | response: 290 | 291 | ``` 292 | { 293 | "period": 86400, # period,unit second 294 | "last": "8000", # latest price 295 | "open": "0", # opening price 296 | "close": "0", # closing price 297 | "high": "0", # highest price 298 | "low": "0", # lowest price 299 | "volume": "0", # Trading volume 300 | "deal": "0" # Turnover 301 | }, 302 | ``` 303 | 304 | ### Inquiry on the Market Status of the Day 305 | 306 | **The interface inquires the market status of calendar day,for example, the current time is 2017-12-20 14:21:35,the data returned by calling this interface is the data of the calendar day of 2017-12-20,which is different from state.query interface,the data that state.query return is the data within a designated period of time, which may straddle more than one calendar days.** 307 | 308 | - method: today.query 309 | - params: 310 | 311 | 312 | Request parameter: 313 | 314 | | name of parameter | type of parameter | mandatory | description | 315 | | ------ | -------- | ---- | ------ | 316 | | market | String | yes | market name | 317 | 318 | Example: 319 | 320 | ``` 321 | { 322 | "method":"today.query", 323 | "params":["BTCBCC"], 324 | "id":100 325 | } 326 | ``` 327 | 328 | Response: 329 | 330 | ``` 331 | { 332 | "last": "8000", # Latest price 333 | "open": "0", # Opening price 334 | "close": "0", # Closing price 335 | "high": "0", # Highest price 336 | "low": "0", # Lowest price 337 | "volume": "0", # Trading volume 338 | "deal": "0" # Turnover 339 | }, 340 | ``` 341 | 342 | ### Inquiry on User's Settled Order 343 | 344 | - method: deals.query 345 | - params: 346 | 347 | Request parameter: 348 | 349 | | name of parameter | type of parameter | mandatory | description | 350 | | -------- | -------- | ---- | ------------------------------------------------------------ | 351 | | market | String | yes | market name | 352 | | limit | Integer | yes | Maximum number returned | 353 | | last\_id | integer | yes | the last id from the most recent id to previous id (id from large to small),for example there are 5 id together, namely 1,2,3,4,5, if last\_id is set to be 3,even if limit is set to be 5, only the two groups of data under id 4,5 will be returned. | 354 | 355 | Request: 356 | 357 | ``` 358 | { 359 | "method":"deals.query", 360 | "params":["BTCBCC",5,1], 361 | "id":100 362 | } 363 | ``` 364 | 365 | Response: 366 | 367 | ``` 368 | { 369 | "error": null, 370 | "result": [ 371 | { "id": 26, "time": 1512454847.188796, "price": "8000", "amount": "1", "type": "buy" }, 372 | { "id": 25, "time": 1512445625.751971, "price": "8000", "amount": "0.125", "type": "buy" }, 373 | { "id": 24, "time": 1512442938.956193, "price": "8000", "amount": "0.125", "type": "buy" }, 374 | { "id": 23, "time": 1512442929.0405071, "price": "8000", "amount": "0.125", "type": "buy" }, 375 | { "id": 22, "time": 1512442927.2021289, "price": "8000", "amount": "0.125", "type": "buy" } ], 376 | "id": 100 377 | } 378 | ``` 379 | 380 | Return value description: 381 | 382 | ``` 383 | "result": [ 384 | { 385 | "id": 26, # deal_id 386 | "time": 1512454847.188796, # trading time 387 | "price": "8000", # trading price 388 | "amount": "1", # amount of transaction settled 389 | "type": "buy" # type of transaction settled 390 | }, 391 | ...... ] 392 | ``` 393 | 394 | ### Inquiry on the Depth of Order 395 | 396 | - method: depth.query 397 | - params: 398 | 399 | Request parameter: 400 | 401 | | name of parameter | type of parameter | mandatory | description | 402 | | ------------ | -------- | ---- | ----- | 403 | | market | String | yes | market name | 404 | | limit | Integer | yes | maximum number returned | 405 | | **interval** | String | yes | precision,for example "0.001",the data obtained will be:such number as 12.975. Also, for example "5",will obtain numbers such as "15" "20" "10". | 406 | 407 | Example: 408 | 409 | ``` 410 | { 411 | "method":"depth.query", 412 | "params":["EOSUSDT",100,"1"], 413 | "id":100 414 | } 415 | ``` 416 | 417 | Response: 418 | 419 | ``` 420 | { 421 | "error": null, 422 | "result": { "asks": [[ "8000", "20"] ], "bids": [[ "800", "4"] ] }, 423 | "id": 100 424 | } 425 | ``` 426 | 427 | Result returned: 428 | 429 | ``` 430 | "result": { 431 | "asks": [ [ "8000", "20" ] ], 432 | "bids": [ ["800", "4"] ] 433 | } 434 | ``` 435 | 436 | ### Inquiry on User's Unfinished Orders 437 | 438 | **Order API call requires authentication,please call server.auth method first for the request of authentication,then call.** 439 | - method: order.query 440 | - params: 441 | 442 | Parameter request: 443 | 444 | | name of parameter | type of parameter | mandatory | description | 445 | | ------ | -------- | ---- | -------------------- | 446 | | market list | list | yes | list of market names,if empty,return the data of all markets| 447 | | offset | Integer | yes | offset | 448 | | limit | Integer | yes | Maximum number of return,less than 101 | 449 | 450 | 451 | Example: 452 | 453 | ``` 454 | { 455 | "method":"order.query", 456 | "params":[["BTCBCC","BTCETH"],0,50], 457 | "id":100 458 | } 459 | or 460 | { 461 | "method":"order.query", 462 | "params":[[],0,50], 463 | "id":100 464 | } 465 | ``` 466 | 467 | Response: 468 | 469 | ``` 470 | { 471 | "error": null, 472 | "result": { "limit": 50, "offset": 0, "total": 0, "records": [] }, 473 | "id": 100 474 | } 475 | ``` 476 | 477 | Description on return value: 478 | 479 | ``` 480 | { 481 | "error": null, 482 | "result": { 483 | "ACATETH": { 484 | "limit": 100, 485 | "offset": 0, 486 | "total": 3, 487 | "records": [ 488 | { 489 | "id": 8675864, # Order ID 490 | "market": "ACATETH", # Market Name 491 | "type": 1, # Type of order 1-limit order 2-market order 492 | "side": 1, # Direction of buy and sell 1-ASK 2-Bid 493 | "user": 15731, # User ID 494 | "ctime": 1524482296.075341, # Time of Order establishment 495 | "mtime": 1524482296.075341, # Time of order modification 496 | "price": "0.00001899", # price 497 | "amount": "1", # amount 498 | "taker_fee": "0", # taker fee 499 | "maker_fee": "0", # maker fee 500 | "left": "1", # unsettled amount left 501 | "deal_stock": "0e-8", # settled amount 502 | "deal_money": "0e-16", # Value settled 503 | "deal_fee": "0e-12" # fee settled 504 | }, 505 | ... 506 | ] 507 | }, 508 | ……, 509 | "SPHTXBTC":{……} 510 | } 511 | "id": 13 512 | } 513 | ``` 514 | 515 | ### Inquiry on User's Finished Orders 516 | 517 | - method: order.history 518 | - params: 519 | 520 | request parameter: 521 | 522 | | name of parameter | type of parameter | mandatory | description | 523 | | ----------- | -------- | ---- | -------------------- | 524 | | market | String | yes | market name | 525 | | start\_time | Integer | yes | starting time | 526 | | end\_time | Integer | yes | ending time | 527 | | offset | Integer | yes | offset | 528 | | limit | Integer | yes | maximum number returned, less than101 | 529 | 530 | Example: 531 | 532 | ``` 533 | { 534 | "method":"order.history", 535 | "params":["BTCBCC",1511941006,1511941406,0,50], 536 | "id":100} 537 | ``` 538 | 539 | response: 540 | 541 | ``` 542 | { 543 | "error": null, 544 | "result": { "limit": 50, "offset": 0, "total": 0, "records": [] }, 545 | "id": 100 546 | } 547 | ``` 548 | 549 | **return value:refer to the return value of order.query method.** 550 | 551 | ### Inquiry on User's Asset 552 | 553 | **The call requires authentication,please call the method of server.auth first for authentication request,then call.** 554 | 555 | - method: asset.query 556 | - params: [] 557 | 558 | for example: 559 | 560 | ``` 561 | { 562 | "method":"asset.query", 563 | "params":["ETH","BTC"], 564 | "id":100 565 | } 566 | ``` 567 | 568 | response: 569 | 570 | ``` 571 | { 572 | "error": null, 573 | "result": { 574 | "ETH": { 575 | "available": "0", # available asset 576 | "freeze": "0" # freeze asset 577 | }, 578 | "BTC": { "available": "0", "freeze": "0" } 579 | }, 580 | "id": 100 581 | } 582 | ``` 583 | 584 | request parameter:asset list。 585 | 586 | return value:refer to the example above。 587 | 588 | 589 | ### Inquiry on Historical Changes of User Assets 590 | 591 | - method: asset.history 592 | - params: 593 | 594 | request parameter: 595 | 596 | | name of parameter | type of parameter | mandatory | description | 597 | | ----------- | -------- | ---- | ----------------------------- | 598 | | asset | String | yes | asset name, which can be null | 599 | | business | String | yes | business name | 600 | | start\_time | Integer | yes | starting time | 601 | | end\_time | Integer | yes | ending time | 602 | | offset | Integer | yes | offset | 603 | | limit | Integer | yes | 最大返回数量maximum number returned, less than 101 | 604 | 605 | example: 606 | 607 | ``` 608 | { 609 | "method":"asset.history", 610 | "params":["BTC","deposit",1501940406,1513328112,0,100], 611 | "id":100 612 | } 613 | ``` 614 | 615 | response: 616 | 617 | ``` 618 | { 619 | "error": null, 620 | "result": { 621 | "offset": 0, 622 | "limit": 100, 623 | "records": [ 624 | { 625 | "time": 1511856143.3754101, # timestamp 626 | "asset": "USD", # asset type 627 | "business":"deposit", # business symbol deposit-deposit,freeze-freeze/unfreeze,withdraw-提币 628 | "change": "100000", # asset change 629 | "balance": "300000", # user balance after the change 630 | "detail": { "id": 10003 } # other details 631 | }, 632 | ... 633 | ] 634 | }, 635 | "id": 100 636 | } 637 | ``` 638 | 639 | ## Subscripbe/Unsubscribe Interface 640 | 641 | 642 | ### Subscribe Market Trends 643 | 644 | - method: kline.subscribe 645 | - params: 646 | 647 | request parameter: 648 | 649 | | name of parameter | type of parameter | mandatory | description | 650 | | -------- | -------- | ---- | ------------ | 651 | | market | String | yes | market name | 652 | | interval | Integer | yes | period of data obtention | 653 | 654 | example: 655 | 656 | ``` 657 | { 658 | "method":"kline.subscribe", 659 | "params":[ "BTCBCC", 60 ], 660 | "id":100 661 | } 662 | ``` 663 | 664 | response: 665 | 666 | ``` 667 | { 668 | "error": null, 669 | "result": { "status": "success" }, 670 | "id": 100 671 | } 672 | ``` 673 | 674 | After successfully subscribing, the subscribed data will be pushed to client end. Refer the content to **[market trend push]**. 675 | 676 | ### Market Trend Push 677 | 678 | example: 679 | 680 | ``` 681 | { 682 | "method": "kline.update", 683 | "params": [[1513135140, "8000", "8000", "8000", "8000", "0", "0", "BTCBCC"]], 684 | "id": null 685 | } 686 | ``` 687 | 688 | parameter description: 689 | 690 | ``` 691 | "params": [ 692 | [ 693 | 1492358400, # timestamp 694 | "7000.00", # opening price 695 | "8000.0", # closing price 696 | "8100.00", # highest price 697 | "6800.00", # lowest price 698 | "1000.00" # 成交量 Turnover 699 | "123456.00", # 成交金额 Value settled 700 | "BTCBCC" # 交易币对市场名称 Market name of transaction pair 701 | ] 702 | ] 703 | ``` 704 | 705 | ### Cancel the Subsctiption on Market Trend 706 | 707 | - method: kline.unsubscribe 708 | - params: [] 709 | 710 | example: 711 | 712 | ``` 713 | { 714 | "method":"kline.unsubscribe", 715 | "params":[], 716 | "id":100 717 | } 718 | ``` 719 | 720 | response: 721 | 722 | ``` 723 | { 724 | "error": null, 725 | "result": {"status": "success"}, 726 | "id": 100 727 | } 728 | ``` 729 | 730 | ### Subscription of Latest Price 731 | 732 | - method: price.subscribe 733 | - params: 734 | 735 | request parameter: 736 | 737 | | name of parameter | type of parameter | mandatory | description | 738 | | -------- | -------- | ---- | ------------ | 739 | | market | String | yes | market name | 740 | 741 | request 742 | 743 | ``` 744 | { 745 | "method":"price.subscribe", 746 | "params":["BTCBCC"], 747 | "id":100 748 | } 749 | ``` 750 | 751 | response 752 | 753 | ``` 754 | { 755 | "error": null, 756 | "result": { "status": "success" }, 757 | "id": 100 758 | } 759 | ``` 760 | 761 | ### Push of Latest Price 762 | 763 | **After successfully subscribing,the data content will be actively pushed to client end.** 764 | 765 | - method: price.update 766 | 767 | example 768 | 769 | ``` 770 | { 771 | "method": "price.update", 772 | "params": ["BTCBCC", "8000.00000000"], 773 | "id": null 774 | } 775 | ``` 776 | 777 | parameter description: 778 | 779 | ``` 780 | "params": [ 781 | "BTCBCC", # market name 782 | "8000.00000000" # latest price 783 | ] 784 | ``` 785 | 786 | ### Cancel the Subscription of Latest Price 787 | 788 | - method: price.unsubscribe 789 | - params: [] 790 | 791 | example: 792 | 793 | ``` 794 | { 795 | "method":"price.unsubscribe", 796 | "params":[], 797 | "id":100 798 | } 799 | ``` 800 | 801 | response 802 | 803 | ``` 804 | { 805 | "error": null, 806 | "result": { "status": "success" }, 807 | "id": 100 808 | } 809 | ``` 810 | 811 | ### The Subscription of Market Status 812 | 813 | **The subscription of 24-hour Market Status.** 814 | 815 | - method: state.subscribe 816 | - params: The list of market names of transaction pairs 817 | 818 | request 819 | 820 | ``` 821 | { 822 | "method":"state.subscribe", 823 | "params":["BTCBCC","BTCUSD"], 824 | "id":100 825 | } 826 | ``` 827 | 828 | response 829 | 830 | ``` 831 | { 832 | "error": null, 833 | "result": { "status": "success" }, 834 | "id": 100 835 | } 836 | ``` 837 | 838 | ### The Push of Market Status 839 | 840 | **After successfully subscribing,the status data will be pushed to client end by trading server.** 841 | 842 | - method: state.update 843 | 844 | example: 845 | 846 | ``` 847 | { 848 | "method": "state.update", 849 | "params": [ 850 | "BTCBCC", { 851 | "period": 86400, 852 | "last": "8000", 853 | "open": "0", 854 | "close": "0", 855 | "high": "0", 856 | "low": "0", 857 | "volume": "0", 858 | "deal": "0" 859 | } 860 | ], 861 | "id": null 862 | } 863 | ``` 864 | 865 | Please refer to the method of state.query for return value. 866 | 867 | ### Cancel the Push of Market Status 868 | 869 | - method: state.unsubscribe 870 | - params: [] 871 | 872 | request 873 | 874 | ``` 875 | { 876 | "method":"state.unsubscribe", 877 | "params":[], 878 | "id":100 879 | } 880 | ``` 881 | 882 | response 883 | 884 | ``` 885 | { 886 | "error": null, 887 | "result": { "status": "success" }, 888 | "id": 100 889 | } 890 | ``` 891 | 892 | ### The Subscription of the Current Day's Market Status 893 | 894 | **The subscription of the current day's market status.** 895 | 896 | - method: today.subscribe 897 | - params: 898 | 899 | request parameter: 900 | 901 | | name of parameter | type of parameter | mandatory | description | 902 | | ----------- | -------- | ---- | ---------- | 903 | | market list | String | yes | list of market names | 904 | 905 | request 906 | 907 | ``` 908 | { 909 | "method":"today.subscribe", 910 | "params":["BTCUSD","BTCBCC"], 911 | "id":100 912 | } 913 | ``` 914 | 915 | response 916 | 917 | ``` 918 | { 919 | "error": null, 920 | "result": { "status": "success" }, 921 | "id": 100 922 | } 923 | ``` 924 | 925 | ### The Push of the Current Day's Market Status 926 | 927 | After successfully subscribing, the server actively pushes data to client end. 928 | 929 | - method: today.update 930 | 931 | example 932 | 933 | ``` 934 | { 935 | "method": "today.update", 936 | "params": [ 937 | "BTCBCC", { 938 | "open": "8000", 939 | "last": "8000", 940 | "high": "8000", 941 | "low": "8000", 942 | "volume": "0", 943 | "deal": "0" 944 | } 945 | ], 946 | "id": null 947 | } 948 | ``` 949 | 950 | Return value refer to the method of state.query. 951 | 952 | ### Cancel the Subscription of Current Day's Market Status 953 | 954 | - method: today.unsubscribe 955 | - params: [] 956 | 957 | Request 958 | 959 | ``` 960 | { 961 | "method":"today.unsubscribe", 962 | "params":[], 963 | "id":100 964 | } 965 | ``` 966 | 967 | Response 968 | 969 | ``` 970 | { 971 | "error": null, 972 | "result": { "status": "success" }, 973 | "id": 100 974 | } 975 | ``` 976 | 977 | ### Subscription of Settled Deals 978 | 979 | - method: deals.subscribe 980 | - params: The list of market names of transaction pairs 981 | 982 | request 983 | 984 | ``` 985 | { 986 | "method":"deals.subscribe", 987 | "params":["BTCBCC","BTCUSD"], 988 | "id":100 989 | } 990 | ``` 991 | 992 | response 993 | 994 | ``` 995 | { 996 | "error": null, 997 | "result": { "status": "success" }, 998 | "id": 100 999 | } 1000 | ``` 1001 | 1002 | ### The Push of Settled Deals 1003 | 1004 | example: 1005 | 1006 | ``` 1007 | { 1008 | "method": "deals.update", 1009 | "params": [ 1010 | "BTCBCC", [ 1011 | {"id": 26, "time": 1512454847.188796, "price": "8000", "amount": "1", "type": "buy"}, 1012 | {"id": 25, "time": 1512445625.751971, "price": "8000", "amount": "0.125", "type": "buy"}, 1013 | {"id": 24, "time": 1512442938.956193, "price": "8000", "amount": "0.125", "type": "buy"}, 1014 | ... 1015 | {"id": 22, "time": 1512442927.2021289, "price": "8000", "amount": "0.125", "type": "buy"}, 1016 | {"id": 3, "time": 1512442109.0283101, "price": "8000", "amount": "0.125", "type": "buy"}, 1017 | {"id": 2, "time": 1512441964.500567, "price": "8000", "amount": "0.125", "type": "buy"}, 1018 | {"id": 1, "time": 1512441751.9356339, "price": "8000", "amount": "0.125", "type": "buy"} 1019 | ] 1020 | ], 1021 | "id": null 1022 | } 1023 | ``` 1024 | 1025 | Refer to the returned result of deals.query. 1026 | 1027 | ### Cancel the Subscription on Settled Deals 1028 | 1029 | - method: deals.unsubscribe 1030 | - params: [] 1031 | 1032 | request 1033 | 1034 | ``` 1035 | { 1036 | "method":"deals.unsubscribe", 1037 | "params":[], 1038 | "id":100 1039 | } 1040 | ``` 1041 | 1042 | response 1043 | 1044 | ``` 1045 | { 1046 | "error": null, 1047 | "result": { "status": "success" }, 1048 | "id": 100 1049 | } 1050 | ``` 1051 | 1052 | #### Subscription on Order Depth 1053 | 1054 | - method: depth.subscribe 1055 | - params: 1056 | 1057 | request parameter: 1058 | 1059 | ``` 1060 | "params":[ 1061 | "BTCBCC", # market name 1062 | 100, # order price,value:1, 5, 10, 20, 30, 50, 100 1063 | "0.0001" # the precision of price range, value:"0","0.00000001","0.0000001","0.000001","0.00001", 1064 | # "0.0001", "0.001", "0.01", "0.1" 1065 | ] 1066 | ``` 1067 | 1068 | request 1069 | 1070 | ``` 1071 | { 1072 | "method":"depth.subscribe", 1073 | "params":["EOSUSDT",100,"0.1"], 1074 | "id":100 1075 | } 1076 | ``` 1077 | 1078 | response 1079 | 1080 | ``` 1081 | { 1082 | "error": null, 1083 | "result": { "status": "success" }, 1084 | "id": 100 1085 | } 1086 | ``` 1087 | 1088 | #### Subscription on Orders Depth 1089 | 1090 | - method: depths.subscribe 1091 | - params: 1092 | 1093 | request parameter: 1094 | 1095 | ``` 1096 | "params":[ 1097 | [ 1098 | "ETCBTC", # market name 1099 | 100, # order price,value:1, 5, 10, 20, 30, 50, 100 1100 | "0.0001" # the precision of price range, value:"0","0.00000001","0.0000001","0.000001","0.00001", 1101 | # "0.0001", "0.001", "0.01", "0.1" 1102 | ],[ 1103 | "BTCBCC", # market name 1104 | 100, # order price,value:1, 5, 10, 20, 30, 50, 100 1105 | "0.0001" # the precision of price range, value:"0","0.00000001","0.0000001","0.000001","0.00001", 1106 | # "0.0001", "0.001", "0.01", "0.1" 1107 | ] 1108 | ] 1109 | ``` 1110 | 1111 | request 1112 | 1113 | ``` 1114 | { 1115 | "method":"depths.subscribe", 1116 | "params":[["ETCUSDT",100,"0.1"],["EOSUSDT",100,"0.1"]], 1117 | "id":100 1118 | } 1119 | ``` 1120 | 1121 | response 1122 | 1123 | ``` 1124 | { 1125 | "error": null, 1126 | "result": { "status": "success" }, 1127 | "id": 100 1128 | } 1129 | ``` 1130 | 1131 | 1132 | ### The Push of Order Depth Data 1133 | 1134 | - method: depth.update 1135 | 1136 | example: 1137 | 1138 | ``` 1139 | { 1140 | "method": "depth.update", 1141 | "params": [true, {"asks": [["8000", "20"]], "bids": [["800", "4"]]}, "BTCBCC"], 1142 | "id": null 1143 | } 1144 | ``` 1145 | 1146 | Description of returned result: 1147 | 1148 | Take the example of the precision of price range as 0.1. 1149 | 1150 | ``` 1151 | "params": [ 1152 | true, #clean: Boolean, true: complete result,false: last returned updated result 1153 | { 1154 | "asks": [ 1155 | [ 1156 | "8000", # price 1157 | "20" # number 1158 | ], 1159 | [ 1160 | "8000.1", # price 1161 | "20" # **the sum of the number of all orders with price≥8000,less than 8000.1** 1162 | ] 1163 | ], 1164 | "bids": 1165 | [ 1166 | [ 1167 | "800", 1168 | "4" 1169 | ], 1170 | [ 1171 | "800.1", 1172 | "5" 1173 | ] 1174 | ] 1175 | }, 1176 | "BTCBCC" # the market name of transaction pair 1177 | ] 1178 | ``` 1179 | 1180 | ### Cancel the Subscription of Order Depth 1181 | 1182 | - method: depth.unsubscribe 1183 | - params: [] 1184 | 1185 | request 1186 | 1187 | ``` 1188 | { 1189 | "method":"depth.unsubscribe", 1190 | "params":[], 1191 | "id":100 1192 | } 1193 | ``` 1194 | 1195 | response 1196 | 1197 | ``` 1198 | { 1199 | "error": null, 1200 | "result": { "status": "success" }, 1201 | "id": 100 1202 | } 1203 | ``` 1204 | 1205 | ### The subscription of User's Order Status 1206 | 1207 | - method: order.subscribe 1208 | - params: list of market names 1209 | 1210 | request 1211 | 1212 | ``` 1213 | { 1214 | "method":"order.subscribe", 1215 | "params":["BTCBCC","BTCETH"], 1216 | "id":100 1217 | } 1218 | ``` 1219 | 1220 | response 1221 | 1222 | ``` 1223 | { 1224 | "error": null, 1225 | "result": { "status": "success" }, 1226 | "id": 100 1227 | } 1228 | ``` 1229 | 1230 | ### The Push on Changes of User's Order 1231 | 1232 | **Every change in the status of order will be pushed to client end** 1233 | 1234 | example: 1235 | 1236 | ``` 1237 | { 1238 | "method": "order.update", 1239 | "params": [ 1240 | 1, # the event type of change on order status,integer value 1-new order, 2-update order, 3-settled completely 1241 | { 1242 | "id": 422458, 1243 | "market": "BTCBCC", 1244 | "source": "", 1245 | "type": 1, # 1-limit order 2 -market order 1246 | "side": 1, # 1-Ask 2-Bid 1247 | "user": 5, 1248 | "ctime": 1513819599.987308, # create_time 1249 | "mtime": 1513819599.987308, # update_time 1250 | "price": "8000", 1251 | "amount": "10", 1252 | "taker_fee": "0.002", 1253 | "maker_fee": "0.001", 1254 | "left": "10", 1255 | "deal_stock": "0", 1256 | "deal_money": "0", 1257 | "deal_fee": "0" } 1258 | ], 1259 | "id": 102 1260 | } 1261 | ``` 1262 | 1263 | refer to order.query for the detailed description on order field. 1264 | 1265 | ### Cancel the Subscription of Changes on Order Status 1266 | 1267 | - method: order.unsubscribe 1268 | - params: [] 1269 | 1270 | request 1271 | 1272 | ``` 1273 | { 1274 | "method":"order.unsubscribe", 1275 | "params":[], 1276 | "id":100 1277 | } 1278 | ``` 1279 | 1280 | response 1281 | 1282 | ``` 1283 | { 1284 | "error": null, 1285 | "result": { "status": "success" }, 1286 | "id": 100 1287 | } 1288 | ``` 1289 | 1290 | ### Subscription on User's Asset Information 1291 | 1292 | - method: asset.subscribe 1293 | - params: list of asset names 1294 | 1295 | request 1296 | 1297 | ``` 1298 | { 1299 | "method":"asset.subscribe", 1300 | "params":["BTC","ETH","BCC"], 1301 | "id":100 1302 | } 1303 | ``` 1304 | 1305 | response 1306 | 1307 | ``` 1308 | { 1309 | "error": null, 1310 | "result": { "status": "success" }, 1311 | "id": 100 1312 | } 1313 | ``` 1314 | 1315 | ### Push of Changes on User Asset 1316 | 1317 | - method: asset.update 1318 | 1319 | example: 1320 | 1321 | ``` 1322 | { 1323 | "method": "asset.update", 1324 | "params": { 1325 | "ETH": { "available": "0", "freeze": "0" }, 1326 | "BTC": { "available": "0", "freeze": "0" } 1327 | }, 1328 | "id": 100 1329 | } 1330 | ``` 1331 | 1332 | ### Subscription of User Asset Information 1333 | 1334 | - method: asset.unsubscribe 1335 | 1336 | request 1337 | 1338 | ``` 1339 | { 1340 | "method":"asset.unsubscribe", 1341 | "params":[], 1342 | "id":100 1343 | } 1344 | ``` 1345 | 1346 | response 1347 | 1348 | ``` 1349 | { 1350 | "error": null, 1351 | "result": { "status": "success" }, 1352 | "id": 100 1353 | } 1354 | ``` 1355 | --------------------------------------------------------------------------------