English 简体中文 繁体中文
json

Introduction

API Introduction

Welcome to the BitV API!

This document is the only official API document of BitV. The features and services provided will be continuously updated here.

You can switch to get the API for different services by clicking the menu above, and you can also switch the language of the document by clicking the language button on the top right.

Examples of request parameters and response results are shown on the right side of the document.

Update Subscription

We will notify you in advance about API additions, updates and downgrades. We suggest you pay attention to and subscribe to our announcements to get relevant information in time.

Contact us

If you have any questions or inquiries regarding the use of the API, please refer to the Q&A for inquiries.

Quick Start

Access Preparation

To use the API, please log in to the web terminal and complete the API key application and permission configuration before developing and trading according to the details in this document.

You can create an API key by clicking here .

Each parent user can create 3 groups of API Key, and each API Key can set two kinds of permissions: read and trade.

Permissions are described as follows:

After successful creation, please make sure to remember the following information:

Interface Types

We provide two kinds of interfaces for users, you can choose the suitable way to check the quotes or trade according to your usage scenarios and preferences.

REST API

REST, which stands for Representational State Transfer, is a popular HTTP-based communication mechanism, where each URL represents a resource.

For one-time operations such as trading, developers are recommended to use the REST API for operations.

WebSocket API

WebSocket is a new protocol (Protocol) for HTML5. It implements full-duplex communication between client and server. A client-server connection can be established through a simple handshake, and the server can actively push information to the client according to business rules.

It is recommended that developers use the WebSocket API to obtain information such as market quotes and buying and selling depth.

Interface Authentication

Both of the above interfaces contain two types of public and private interfaces.

The public interface can be used to obtain basic information and quotation data. The public interface can be called without authentication.

The private interface can be used for trade management and account management. Each private request must be signed and authenticated using your API Key.

Access URLs

REST API

https://api.bitv.com

Websocket Feed (quotes)

wss://api.bitv.com/ws

Websocket Feed (assets and orders)

*wss://api.bitv.com/ws/v2

Signature Authentication

Signature Description

To ensure that requests are not altered, private interfaces other than public interfaces (base information, ticker data) must be signed and authenticated with your API Key to verify that parameters or parameter values have not been altered in transit.
Each API Key requires the appropriate permissions to access the corresponding interface, and each newly created API Key needs to be assigned permissions. Before using an interface, check the permission type for each interface and make sure your API Key has the appropriate permissions.

A legitimate request consists of the following components:

Signing steps

Because when using HMAC for signature computation, the result of the computation can be completely different using different content. Therefore, please normalize the request before performing the signature calculation. The following is an example of a request for order details:

The full request URL for an order detail query

https://api.bitv.com/v1/order/orders?

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

&SignatureMethod=HmacSHA256

&SignatureVersion=2

&Timestamp=2017-05-11T15:19:30

&order-id=1234567890

1. request method (GET or POST, GET for WebSocket), followed by the newline character “\n”

For example: GET\n

2. add the access domain name in lowercase, followed by the newline character “\n”

For example: api.bitv.com\n

3. add the path to the access method, followed by a line break “\n”

For example, to check orders:
/v1/order/orders\n

For example WebSocket v2
/ws/v2

4. URL encoding of the parameters and sorting them in ASCII order

For example, here is the original order of the request parameters and after URL encoding

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

order-id=1234567890

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

After sorting

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

order-id=1234567890

5. In the above order, connect the parameters using the character “&”

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15% 3A19%3A30&order-id=1234567890

6. compose the final string for the signature calculation as follows

GET\n

api.bitv.com\n

/v1/order/orders\n

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15% 3A19%3A30&order-id=1234567890

7. Generate a digital signature with the “request string” created in the previous step and your Secret Key

  1. Use the request string from the previous step and the API private key as two parameters, call the HmacSHA256 hash function to obtain the hash value.
  2. Base-64 encode this hash value to get the digital signature for this API call.

4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o=

8. Include the generated digital signature in your request

For Rest API:

  1. Add all required authentication parameters to the path parameters of the interface call
  2. URL encode the digital signature and add it to the path parameters, with the parameter name as “Signature”.

Ultimately, the API request sent to the server should look like this:

https://api.bitv.com/v1/order/orders?AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&order-id=1234567890&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&Signature=4F65x5A2bLyMWVQj3Aqp%2BB4w%2BivaA7n5Oi2SuYtCJ9o%3D

For WebSocket interface:

  1. Fill in the parameters and signature as per the required JSON format.
  2. The parameters in the JSON request do not need to be URL-encoded.

For example:

` { “action”: “req”, “ch”: “auth”, “params”: { “authType”:”api”, “accessKey”: “e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx”, “signatureMethod”: “HmacSHA256”, “signatureVersion”: “2.1”, “timestamp”: “2019-09-01T18:16:16”, “signature”: “4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o=” } } `

Business Glossary

Trading Pairs

Trading pairs consist of a base currency and a quote currency. For example, in the trading pair BTC/USDT, BTC is the base currency, and USDT is the quote currency.

The field corresponding to the base currency is called base-currency.

The field corresponding to the quote currency is called quote-currency.

Accounts

Different businesses require different types of accounts. The account-id is a unique identifier for each business account.

The account-id can be obtained through the /v1/account/accounts interface, and the specific account type can be determined based on the account-type.

Account types include:

Order Types

The order type is determined by the combination of the trade direction and the order operation type. For example, “buy-market” consists of the buy direction and the market operation type.

Trade directions:

Order types:

Order Status

Integration Guide

API Overview

API Category Category Link Description
Basic /v1/common/* Basic APIs, including currency, trading pair, timestamp, etc.
Market /market/* Public market APIs, including trades, depth, market data, etc.
Account /v1/account/* /v1/subuser/* Account APIs, including account information, subusers, etc.
Order /v1/order/* Order APIs, including order placement, cancellation, order query, trade query, etc.

This categorization provides a general overview, but some APIs may not follow this convention. Please refer to the corresponding API documentation based on your specific needs.

New Rate Limit Rules

Rate Limit Rules

Except for APIs that have a separate rate limit value marked as “NEW” -

For example:

Request Format

All API requests are RESTful and currently support two methods: GET and POST.

Response Format

All APIs return data in JSON format. There are slight differences in the JSON structure between v1 and v2 APIs.

v1 API response format: The top-level structure consists of four fields: status, ch, ts, and data. The first three fields represent the request status and attributes, and the actual business data is contained in the data field.

Here is an example of the response format:

{
  "status": "ok",
  "ch": "market.btcusdt.kline.1day",
  "ts": 1499223904680,
  "data": // per API response data in nested JSON object
}
Field Name Data Type Description
code int API interface response code
message string Error message (if any)
data object Main data returned by the interface

v2 API response format: The top-level structure consists of three fields: code, message, and data. The first two fields represent the response code and the error message, respectively. The actual business data is contained in the data field.

Here is an example of the response format:

{
  "code": 200,
  "message": "",
  "data": // per API response data in nested JSON object
}
Field Name Data Type Description
code int API interface response code
message string Error message (if any)
data object Main data returned by the interface

Data Types

This document describes the conventions for data types in the JSON format:

Best Practices

Security

Public

New Rate Limit Rules

Market Data

Obtaining Market Data

Obtaining Latest Trade Price

Obtaining Order Book Depth

Obtaining Latest Trades

Order Management

Placing Orders (/v1/order/orders/place)

Search Historical Orders (/v1/order/orders)

Account Management

Asset Changes

common problem

API information notification

Announcements will be issued in advance to notify you of new API additions, updates, and offline information. It is recommended that you pay attention to and subscribe to our announcements to obtain relevant information in a timely manner.

Q1: How many Api Keys can a user apply for?

A: Each parent user can create 3 groups of API Keys, and each API Key can be set with two permissions: reading and trading. Each parent user can also create 200 sub-users, and each sub-user can create 3 sets of API Keys, and each API Key can be set with two permissions for reading and trading.

The following are descriptions of the two permissions:

Q2: Why do disconnections and timeouts often occur?

A: Please check whether it belongs to the following situations:

  1. If the client server is located in mainland China, it is difficult to guarantee the stability of the connection.

Q3: Why is WebSocket always disconnected?

A: The common reasons are:

  1. If Pong is not replied, the WebSocket connection needs to reply Pong after receiving the Ping message sent by the server to ensure the stability of the connection.

  2. Due to network reasons, the client sent a Pong message, but the server did not receive it.

  3. The connection is disconnected due to network reasons.

  4. It is recommended that users implement a WebSocket connection disconnection and reconnection mechanism. After ensuring that the heartbeat (Ping/Pong) message is correctly replied, if the connection is accidentally disconnected, the program can automatically reconnect.

Q4: Why does the signature verification always fail?

A: Please compare the difference between the string before signing with Secret Key and the following string

Please note the following points when comparing:

  1. Signature parameters should be sorted according to ASCII code. For example, the following are the original parameters:

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

order-id=1234567890

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

After sorting it should be:

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

order-id=1234567890

  1. The signature string needs to be URL-encoded. for example:
  1. The signature needs to be base64 encoded

  2. Get request parameters need to be in the signature string

  3. The time is UTC time converted to YYYY-MM-DDTHH:mm:ss

  4. Check whether there is a deviation between the local time and the standard time (the deviation should be less than 1 minute)

  5. When WebSocket sends a signature verification and authentication message, the message body does not need URL encoding

  6. The Host in the signature should be the same as the Host in the request interface

If you use a proxy, the proxy may change the request Host, you can try to remove the proxy;

The network connection library you use may include the port in the Host, you can try to include the port in the Host used in the signature

  1. Whether there are hidden special characters in Api Key and Secret Key, which will affect the signature

Q5: Why is the gateway-internal-error error returned by calling the interface?

A: Please check whether it belongs to the following situations:

  1. Whether the account-id is correct or not requires the data returned by the GET /v1/account/accounts interface.

  2. It may be caused by the network, please try again later.

  3. Whether the format of the sent data is correct (standard JSON format is required).

  4. The POST request header needs to be declared as Content-Type: application/json.

Q6: What is the reason why the call interface returns a login-required error?

A: Please check whether it belongs to the following situations:

  1. The AccessKey parameter should be brought into the URL.
  2. The Signature parameter should be brought into the URL.
  3. Whether the account-id is correct or not is the data returned by GET /v1/account/accounts interface.
  4. This error may be triggered when the request is made again after the frequency limit occurs.

Q7: What is the reason for calling the Rest interface and returning HTTP 405 error method-not-allowed?

A: This error indicates that a Rest interface that does not exist has been called. Please check whether the path of the Rest interface is accurate. Due to the settings of Nginx, the request path (Path) is case-sensitive, please strictly follow the case stated in the document.

Q1: How often is the current handicap data updated?

A: The current handicap data is updated once a second, whether it is a RESTful query or a Websocket push, it is updated once a second. If you need real-time bid, sell, and price data, you can use WebSocket to subscribe to the topic market.$symbol.bbo, which will push the latest bid, sell, and price data in real time.

Q2: Will the trading volume of the 24-hour market interface (/market/detail) data interface experience negative growth?

A: The transaction volume and transaction amount in the /market/detail interface are 24-hour rolling data (the size of the translation window is 24 hours), and the cumulative transaction volume and transaction amount in the latter window may be smaller than the previous window.

Q3: How to get the latest transaction price?

A: It is recommended to use the REST API GET /market/trade interface to request the latest transaction, or use WebSocket to subscribe to the market.$symbol.trade.detail topic, and obtain it according to the price in the returned data.

Q4: When is the K-line calculated?

A: The K-line period is calculated based on Singapore time. For example, the starting period of the daily K-line is from 0:00 Singapore time to 0:00 Singapore time the next day.

Q1: What is account-id?

A: account-id corresponds to the ID of different business accounts of the user, which can be obtained through the /v1/account/accounts interface, and specific accounts are distinguished according to account-type.

Account types include:

Q2: What is client-order-id?

A: The client-order-id is a parameter of the order request identification, the type is a string, and the length is 64. This id is generated by the user and is valid within 24 hours.

Q3: How to obtain the order quantity, amount, decimal limit, precision information?

A: You can use the Rest API GET /v1/common/symbols to obtain relevant currency pair information. When placing an order, pay attention to the difference between the minimum order quantity and the minimum order amount.

Common return errors are as follows:

Q4: Why is the balance insufficient when placing an order again after receiving the message that the order has been successfully filled?

A: In order to ensure the timely delivery of orders and low latency, the result of order push is pushed directly after matching. At this time, the order may not have completed the liquidation of assets.

It is recommended to use the following methods to ensure that funds can be placed correctly:

  1. Combined with the asset push topic accounts, receive asset change messages synchronously to ensure that funds have been cleared.

  2. When receiving the order push message, use the Rest interface to call the account balance to verify whether the account funds are sufficient.

  3. Keep a relatively sufficient fund balance in the account.

Q5: What is the difference between filled-fees and filled-points in the matching results?

A: There are two types of transaction fees in matchmaking transactions: ordinary fees and deductible fees, and the two types will not exist at the same time.

  1. Ordinary handling fee means that the deduction is not enabled at the time of the transaction, and the original currency is used for the deduction of the handling fee. For example: when purchasing BTC under the BTCUSDT currency pair, the filled-fees field is not empty, indicating that the normal handling fee has been deducted, and the unit is BTC.

  2. The deduction of handling fee means that when the transaction is completed, the deduction is turned on, and the deduction asset is used as the deduction of the handling fee. For example, when purchasing BTC under the BTCUSDT currency pair, when the deduction assets are sufficient, filled-fees is empty, and filled-points is not empty, indicating that the deduction assets are deducted as a handling fee. The deduction unit needs to refer to the fee-deduct-currency field

Q6: What is the difference between match-id and trade-id in the matching results?

A: match-id indicates the sequence number of the order in matching, and trade-id indicates the sequence number at the time of transaction. A match-id may have multiple trade-ids (at the time of transaction), or may not have trade-id (creating order, canceling Order)

Q7: Why does placing an order based on the price of buying one or selling one in the current market trigger an order limit error?

A: Currently, there is price limit protection based on the latest transaction price. For coins with poor liquidity, placing an order based on market data may trigger price limit protection. It is recommended to place an order based on the transaction price + handicap data information pushed by ws

basic information

Introduction

The basic information Rest interface provides public reference information such as market status, transaction pair information, currency information, currency chain information, and server timestamp.

Get all trading pairs

This interface returns all supported trading pairs.

curl "https://api.bitv.com/v1/common/symbols"

HTTP requests

Request parameters

This interface does not accept any parameters.

Responses:

{
     "status": "ok",
     "data": [
         {
             "base-currency": "btc",
             "quote-currency": "usdt",
             "price-precision": 2,
             "amount-precision": 6,
             "symbol-partition": "main",
             "symbol": "btcusdt",
             "state": "online",
             "value-precision": 8,
             "min-order-amt": 0.0001,
             "max-order-amt": 1000,
             "min-order-value": 5,
             "limit-order-min-order-amt": 0.0001,
             "limit-order-max-order-amt": 1000,
             "sell-market-min-order-amt": 0.0001,
             "sell-market-max-order-amt": 100,
             "buy-market-max-order-value": 1000000,
             "api-trading": "enabled",
             "limit-order-max-buy-amt": 50,
             "limit-order-max-sell-amt": 50,
             "buy-limit-must-less-than": 1.3,
             "sell-limit-must-greater-than": 0.7,
             "market-sell-order-rate-must-less-than": 0.05,
             "market-buy-order-rate-must-less-than": 0.05,
             "max-order-value": 3000000,
             "tags": ""
         },
      …
     ]
}

return fields

Field Name Required Data Type Description
base-currency true string Base currency in the transaction pair
quote-currency true string Quote currency in the trading pair
price-precision true integer Precision of the trading pair quotation (digits after the decimal point)
amount-precision true integer Precision of the trading pair base currency counting (digits after the decimal point)
symbol-partition true string Transaction partition; possible values: [main, innovation]
symbol true string Trading pair
state true string Trading pair status; possible values: [online, offline, suspend, pre-online]
value-precision true integer Precision of the transaction amount of the trading pair (digits after the decimal point)
min-order-amt true float Minimum order size of a limit order for the trading pair, in the base currency (to be obsolete)
max-order-amt true float Maximum order size of a limit order for the trading pair, in the base currency (to be obsolete soon)
limit-order-min-order-amt true float Minimum order size of a limit order for the trading pair, in the base currency (NEW)
limit-order-max-order-amt true float Maximum order size of a limit order for the trading pair, in the base currency (NEW)
sell-market-min-order-amt true float Minimum order size of a market sell order for the trading pair, in the base currency (NEW)
sell-market-max-order-amt true float Maximum order size of a market sell order for the trading pair, in the base currency (NEW)
buy-market-max-order-value true float Maximum order value of a buy order at the market price of the trading pair, in the unit of pricing currency (NEW)
min-order-value true float Minimum order amount for a limit order and a market buy order for the trading pair, in the pricing currency
max-order-value false float Maximum order amount of a limit order and a market buy order for the trading pair, in converted USDT (NEW)
api-trading true string API trading enable flag (valid value: enabled, disabled)
limit-order-max-buy-amt true float max amount of limit price buy order, in the base currency
limit-order-max-sell-amt true float max amount of limit price sell order, in the base currency
buy-limit-must-less-than true float Buy limit must less than
sell-limit-must-greater-than true float Sell limit must greater than
market-sell-order-rate-must-less-than true float Market sell order rate must less than
market-buy-order-rate-must-less-than true float Market buy order rate must less than
tags false string Tags, multiple tags are separated by commas, such as: st, hadax

Get all currencies

This interface returns all supported currencies.

curl "https://api.bitv.com/v1/common/currencys"

HTTP requests

Request parameters

This interface does not accept any parameters.

Response:

  {
    "status": "ok",
     "data": [
       "usdt",
       "eth",
       "etc"
     ]
  }

return fields

APIv2 coin chain reference information

This node is used to query the static reference information (public data) of each currency and its blockchain

HTTP requests

curl "https://api.bitv.com/v2/reference/currencies?currency=usdt"

Request parameters

Field Name Required Type Field Description Value Range
currency false string Currency btc, ltc, bch, eth, etc … (refer to GET /v1/common/currencys)

Response:

{
     "code":200,
     "data":[
         {
             "chains":[
                 {
                     "chain": "trc20usdt",
                     "displayName": "",
                     "fullName":"",
                     "baseChain": "TRX",
                     "baseChainProtocol": "TRC20",
                     "isDynamic": false,
                     "depositStatus": "allowed",
                     "maxTransactFeeWithdraw": "1.00000000",
                     "maxWithdrawAmt": "280000.00000000",
                     "minDepositAmt": "100",
                     "minTransactFeeWithdraw": "0.10000000",
                     "minWithdrawAmt": "0.01",
                     "numOfConfirmations": 999,
                     "numOfFastConfirmations": 999,
                     "withdrawFeeType": "circulated",
                     "withdrawPrecision": 5,
                     "withdrawQuotaPerDay": "280000.00000000",
                     "withdrawStatus": "allowed",
                     "transactFeeWithdraw":"",
                     "addrWithTag": false,
                     "addrDepositTag": false
                 },
                 {
                     "chain": "usdt",
                     "displayName": "",
                     "fullName":"",
                     "baseChain": "BTC",
                     "baseChainProtocol": "OMNI",
                     "isDynamic": false,
                     "depositStatus": "allowed",
                     "maxWithdrawAmt": "19000.00000000",
                     "minDepositAmt": "0.0001",
                     "minWithdrawAmt": "2",
                     "numOfConfirmations": 30,
                     "numOfFastConfirmations": 15,
                     "transactFeeRateWithdraw": "0.00100000",
                     "withdrawFeeType": "ratio",
                     "withdrawPrecision": 7,
                     "withdrawQuotaPerDay": "90000.00000000",
                     "withdrawStatus": "allowed",
                     "transactFeeWithdraw":"",
                     "addrWithTag": false,
                     "addrDepositTag": false
                 },
                 {
                     "chain": "usdterc20",
                     "displayName": "",
                     "fullName":"",
                     "baseChain": "ETH",
                     "baseChainProtocol": "ERC20",
                     "isDynamic": false,
                     "depositStatus": "allowed",
                     "maxWithdrawAmt": "18000.00000000",
                     "minDepositAmt": "100",
                     "minWithdrawAmt": "1",
                     "numOfConfirmations": 999,
                     "numOfFastConfirmations": 999,
                     "transactFeeWithdraw": "0.10000000",
                     "withdrawFeeType": "fixed",
                     "withdrawPrecision": 6,
                     "withdrawQuotaPerDay": "180000.00000000",
                     "withdrawStatus": "allowed",
                     "transactFeeWithdraw":"",
                     "addrWithTag": false,
                     "addrDepositTag": false
                 }
             ],
             "currency": "usdt",
             "assetType": 1,
             "instStatus": "normal"
         }
         ]
}

Response data

field name required data type field description value range
code true int status code  
message false string error description (if any)  
data true object    
{currency true string currency  
{chains true object    
chain true string chain name  
displayName true string chain display name  
assetType false string asset type, 1 virtual currency 2 fiat currency  
fullName false string currency full name  
baseChain false string underlying chain name  
baseChainProtocol false string underlying chain protocol  
isDynamic false boolean Whether dynamic fee (only valid for fixed type, withdrawFeeType=fixed) true, false
numOfConfirmations true int The number of confirmations required for secure account login (coin withdrawals are allowed after reaching the number of confirmations)  
numOfFastConfirmations true int The number of confirmations required for fast account transfer (transactions are allowed but withdrawals are not allowed after reaching the number of confirmations)  
minDepositAmt true string minimum deposit amount  
depositStatus true string deposit status allowed, prohibited
minWithdrawAmt true string minimum withdrawal amount  
maxWithdrawAmt true string single maximum withdrawal amount  
withdrawQuotaPerDay true string Daily withdrawal quota (Singapore time zone)  
withdrawPrecision true int withdrawal precision  
withdrawFeeType true string Withdrawal fee type (the type of withdrawal fee for a specific currency on a specific chain is unique) fixed, circulated, ratio
transactFeeWithdraw false string single withdrawal fee (only valid for fixed type, withdrawFeeType=fixed)  
minTransactFeeWithdraw false string Minimum single withdrawal fee (only valid for interval type and ratio type with lower limit, withdrawFeeType=circulated or ratio)  
maxTransactFeeWithdraw false string Maximum single withdrawal fee (only valid for interval type and ratio type with upper limit, withdrawFeeType=circulated or ratio)  
transactFeeRateWithdraw false string transaction fee rate for a single withdrawal (only valid for ratio type, withdrawFeeType=ratio)  
addrWithTag false boolean addr with tag  
addrDepositTag false boolean has addr deposit tag  
withdrawStatus } true string withdrawal status allowed, prohibited
instStatus } true string currency status normal, delisted

status code

Status Code Error Message Error Scenario Description
200 success Request succeeded
500 error System error
2002 invalid field value in “field name” Illegal field value

Get the current system timestamp

This interface returns the current system timestamp, that is, the total milliseconds from UTC January 1, 1970 0:00:00:00 milliseconds to the present.

curl "https://api.bitv.com/v1/common/timestamp"

HTTP requests

Request parameters

This interface does not accept any parameters.

Response:

  {
    "status": "ok",
    "data": 1494900087022
  }

market data

Introduction

The market data interface provides market data such as various K-lines, depth and latest transaction records.

The following are the error codes, error messages and descriptions returned by the market data interface.

Error Code Error Message Description
invalid-parameter invalid symbol Invalid trading pair
invalid-parameter invalid period Incorrect period parameter for K-line request
invalid-parameter invalid depth Incorrect depth parameter
invalid-parameter invalid type Depth type parameter error
invalid-parameter invalid size Incorrect size parameter
invalid-parameter invalid size, valid range: [1, 2000] Incorrect size parameter, valid range: [1, 2000]
invalid-parameter request timeout Request timeout

K-line data (candle chart)

This interface returns historical K-line data.

curl "https://api.bitv.com/market/history/kline?period=1day&size=200&symbol=btcusdt"

HTTP requests

Request parameters

parameter data type required default value description value range
symbol string true NA Trading pair btcusdt, ethbtc, etc.
period string false 1min Return data time granularity, i.e., the time interval of each candle 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year
size integer false 150 Number of K-line data to return [1, 2000]

Response:

{
    "ch": "market.btcusdt.kline.1day",
    "status": "ok",
    "ts": 1761127929978,
    "data":[
       {
         "id": 1499184000,
         "amount": 37593.0266,
         "count": 0,
         "open": 1935.2000,
         "close": 1879.0000,
         "low": 1856.0000,
         "high": 1940.0000,
         "vol": 71031537.97866500
       }
    ]
}

Response data

Field Name Data Type Description
id long The timestamp adjusted to Singapore time, in seconds, used as the id of this candlestick
amount float Transaction amount in base currency
count integer Transaction count
open float Opening price of this candlestick
close float Closing price of this candlestick
low float Lowest price in this candlestick
high float Highest price in this candlestick
vol float Volume in quote currency

Aggregation Quotes (Ticker)

This interface obtains ticker information and provides transaction aggregation information in the last 24 hours.

curl "https://api.bitv.com/market/detail/merged?symbol=ethusdt"

HTTP requests

Request parameters

Parameter Data Type Required Default Value Description Value Range
symbol string true NA Trading pair btcusdt, ethbtc… (refer to GET /v1/common/symbols for value)

Response:

{
    "ch": "market.ethhkd.detail.merged",
    "status": "ok",
    "ts": 1761185653396,
    "tick": {
       "id": 1499225271,
       "version":5104471,
       "close": 1885.0000,
       "open": 1960.0000,
       "high": 1985.0000,
       "low": 1856.0000,
       "amount":81486.2926,
       "count": 42122,
       "vol":157052744.85708200,
       "ask":[1885.0000,21.8804],
       "bid": [1884.0000,1.6702]
    }
}

Response data

Field Name Data Type Description
id long NA
version long Internal field
amount float Transaction volume in base currency (rolling 24 hours)
count integer Number of transactions (rolling 24 hours)
open float Opening price of this stage (rolling 24 hours)
close float The latest price at this stage (rolling 24 hours)
low float The lowest price of this stage (rolling 24 hours)
high float The highest price of this stage (rolling 24 hours)
vol float Volume in quote currency (rolling 24 hours)
bid object Current highest bid price [price, size]
ask object Current minimum ask price [price, size]

Depth of Market Data

This interface returns the current market depth data for the specified trading pair.

curl "https://api.bitv.com/market/depth?symbol=btcusdt&type=step2"

HTTP requests

Request parameters

parameter data type required default value description value range
symbol string true NA Trading pair btcusdt, ethbtc… (refer to GET /v1/common/symbols for value)
depth integer false 20 Number of depths to return 5, 10, 20
type string true step0 Price aggregation level, see details below step0, step1, step2, step3, step4, step5

Description of each value for parameter type

Value Description
step0 No aggregation
step1 Aggregation level: quote precision * 10
step2 Aggregation level: quote precision * 100
step3 Aggregation level: quote precision * 1000
step4 Aggregation level: quote precision * 5000
step5 Aggregation level: quote precision * 10000

Response:

{
    "ch": "market.ethhkd.depth.step2",
    "status": "ok",
    "ts": 1761186823791,
    "tick": {
       "version": 31615843081,
       "ts": 1489464585407,
       "bids": [
         [7964, 0.0678], // [price, size]
         [7963, 0.9162],
         [7961, 0.1],
         [7960, 12.8898],
         [7958, 1.2],
         ...
       ],
       "asks": [
         [7979, 0.0736],
         [7980, 1.0292],
         [7981, 5.5652],
         [7986, 0.2416],
         [7990, 1.9970],
         ...
       ]
     }
}

Response data

Field Name Data Type Description
ts integer Timestamp adjusted to Singapore time, in milliseconds
version integer Internal field
bids object All current bids [price, size]
asks object All current ask orders [price, size]

Recent market transaction records

This interface returns the latest transaction record of the specified trading pair.

curl "https://api.bitv.com/market/trade?symbol=ethusdt"

HTTP requests

Request parameters

Parameter Data Type Required Default Value Description
symbol string true NA btcusdt, ethbtc… (value reference GET /v1/common/symbols)

Response:

{
    "ch": "market.ethhkd.trade.detail",
    "status": "ok",
    "ts": 1761187323300,
    "tick": {
         "id": 600848670,
         "ts": 1489464451000,
         "data": [
           {
             "id": 600848670,
             "trade-id": 102043494568,
             "price": 7962.62,
             "amount": 0.0122,
             "direction": "buy",
             "ts": 1489464451000
           }
         ]
    }
}

Response data

Field Name Data Type Description
id integer unique transaction id (will be discarded)
trade-id integer unique transaction ID (NEW)
amount float transaction amount in base currency
price float transaction price in quote currency
ts integer Timestamp adjusted to Singapore time, in milliseconds
direction string Transaction direction: “buy” or “sell”, “buy” means to buy, “sell” means to sell

Get recent transaction records

This interface returns all recent transaction records of the specified trading pair.

curl "https://api.bitv.com/market/history/trade?symbol=ethusdt&size=2"

HTTP requests

Request parameters

parameter data type required default value description
symbol string true NA btcusdt, ethbtc… (value reference GET /v1/common/symbols)
size integer false 1 the number of transaction records to return, the maximum value is 2000

Response:

{
    "ch": "market.ethhkd.trade.detail",
    "status": "ok",
    "ts": 1761187576005,
    "data": [
        {
           "id": 31618787514,
           "ts":1544390317905,
           "data":[
              {
                 "amount":9.000000000000000000,
                 "ts":1544390317905,
                 "trade-id": 102043483472,
                 "id":3161878751418918529341,
                 "price": 94.6900000000000000000,
                 "direction": "sell"
              },
              {
                 "amount":73.771000000000000000,
                 "ts":1544390317905,
                 "trade-id": 102043483473
                 "id":3161878751418918532514,
                 "price": 94.6600000000000000000,
                 "direction": "sell"
              }
           ]
        },
        {
           "id":31618776989,
           "ts":1544390311353,
           "data":[
              {
                 "amount": 1.0000000000000000000,
                 "ts":1544390311353,
                 "trade-id": 102043494568,
                 "id":3161877698918918522622,
                 "price":94.710000000000000000,
                 "direction": "buy"
              }
           ]
        }
    ]
}

Response data

Parameter Data Type Description
id integer unique transaction id (will be discarded)
trade-id integer unique transaction ID (NEW)
amount float transaction amount in base currency
price float transaction price in quote currency
ts integer Timestamp adjusted to Singapore time, in milliseconds
direction string Transaction direction: “buy” or “sell”, “buy” means to buy, “sell” means to sell

Last 24 hours market data

This interface returns the summary of market data in the last 24 hours.

curl "https://api.bitv.com/market/detail?symbol=ethusdt"

HTTP requests

Request parameters

Parameter Data Type Required Default Value Description
symbol string true NA btcusdt, ethbtc… (value reference GET /v1/common/symbols)

Response:

{
    "ch": "market.ethhkd.detail",
    "status": "ok",
    "ts": 1761188787410,
    "tick": {
        "amount":613071.438479561,
        "open":86.21,
        "close": 94.35,
        "high": 98.7,
        "id": 31619471534,
        "count": 138909,
        "low": 84.63,
        "version":31619471534,
        "vol":5.6617373443873316E7
    }
}

Response data

Field Name Data Type Description
id integer Response ID
amount float Transaction volume in base currency (rolling 24 hours)
count integer Number of transactions (according to rolling 24 hours)
open float Opening price of this stage (according to rolling 24 hours)
close float Closing price of this stage (according to rolling 24 hours)
low float Lowest price of this stage (according to rolling 24 hours)
high float Highest price of this stage (according to rolling 24 hours)
vol float Volume in quote currency (rolling 24 hours)
version integer Internal data

Account related

Introduction

The account-related interface provides functions such as account, balance, history query and asset transfer.

The following are the error codes, error messages and descriptions returned by account-related interfaces.

Error Code Error Message Description
500 system error Exception in calling internal service
1002 forbidden Forbidden operation, such as inconsistency between accountId and UID in user input parameters
2002 “invalid field value in currency Currency does not conform to regular rules ^[a-z0-9]{2,10}$
2002 “invalid field value in transactTypes The change type transactTypes is not “transfer”
2002 “invalid field value in sort Pagination request parameter is not valid “asc” or “desc”
2002 “value in fromId is not found in record” fromId not found
2002 “invalid field value in accountId accountId in the query parameter is empty
2002 “value in startTime exceeded valid range” The query time parameter is greater than the current time or more than 180 days from the current time
2002 “value in endTime exceeded valid range” The query end time is less than the start time or the query time span is greater than 10 days

account information

API Key Permission: Read
Frequency limit value (NEW): 100 times/2s

Query all account ID account-id and related information of the current user

HTTP requests

Request parameters

none

Response:

{
   "status": "ok",
   "data": [
     {
       "id": 100001,
       "type": "spot",
       "state": "working"
     }
   ]
}

Response data

Parameter name Required Data type Description Value range
id true long account-id  
state true string account status working: normal, lock: account is locked
type true string account type spot: spot account

Account Balance

API Key Permission: Read
Frequency limit value (NEW): 100 times/2s

Query the balance of the specified account, the following accounts are supported:

spot: spot account

HTTP requests

Request parameters

Parameter name Required Type Description Default value Value range
account-id true string account-id, fill in the path, value reference GET /v1/account/accounts    

Response:

{
   "status": "ok",
   "data": {
     "id": 100009,
     "type": "spot",
     "state": "working",
     "list": [
       {
         "currency": "usdt",
         "type": "trade",
         "balance": "5007.4362812650",
         "available": "0",
         "debt": "0",
         "seq-num": "0"
       },
       {
         "currency": "usdt",
         "type": "frozen",
         "balance": "348.11999203300",
         "available": "0",
         "debt": "0",
         "seq-num": "0"
       }
     ]
   }
}

Response data

Parameter name Required Data type Description Value range
id true long Account ID  
state true string Account status working: normal, lock: account is locked
type true string Account type spot: spot account
list false Array    

list field description:

Parameter name Required Data type Description Value range
balance true string Balance  
currency true string Currency  
type true string Type trade: trade balance, frozen: frozen balance
available true string Balance Maximum Available Balance
debt true string Balance Debt
seq-num true int Version  

Account History

API Key Permission: Read
Frequency limit value (NEW): 5 times/2s

This node returns the account history based on the user account ID.

###HTTP Request

Request parameters

Parameter Name Required Data Type Description Default Value Value Range
account-id true string Account number, refer to GET /v1/account/accounts    
currency false string Currency, e.g., btc, ltc, bch, eth, etc… (refer to GET /v1/common/currencys for values)    
transact-types false string Change types, multiple choices separated by commas all trade, transact-fee, fee-deduction, transfer, deposit, withdraw, withdraw-fee, other-types
start-time false long Unix time in milliseconds. Use transact-time as the key to search. The maximum query window is 1 hour. The window translation range is the last 30 days. ((end-time) - 1 hour) [(end-time) - 1 hour, end-time]
end-time false long Unix time in milliseconds. Use transact-time as the key to search. The maximum query window is 1 hour. The window translation range is the last 30 days. current-time [(current-time) - 29 days, current-time]
sort false string Search direction asc asc, desc
size false int Maximum number of entries 100 [1, 500]
from-id false long Start number (valid only when querying for the next page)    

Response:

{
     "status": "ok",
     "data": [
         {
             "account-id": 5260185,
             "currency": "btc",
             "transact-amt": "0.002393000000000000",
             "transact-type": "transfer",
             "record-id": 89373333576,
             "avail-balance": "0.002393000000000000",
             "acct-balance": "0.002393000000000000",
             "transact-time": 1571393524526
         },
         {
             "account-id": 5260185,
             "currency": "btc",
             "transact-amt": "-0.002393000000000000",
             "transact-type": "transfer",
             "record-id": 89373382631,
             "avail-balance": "0E-18",
             "acct-balance": "0E-18",
             "transact-time": 1571393578496
         }
     ]
}

Response data

Field Name Data Type Description Value Range
status string Status code  
data object    
{ account-id long Account number  
currency string Currency  
transact-amt string Change amount (Positive for deposit or Negative for withdrawal)  
transact-type string Transaction type  
avail-balance string Available balance  
acct-balance string Account balance  
transact-time long Transaction time (database record time)  
record-id } long Database record ID (globally unique)  
next-id long The start number of the next page (included when the query results need to be returned in pages)  

Spot Trading

Introduction

The spot trading interface provides functions such as order placement, order cancellation, order query, transaction query, and commission rate query.

Return Code Description
base-argument-unsupported A parameter is not supported, please check the parameter
base-system-error System error, if the order is canceled: the order status cannot be found in the cache, the order cannot be canceled; if the order is placed: the order failed to enter the cache, please try again
login-required There is no Signature parameter in the URL or the user cannot be found (the key does not correspond to the account ID, etc.)
parameter-required Take Profit Stop Loss order lacks parameter stop-price or operator
base-record-invalid No data found yet, please try again later
order-amount-over-limit Order quantity over limit
base-symbol-trade-disabled The trading pair is disabled
base-operation-forbidden The user is not in the whitelist or the currency does not allow OTC transactions and other prohibited actions
account-get-accounts-inexistent-error The account does not exist under the user
account-account-id-inexistent The account does not exist
order-disabled The trading pair is suspended and cannot place an order
cancel-disabled The trading pair is suspended and the order cannot be canceled
order-invalid-price The price of the order is illegal (for example, the market price cannot have a price, or the price of the limit order exceeds the market price by 10%)
order-accountbalance-error Insufficient account balance
order-limitorder-price-min-error The selling price cannot be lower than the specified price
order-limitorder-price-max-error The purchase price cannot be higher than the specified price
order-limitorder-amount-min-error The order quantity cannot be lower than the specified quantity
order-limitorder-amount-max-error The order quantity cannot be higher than the specified quantity
order-etp-nav-price-min-error The order price cannot be lower than the specified ratio of net value
order-etp-nav-price-max-error The order price cannot be higher than the specified ratio such as net value
order-orderprice-precision-error Transaction price precision error
order-orderamount-precision-error Transaction amount precision error
order-value-min-error The order transaction amount cannot be lower than the specified amount
order-marketorder-amount-min-error The selling amount cannot be lower than the specified amount
order-marketorder-amount-buy-max-error The market order buy amount cannot be higher than the specified amount
order-marketorder-amount-sell-max-error The sell amount of a market order cannot be higher than the specified amount
order-holding-limit-failed The order exceeds the position limit of the currency
order-type-invalid Invalid order type
order-orderstate-error Order state error
order-date-limit-error The query time cannot exceed the system limit
order-source-invalid Invalid order source
order-update-error Update data error
order-user-cancel-forbidden The order type is IOC and cancellation is not allowed
order-price-greater-than-limit The order price is higher than the order limit price before the opening, please place a new order
order-price-less-than-limit The order price is lower than the order limit price before the opening, please place a new order
order-stop-order-hit-trigger The stop loss order is triggered by the current price
market-orders-not-support-during-limit-price-trading Market orders are not supported for time-limited orders
price-exceeds-the-protective-price-during-limit-price-trading The price exceeds the protective price during the price limit
invalid-client-order-id Client order ID duplicated
invalid-interval Query start and end window settings are wrong
invalid-start-date The query start date contains an invalid value
invalid-end-date The query start date contains an invalid value
invalid-start-time The query start time contains invalid values
invalid-end-time Query start time contains invalid value
validation-constraints-required Specified required parameter is missing
not-found The order does not exist when canceling the order
base-not-found Invalid client order ID canceled too many orders, try again after an hour

place an order

API Key Permissions: Transactions Frequency limit value; 100 times/2s

Send a new order for matching.

HTTP requests

Request:

{
   "account-id": "100009",
   "amount": "10.1",
   "price": "100.1",
   "source": "api",
   "symbol": "ethusdt",
   "type": "buy-limit",
   "client-order-id": "a0001"
}

Request parameters

Parameter Name Data Type Required Default Value Description
account-id string true NA Account ID. Refer to GET /v1/account/accounts for valid values. For spot transactions, use the account ID of the ‘spot’ account.
symbol string true NA Trading pair, such as btcusdt, ethbtc, etc. Refer to GET /v1/common/symbols for valid values.
type string true NA Order type, including buy-market, sell-market, buy-limit, sell-limit
amount string true NA Order amount (for market orders, it represents the buying amount).
price string false NA Order price (not applicable for market orders).
source string false spot-api Order source. Use "spot-api" for spot transactions.
client-order-id string false NA User-defined order ID (maximum length of 64 characters, must be unique within 24 hours).

Response:

{
   "status": "ok",
   "data": "59378"
}

Response data

The returned master data object is a string corresponding to the order number.

If the client order ID is reused (within 24 hours), the node will return an error message invalid.client.order.id.

Batch order

API Key Permissions: Transaction
Frequency limit (NEW): 50 times/2s

A batch of up to 10 orders

HTTP requests

Request:

[
{
     "account-id": "123456",
     "price": "7801",
     "amount": "0.001",
     "symbol": "btcusdt",
     "type": "sell-limit",
     "client-order-id": "c1"
},
{
     "account-id": "123456",
     "price": "7802",
     "amount": "0.001",
     "symbol": "btcusdt",
     "type": "sell-limit",
     "client-order-id": "d2"
}
]

Request parameters

Parameter Name Data Type Required Default Value Description
[{account-id string true NA Account ID. Refer to GET /v1/account/accounts for valid values. For spot transactions, use the account ID of the ‘spot’ account.
symbol string true NA Trading pair, such as btcusdt, ethbtc, etc. Refer to GET /v1/common/symbols for valid values.
type string true NA Order type, including buy-market, sell-market, buy-limit, sell-limit
amount string true NA Order amount (for market orders, it represents the buying amount)
price string false NA Order price (not applicable for market orders)
source string false spot-api Order source. Use “spot-api” for spot transactions.
client-order-id}] string false NA User-defined order ID (maximum length of 64 characters, must be unique within 24 hours)

Response:

{
     "status": "ok",
     "data": [
         {
             "order-id": 61713400772,
             "client-order-id": "c1"
         },
         {
             "order-id": 61713400940,
             "client-order-id": "d2"
         }
     ]
}

Response data

Field Name Data Type Description
[{ order-id integer Order ID
client-order-id string User-defined order ID (if provided)
err-code string Error code for rejected orders (only applicable to rejected orders)
err-msg }] string Error message for rejected orders (only applicable to rejected orders)

If the client order ID is reused (within 24 hours), the node returns the order ID and client order ID of the previous order.

Cancel order

API Key Permissions: Transaction
Frequency limit value (NEW): 100 times/2s

This interface sends a request to cancel an order.

HTTP requests

Request parameters

Parameter name Required Data type Description Default value Value range
order-id true string Order ID, to be filled in the path    

Success response:

{
   "status": "ok",
   "data": "59378"
}

Response data

The returned master data object is a string corresponding to the order number.

error code

Failure response:

{
   "status": "error",
   "err-code": "order-orderstate-error",
   "err-msg": "Order status error",
   "order-state":-1 // current order state
}

In the returned field list, the possible values of order-state include -

order-state Description
-1 order was already closed in the long past (order state = canceled, partial-canceled, filled, partial-filled)
5 Partially canceled
6 Filled
7 Canceled
10 Canceling

Cancel order (based on client order ID)

API Key Permissions: Transaction
Frequency limit value (NEW): 100 times/2s

This interface sends a request to cancel an order.

HTTP requests

Request:

{
   "client-order-id": "a0001"
}

Request parameters

Parameter name Required Type Description Default value Value range
client-order-id true string User-defined order number    

Response:

{
   "status": "ok",
   "data": "10"
}

Response data

Field Name Data Type Description
data integer Order cancellation status code
Status Code Description
-1 Order was already closed in the long past (order state = canceled, partial-canceled, filled, partial-filled)
0 client-order-id not found
5 Partial-canceled
6 Filled
7 Canceled
10 Canceling

Query current unfilled orders

API Key Permission: Read
Frequency limit value (NEW): 50 times/2s

Query the orders that have been submitted but have not been fully executed or canceled.

HTTP requests

Request:

{
    "account-id": "100009",
    "symbol": "ethusdt",
    "side": "buy"
}

Request parameters

Parameter Name Data Type Required Default Value Description
account-id string false NA Account ID, refer to GET /v1/account/accounts for value. Spot transactions use the account-id of the ‘spot’ account
symbol string false NA Trading pair, namely btcusdt, ethbtc… (refer to GET /v1/common/symbols for value)
side string false both Specify to only return orders in one direction, possible values are: buy, sell. By default, both directions are returned.
from string false   Query starting ID
direct string false(if field “from” is defined, this field “direct” becomes Required)   Query direction, prev means forward; next means backward (required if the ‘from’ field is set)
size int false 100 Return the quantity of the order, the maximum value is 500.

Response:

{
   "status": "ok",
   "data": [
     {
       "id": 5454937,
       "symbol": "ethusdt",
       "account-id": 30925,
       "amount": "1.0000000000000000000",
       "price": "0.453000000000000000",
       "created-at": 1530604762277,
       "type": "sell-limit",
       "filled-amount": "0.0",
       "filled-cash-amount": "0.0",
       "filled-fees": "0.0",
       "source": "web",
       "client-order-id": "",
       "state": "submitted"
     }
   ]
}

Response data

Field Name Data Type Description
id integer Order ID, can be used as the ‘from’ field for the next page turning query request
client-order-id string User-defined order number (available for all open orders)
symbol string Trading pair, such as btcusdt, ethbtc
price string Transaction price of limit order
created-at int Timestamp of order creation adjusted to Singapore time, in milliseconds
type string Order type
filled-amount string Amount of the filled part of the order
filled-cash-amount string The total price of the filled portion of the order
filled-fees string Total transaction fees paid
source string Fill in “api” for spot transactions
state string Order status, including submitted, partial-filled, canceling, created
account-id long Account ID
amount string Order quantity

Cancel orders in batches (open orders)

API Key Permissions: Transaction
Frequency limit value (NEW): 50 times/2s

This interface sends a request to cancel orders in batches.

HTTP requests

Request parameters

Parameter Name Required Type Description Default Value Value Range
account-id false string Account ID, refer to GET /v1/account/accounts for available values.    
symbol false string List of trading symbols (up to 10 symbols, multiple symbols separated by commas). e.g. btcusdt, bccbtc…(Refer to GET /v1/common/symbols) all  
side false string Trading direction.   “buy” or “sell”,If not provided, all orders that meet the conditions and have not been executed will be returned.
size false int Number of records to be returned. 100 [1, 100]

Response:

{
   "status": "ok",
   "data": {
     "success-count": 2,
     "failed-count": 0,
     "next-id": 5454600
   }
}

Response data

Parameter Name Required Data Type Description Value Range
success-count true int Number of successfully canceled orders  
failed-count true int Number of failed orders  
next-id true long Next order ID that meets the cancellation criteria for continuation  

Cancel orders in bulk

API Key Permissions: Transaction
Frequency limit value (NEW): 50 times/2s

This interface sends cancellation requests for multiple orders (based on id) at the same time.

HTTP requests

Request:

{
   "client-order-ids": [
    "5983466", "5722939", "5721027", "5719487"
   ]
}

Request parameters

Parameter Name Required Data Type Description Default Value Value Range
order-ids false string[] List of order IDs (either order-ids or client-order-ids must be provided, and the list should not exceed 50 orders)   Maximum 50 order IDs at a time
client-order-ids false string[] List of user-made order numbers (either order-ids or client-order-ids must be provided, and the list should not exceed 50 orders)   Maximum 50 client order IDs at a time

Response:

{
     "status": "ok",
     "data": {
         "success": [
             "5983466"
         ],
         "failed": [
             {
               "err-msg": "Incorrect order state",
               "order-state": 7,
               "order-id": "",
               "err-code": "order-orderstate-error",
               "client-order-id": "first"
             },
             {
               "err-msg": "Incorrect order state",
               "order-state": 7,
               "order-id": "",
               "err-code": "order-orderstate-error",
               "client-order-id": "second"
             },
             {
               "err-msg": "The record is not found.",
               "order-id": "",
               "err-code": "base-not-found",
               "client-order-id": "third"
             }
           ]
     }
}

Response data

Field Name Data Type Description
{ success string[] List of successfully canceled orders (can be order ID list or client order ID list as per user request)
failed } string[] List of failed orders (can be order ID list or client order ID list as per user request)

Failed order list:

Field Name Data Type Description
[{ order-id string Order number (if the user includes order ID when creating an order, this field must also be included)
client-order-id string User-made order number (if the user includes client order ID when creating an order, this field must also be included)
err-code string Order rejection error code (only valid for rejected orders)
err-msg string Order rejection error message (only valid for rejected orders)
order-state }] string Current order state (if applicable)

Possible values for order-state:

order-state Description
-1 Order was already closed in the past (order state = canceled, partial-canceled, filled, partial-filled)
5 Partially canceled
6 Filled
7 Canceled
10 Canceling

Query order details

API Key Permission: Read
Frequency limit value (NEW): 50 times/2s

This interface returns the latest status and details of the specified order. Orders created through the API cannot be queried after being canceled for more than 2 hours.

HTTP requests

Request parameters

Parameter name Required Data Type Description Default value Value range
order-id true string Order ID,Place it within path    

Response:

{  
  "status": "ok",
  "data": 
  {
    "id": 59378,
    "symbol": "ethusdt",
    "account-id": 100009,
    "amount": "10.1000000000",
    "price": "100.1000000000",
    "created-at": 1494901162595,
    "type": "buy-limit",
    "field-amount": "10.1000000000",
    "field-cash-amount": "1011.0100000000",
    "field-fees": "0.0202000000",
    "finished-at": 1494901400468,
    "source": "api",
    "state": "filled",
    "canceled-at": 0,
    "client-order-id": ""
  }
}

Response data

Field name Required Data type Description Value range  
account-id true long Account ID    
amount true string Order quantity    
canceled-at false long Order cancellation time    
created-at true long Order creation time    
field-amount true string Transaction amount    
field-cash-amount true string Total transaction amount    
field-fees true string Transaction fee (buy for coins, sell for money)    
finished-at false long The time when the order becomes finalized, not the transaction time, including the “cancelled” status    
id true long Order ID    
client-order-id false string User-defined order number (all open orders can return client-order-id (if any); only closed orders within 7 days (based on order creation time) (state <> canceled) Can return client-order-id (if any); Only closed orders (state = canceled) within 24 hours (based on order creation time) can return client-order-id (if any)    
price true string Order price    
source true string Order source api  
state true string Order status submitted, partial-filled, partially-canceled, filled, canceled, created  
symbol true string Trading pair btcusdt, ethbtc, rcneth …  
type true string Order type buy-market: buy at market price, sell-market: sell at market price, buy-limit: buy at limit price, sell-limit: sell at limit price  

Query order details (based on client order ID)

API Key Permission: Read
Frequency limit value (NEW): 50 times/2s

This interface returns the latest order status and details of the specified user-defined order number (within 24 hours). Orders created through the API cannot be queried after being canceled for more than 2 hours.

HTTP requests

Request parameters

Parameter name Required Type Description Default value
clientOrderId true string User-defined order number  

Response:

{  
  "status": "ok",
  "data": 
  {
    "id": 59378,
    "symbol": "ethusdt",
    "account-id": 100009,
    "amount": "10.1000000000",
    "price": "100.1000000000",
    "created-at": 1494901162595,
    "type": "buy-limit",
    "field-amount": "10.1000000000",
    "field-cash-amount": "1011.0100000000",
    "field-fees": "0.0202000000",
    "finished-at": 1494901400468,
    "source": "api",
    "state": "filled",
    "canceled-at": 0,
    "client-order-id": ""
  }
}

Response data

Field name Required Data type Description Value range
account-id true long Account ID  
amount true string Order quantity  
canceled-at false long Order cancellation time  
created-at true long Order creation time  
field-amount true string Transaction amount  
field-cash-amount true string Total transaction amount  
field-fees true string Transaction fee (buy for coins, sell for money)  
finished-at false long The time when the order becomes finalized, including the “cancelled” status  
id true long Order ID  
client-order-id false string User-defined order number (Only orders within 24 hours (based on order creation time) can be queried)  
price true string Order price  
source true string Order source api
state true string Order status submitted, partial-filled, partially-canceled, filled, canceled, created
symbol true string Trading pair btcusdt, ethbtc, rcneth …
type true string Order type buy-market: buy at market price, sell-market: sell at market price, buy-limit: buy at limit price, sell-limit: sell at limit price

If the client order ID does not exist, the following error message will be returned { “status”: “error”, “err-code”: “base-record-invalid”, “err-msg”: “record invalid”, “data”: null }

transaction details

API Key Permission: Read
Frequency limit value (NEW): 50 times/2s

This interface returns the transaction details of the specified order.

HTTP requests

Request parameters

Parameter name Required Type Description Default value
order-id true string Order ID, fill in the path  

Response:

{  
  "status": "ok",
  "data": [
    {
      "id": 29553,
      "order-id": 59378,
      "match-id": 59335,
      "trade-id": 100282808529,
      "symbol": "ethusdt",
      "type": "buy-limit",
      "source": "api",
      "price": "100.1000000000",
      "filled-amount": "9.1155000000",
      "filled-fees": "0.0182310000",
      "created-at": 1494901400435,
      "role": "maker",
      "filled-points": "0.0",
      "fee-deduct-currency": "",
      "fee-currency": "usdt",
      "fee-deduct-state": "done"
    }
    ...
  ]
}

Response data

Field name Required Data type Description Value range
created-at true long Transaction timestamp  
filled-amount true string Filled amount  
filled-fees true string Transaction fee (positive value) or transaction rebate (negative value)  
fee-currency true string Currency of transaction fee or transaction fee rebate (transaction fee of buy order is based on base currency, transaction fee of sell order is based on quote currency; transaction fee rebate of buy order is based on quote currency, transaction fee rebate of sell order is based on base currency)  
id true long Order transaction record ID  
match-id true long Matching ID  
order-id true long Order ID  
trade-id false integer Unique trade ID  
price true string Transaction price  
source true string Order source api
symbol true string Trading pair btcusdt, ethbtc, rcneth, …
type true string Order type buy-market, sell-market, buy-limit, sell-limit
role true string Transaction role maker, taker
filled-points true string Deduction amount  
fee-deduct-currency true string Deduction type deduction type. if blank, the transaction fee is based on original currency
fee-deduct-state true string Deduction status Fee deduction status,In deduction:ongoing,Deduction completed:done

Note:

Search history orders

API Key Permission: Read
Frequency limit value (NEW): 50 times/2s

This interface queries historical orders based on search conditions. Orders created through the API cannot be queried after being canceled for more than 2 hours.

Users can choose to query historical orders by “time range” instead of the original query method of “date range”.

It is recommended that users query historical orders by “time range”.

HTTP requests

Request parameters

Parameter name Required Type Description Default value Value range
symbol true string Trading pair   btcusdt, ethbtc… (value reference GET /v1/common/symbols)
types false string Combinations of order types to query, separated by commas   buy-market: buy at market price, sell-market: sell at market price, buy-limit: buy at limit price, sell-limit: sell at limit price
start-time false long Query start time, the time format is UTC time in milliseconds. Query based on order generation time -48h Value range [((end-time) – 48h), (end-time)], the maximum query window is 48 hours, and the translation range is the nearest for 180 days. The translation range of the query window for historical orders that have been completely canceled is only the last 2 hours (state=”canceled”).
end-time false long Query end time, the time format is UTC time in milliseconds. Query based on order generation time present Value range [(present-179d), present], the maximum query window is 48 hours, the translation range is the last 180 days, and the query window translation range of completely canceled historical orders is only the latest 2 hours (state=”canceled”).
states true string Combination of order states to query, separated by ‘,’. partial-canceled, filled, canceled  
from false string Query start ID   If it is a backward query, it will be assigned the last ID obtained in the last query result; if it is a forward query, it will be assigned the first ID obtained in the last query result.
direct false string Query direction   prev forward; next backward
size false string Query record size 100 [1, 100]

Response:

{  
  "status": "ok",
  "data": [
    {
      "id": 59378,
      "symbol": "ethusdt",
      "account-id": 100009,
      "client-order-id": "",
      "amount": "10.1000000000",
      "price": "100.1000000000",
      "created-at": 1494901162595,
      "type": "buy-limit",
      "field-amount": "10.1000000000",
      "field-cash-amount": "1011.0100000000",
      "field-fees": "0.0202000000",
      "finished-at": 1494901400468,
      "source": "api",
      "state": "filled",
      "canceled-at": 0
    }
    ...
  ]
}

Response data

Parameter name Required Data type Description Value range
account-id true long Account ID  
amount true string Order quantity  
canceled-at false long The time when the cancellation request was received  
created-at true long Order creation time  
field-amount true string Transaction amount  
field-cash-amount true string Total transaction amount  
field-fees true string Transaction fee (buying is base currency, selling is price currency)  
finished-at false long Last transaction time  
id true long Order ID, no order of size, can be used as the ‘from’ field of the next page turning query request  
client-order-id false string User-defined order number (all open orders can return ‘client-order-id’ (if any); only closed orders within 7 days (based on order creation time) (state <> canceled) can return ‘client-order-id’ (if any); only closed orders (state = canceled) within 24 hours (based on order creation time) can be queried)  
price true string Order price  
source true string Order source api
state true string Order status submitted, partial-filled, partially-canceled, filled, canceled, created
symbol true string Trading pair btcusdt, ethbtc, rcneth …
type true string Order type submit-cancel: the order cancellation application has been submitted, buy-market: buy at the market price, sell-market: sell at the market price, buy-limit: buy at the limit price, sell-limit: sell at the limit price
Error code Corresponding error scenario
invalid_interval Start date is less than end date; or the time interval between start date and end date is greater than 2 days
invalid_start_date Start date is a date 180 days ago; or start date is a date in the future
invalid_end_date End date is a date 180 days ago; or end date is a date in the future

Search historical orders within the last 48 hours

API Key Permission: Read
Frequency limit value (NEW): 20 times/2s

This interface queries historical orders within the last 48 hours based on search criteria. Orders created through the API cannot be queried after being canceled for more than 2 hours.

HTTP requests

Request:

{
    "symbol": "btcusdt",
    "start-time": "1556417645419",
    "end-time": "1556533539282",
    "direct": "prev",
    "size": "10"
}

Request parameters

Parameter name Required Type Description Default value Value range
symbol false string Trading pair all btcusdt, ethbtc… (value reference GET /v1/common/symbols)
start-time false long Query start time (inclusive) Time 48 hours ago UTC time in milliseconds
end-time false long Query end time (inclusive) Query time UTC time in milliseconds
direct false string Order query direction (Note: it only works when the total number of retrieved items exceeds the limit of the size field) next prev (forward), next (backward)
size false int Number of items returned each time 100 [10, 1000]

Response:

{
    "status": "ok",
    "data": [
        {
            "id": 31215214553,
            "symbol": "btcusdt",
            "account-id": 4717043,
            "client-order-id": "",
            "amount": "1.000000000000000000",
            "price": "1.000000000000000000",
            "created-at": 1556533539282,
            "type": "buy-limit",
            "field-amount": "0.0",
            "field-cash-amount": "0.0",
            "field-fees": "0.0",
            "finished-at": 1556533568953,
            "source": "web",
            "state": "canceled",
            "canceled-at": 1556533568911
        }
    ]
}

Response data

Parameter name Required Data type Description Value range
{account-id true long Account ID  
amount true string Order quantity  
canceled-at false long The time when the cancellation request was received  
created-at true long Order creation time  
field-amount true string Transaction amount  
field-cash-amount true string Total transaction amount  
field-fees true string Transaction fee (buying is base currency, selling is price currency)  
finished-at false long Last transaction time  
id true long Order ID, no size order  
client-order-id false string User-defined order number (only closed orders (state <> canceled) within 48 hours (based on order creation time) can return client-order-id (if any); only 24 hours (state = canceled) can be queried)
price true string Order price  
source true string Order source api
state true string Order status partial-canceled, partially-filled, completely-filled, canceled
symbol true string Trading pair btcusdt, ethbtc, rcneth, etc.
type } true string Order type buy-market, sell-market, buy-limit, sell-limit, etc.
next-time false long Next query start time (valid when the request field “direct” is “prev”), next query end time (valid when the request field “direct” is “next”).Note: Only when the total number of items in the search result exceeded the limitation defined in “size”, this field exists. UTC time in milliseconds

Current and historical transactions

API Key Permission: Read
Frequency limit value (NEW): 20 times/2s

This interface queries current and historical transaction records based on search criteria.

HTTP requests

Request parameters

Parameter name Required Type Description Default value Value range
symbols false string Trading pair N/A btcusdt, ethbtc… (value reference GET /v1/common/symbols)
types false string Combination of order types to query, separated by ‘,’ all buy-market: buy at market price, sell-market: sell at market price, buy-limit: buy at limit price, sell-limit: sell at limit price
start-date false string Query start date (Singapore time zone), date format yyyy-mm-dd -1d Range of values [((end-date) – 1), (end-date)], the maximum query window is 2 days, and the window translation range is the last 61 days.
end-date false string Query end date (Singapore time zone), date format yyyy-mm-dd today Value range [(today-60), today], the maximum query window is 2 days, and the window translation range is the last 61 days.
from false string Query start ID N/A If it is a backward query, it will be assigned the last ID (not trade-id) obtained in the last query result; if it is a forward query, it will be assigned the first ID (not trade-id) obtained in the last query result.
direct false string Query direction next prev (forward), next (backward)
size false string Query record size 100 [1, 500]

Response:

{  
  "data": [
    {
      "id": 29553,
      "order-id": 59378,
      "match-id": 59335,
      "symbol": "ethusdt",
      "type": "buy-limit",
      "source": "api",
      "price": "100.1000000000",
      "filled-amount": "9.1155000000",
      "filled-fees": "0.0182310000",
      "created-at": 1494901400435,
      "trade-id": 100282808529,
      "role": taker,
      "filled-points": "0.0",
      "fee-currency": "eth",
      "fee-deduct-state": "done",
      "fee-deduct-currency": ""
    }
    ...
  ]
}

Response data

Parameter name Required Data type Description Value range
created-at true long Transaction timestamp.  
filled-amount true string Filled amount.  
filled-fees true string Transaction fee (positive value) or transaction rebate (negative value).  
fee-currency true string Transaction fee or transaction rebate currency. The transaction fee currency for buy orders is the base currency, and the transaction fee currency for sell orders is the pricing currency. The transaction rebate currency for buy orders is the pricing currency, and the transaction rebate currency for sell orders is the base currency.  
id true long Order transaction record ID. It is not the order ID of size and can be used as the “from” field for the next page-turning query request.  
match-id true long Matching ID.  
order-id true long Order ID.  
trade-id false integer Unique trade ID.  
price true string Transaction price.  
source true string Order source. api
symbol true string Trading pair. btcusdt, ethbtc, rcneth …
type true string Order type. buy-market: buy at market price, sell-market: sell at market price, buy-limit: buy at limit price, sell-limit: sell at limit price
role true string Transaction role. maker, taker
filled-points true string Deduction amount .  
fee-deduct-currency true string Deduction type.  
fee-deduct-state true string Deduction status. deduction in progress: ongoing, deduction completed: done

Note:

Error code Corresponding error scenario
invalid_interval The start date is greater than the end date, or the time interval between the start and end dates is > 2 days.
invalid_start_date The start date is 61 days ago or in the future.
invalid_end_date The end date is 61 days ago or in the future.

Websocket market data

Introduction

Access URL

Quotation request address

wss://api.bitv.com/ws

data compression

All data returned by the WebSocket market interface is compressed by GZIP, and the client needs to decompress it after receiving the data.

Heartbeat message

{"ping": 1492420473027}

When the user’s Websocket client connects to the Websocket server, the server will periodically (currently set to 5 seconds) send a ping message to it and include an integer value.

{"pong": 1492420473027}

When the user’s Websocket client receives this heartbeat message, it should return a pong message containing the same integer value.

Subscribe to topics

Sub request:

{
   "sub": "market.btcusdt.kline.1min",
   "id": "id1"
}

After successfully establishing a connection to the Websocket server, the Websocket client sends a request to subscribe to a specific topic:

{ “sub”: “topic to sub”, “id”: “id generate by client” }

Sub response:

{
   "id": "id1",
   "status": "ok",
   "subbed": "market.btcusdt.kline.1min",
   "ts": 1489474081631
}

After successfully subscribing, the Websocket client will receive an acknowledgment.

After that, once the subscribed topic is updated, the Websocket client will receive the update message (push) pushed by the server.

unsubscribe

UnSub request:

{
   "unsub": "market.btcusdt.trade.detail",
   "id": "id4"
}

The format for unsubscribing is as follows:

{ “unsub”: “topic to unsub”, “id”: “id generate by client” }

UnSub response:

{
   "id": "id4",
   "status": "ok",
   "unsubbed": "market.btcusdt.trade.detail",
   "ts": 1494326028889
}

Successful unsubscribe confirmation.

request data

The Websocket server also supports one-time request data (pull).

The format of a one-time request is as follows:

{ “req”: “topic to req”, “id”: “id generate by client” }

For the specific format of the data returned at one time, see each topic.

Frequency Limit

Data request (req) frequency limit rules

Every two requests for a single connection cannot be less than 100ms.

error code

The following are the error codes, error messages and descriptions of the WebSocket market interface.

Error Code Error Message Description
bad-request invalid topic Topic error
bad-request invalid symbol Symbol error
bad-request symbol trade not open now The trading pair is not currently open
bad-request 429 too many request Too many requests
bad-request unsub with not subbed topic Attempt to unsubscribe from an unsubscribed topic
bad-request not json string Invalid JSON format in the request
1008 header required correct cloud-exchange Incorrect exchangeCode parameter
bad-request request timeout Request timeout

K line data

Topic Subscription

Once the K-line data is generated, the Websocket server will push it to the client through this subscription topic interface:

market.$symbol$.kline.$period$

Subscription Request

{
   "sub": "market.ethbtc.kline.1min",
   "id": "id1"
}

parameters

parameter data type required description value range
symbol string true transaction code btcusdt, ethbtc…etc.
period string true K-line period 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year

Response

{
  "id": "id1",
  "status": "ok",
  "subbed": "market.ethbtc.kline.1min",
  "ts": 1489474081631 //system response time
}

Update example

{
  "ch": "market.ethbtc.kline.1min",
  "ts": 1489474082831, //system update time
  "tick": {
    "id": 1489464480,
    "amount": 0.0,
    "count": 0,
    "open": 7962.62,
    "close": 7962.62,
    "low": 7962.62,
    "high": 7962.62,
    "vol": 0.0
  }
}

Data update field list

Field Data Type Description
id integer unix time, also used as K line ID
amount float volume
count integer transaction count
open float opening price
close float closing price (when the K line is the latest one, it is the latest transaction price)
low float lowest price
high float highest price
vol float transaction volume, ie sum (each transaction price * transaction volume of this transaction)

Data Request

To obtain K-line data at one time by request, the following parameters need to be provided additionally: (Up to 300 items can be returned each time)

{
   "req": "market.$symbol.kline.$period",
   "id": "id generated by client",
   "from": "from time in epoch seconds",
   "to": "to time in epoch seconds"
}
Parameter Data Type Required Default Value Description Value Range
from integer false 1501174800 (2017-07-28T00:00:00+08:00) Start time (Epoch time in seconds) [1501174800, 2556115200]
to integer false 2556115200 (2050-01-01T00:00:00+08:00) End time (Epoch time in seconds) [1501174800, 2556115200] or ($from, 2556115200] if “from” is set

Depth of market market data

This topic sends the latest Depth of Market snapshot. The snapshot frequency is 1 time per second.

Topic Subscription

market.$symbol.depth.$type

Subscribe request

{
   "sub": "market.btcusdt.depth.step0",
   "id": "id1"
}

parameters

parameter data type required default value description value range
symbol string true NA transaction symbol btcusdt, ethbtc… (value reference GET /v1/common/symbols)
type string true step0 merge depth type step0, step1, step2, step3, step4, step5

“type” merge depth type

Value Description
step0 Do not merge depth
step1 Aggregation level = precision*10
step2 Aggregation level = precision*100
step3 Aggregation level = precision*1000
step4 Aggregation level = precision*5000
step5 Aggregation level = precision*10000

When the type value is ‘step0’, the default depth is 150 steps; When the type value is ‘step1’, ‘step2’, ‘step3’, ‘step4’, ‘step5’, the default depth is 20 steps.

Response

{
  "id": "id1",
  "status": "ok",
  "subbed": "market.btcusdt.depth.step0",
  "ts": 1489474081631 //system response time
}

Update example

{
  "ch": "market.htusdt.depth.step0",
  "ts": 1572362902027, //system update time
  "tick": {
    "bids": [
      [3.7721, 344.86],// [price, size]
      [3.7709, 46.66] 
    ],
    "asks": [
      [3.7745, 15.44],
      [3.7746, 70.52]
    ],
    "version": 100434317651,
    "ts": 1572362902012 //quote time
  }
}

Data update field list

Field Data Type Description
bids object All current bids [price, size]
asks object All current ask orders [price, size]
version integer Internal field
ts integer Timestamp of Singapore time in milliseconds

Data Request

Support data request method to obtain market depth data at one time:

{
   "req": "market.btcusdt.depth.step0",
   "id": "id10"
}

Market depth MBP market data (incremental push)

Users can subscribe to this channel to receive the incremental data push of the latest in-depth market Market By Price (MBP); at the same time, this channel supports users to request full data in the form of req.

Suggested downstream data processing methods:
1) Subscribe to incremental data and start caching;
2) Request the full amount of data (equal number of gears) and align with the prevSeqNum in the buffered incremental data according to the seqNum of the full amount of message;
3) Start continuous incremental data reception and calculation, construct and continuously update the MBP order book;
4) The prevSeqNum of each incremental data must be consistent with the seqNum of the previous incremental data, otherwise it means that there is incremental data loss, and the full amount of data must be reacquired and aligned;
5) If the incremental data received includes a new price gear, the price gear must be inserted into the appropriate position in the MBP order book;
6) If the incremental data received includes an existing price gear, but the size is different, the size of the price gear in the MBP order book must be replaced;
7) If the size of a certain price gear in the incremental data is 0, the price gear must be deleted from the MBP order book;
8) If an update of two or more price levels is received in a single piece of incremental data, these price levels must be updated in the MBP order book at the same time.

Currently only supports the push of 5-file/20-file MBP step-by-step increments and 150-file MBP snapshot increments, the difference between the two is -
1) The depth is different;
2) 5 files/20 files are incremental MBP quotations one by one, and 150 files are 100 millisecond timed snapshot incremental MBP quotations;
3) When only one-sided market changes occur in the 5-level/20-level order book, the incremental push only includes unilateral market updates. For example, the push message contains the array of asks, but not the array of bids;

{
    "ch": "market.btcusdt.mbp.5",
    "ts": 1573199608679,
    "tick": {
        "seqNum": 100020146795,
        "prevSeqNum": 100020146794,
        "asks": [
            [645.140000000000000000, 26.755973959140651643]
        ]
    }
}

When the 150-level order book only has a unilateral market change, the incremental push includes a bilateral market update, but one side of the market is empty, for example, the push message contains the update of the array asks and also includes an empty array of bids;

{
    "ch":"market.btcusdt.mbp.150",
    "ts":1573199608679,
    "tick":{
        "seqNum":100020146795,
        "prevSeqNum":100020146794,
        "bids":[ ],
        "asks":[
            [645.14,26.75597395914065]
        ]
    }
}

In the future, the data behavior of the 150-level incremental push will be consistent with that of the 5-level/20-level increment, that is, when the unilateral market depth changes, the push message will not include the other side’s market depth;
4) When the 150 order books have not changed within the 100 millisecond interval, the incremental push contains bids and asks empty arrays;

{
    "ch":"market.zecusdt.mbp.150",
    "ts":1585074391470,
    "tick":{
        "seqNum":100772868478,
        "prevSeqNum":100772868476,
        "bids":[  ],
        "asks":[  ]
    }
}

However, the 5-level/20-level MBP is incremented one by one, and no data is pushed when the order book does not change;
In the future, the data behavior of 150 increments will be consistent with that of 5 increments, that is, when the order book has not changed, empty messages will no longer be pushed;
5) Only some trading pairs (btcusdt, ethusdt, xrpusdt, eosusdt, ltcusdt, etcusdt, adausdt, dashusdt, bsvusdt) are supported in the 5-level/20-level incremental market, and 150-level snapshot increments support all trading pairs.

The REQ channel supports the acquisition of full data of 5 files/20 files/150 files.

Subscribe to incremental push

market.$symbol.mbp.$levels

Sub request

{
   "sub": "market.btcusdt.mbp.5",
   "id": "id1"
}

Request full data

market.$symbol.mbp.$levels

Req request

{
   "req": "market.btcusdt.mbp.5",
   "id": "id2"
}

parameters

parameter data type required default value description value range
symbol string true NA transaction code (wildcards are not supported)  
levels integer true NA depth level (value: 5, 20, 150) currently only supports 5 levels, 20 levels, or 150 levels of depth

Response (incremental subscription)

{
   "id": "id1",
   "status": "ok",
   "subbed": "market.btcusdt.mbp.5",
   "ts": 1489474081633 //system response time
}

Incremental Update (incremental subscription)

{
"ch": "market.btcusdt.mbp.5",
"ts": 1573199608679, //system update time
   "tick": {
            "seqNum": 100020146795,
            "prevSeqNum": 100020146794,
            "asks": [
                  [645.140000000000000000, 26.755973959140651643] // [price, size]
            ]
       }
}

Response (full request)

{
"id": "id2",
"rep": "market.btcusdt.mbp.150",
"status": "ok",
"data": {
"seqNum": 100020142010,
"bids": [
[618.37, 71.594], // [price, size]
[423.33, 77.726],
[223.18, 47.997],
[219.34, 24.82],
[210.34, 94.463]
     ],
"asks": [
[650.59, 14.909733438479636],
[650.63, 97.996],
[650.77, 97.465],
[651.23, 83.973],
[651.42, 34.465]
]
}
}

Data update field list

Field Data Type Description
seqNum integer message sequence number
prevSeqNum integer sequence number of the previous message
bids object bids, sorted by price in descending order, [“price”,”size”]
asks object Ask orders, sorted by price in ascending order, [“price”,”size”]

Market depth MBP market data (full push)

Users can subscribe to this channel to receive the full data push of the latest in-depth market Market By Price (MBP). The push frequency is about once every 100 milliseconds.

Subscribe to incremental push

market.$symbol.mbp.refresh.$levels

Sub request

{
"sub": "market.btcusdt.mbp.refresh.20",
"id": "id1"
}

parameters

parameter data type required default value description value range
symbol string true NA transaction code (wildcards are not supported)  
levels integer true NA depth level 5, 10, 20

Response

{
"id": "id1",
"status": "ok",
"subbed": "market.btcusdt.mbp.refresh.20",
"ts": 1489474081631 //system response time
}

Refresh Update

{
"ch": "market.btcusdt.mbp.refresh.20",
"ts": 1573199608679, //system update time
"tick": {

"seqNum": 100020142010,
"bids": [
[618.37, 71.594], // [price, size]
[423.33, 77.726],
[223.18, 47.997],
[219.34, 24.82],
[210.34, 94.463], ... // omit the remaining 15 files
    ],
"asks": [
[650.59, 14.909733438479636],
[650.63, 97.996],
[650.77, 97.465],
[651.23, 83.973],
[651.42, 34.465], ... // omit the remaining 15 files
]
}
}

Data update field list

Field Data Type Description
seqNum integer message sequence number
bids object bids, sorted by price in descending order: [“price”,”size”]
asks object Ask orders, sorted by price in ascending order: [“price”,”size”]

Buy one sell one tick by tick

When any of the data of the first price of buying, the first amount of buying, the first price of selling, and the first amount of selling changes, this topic will be updated one by one.

Topic Subscription

market.$symbol.bbo

Subscribe request

{
   "sub": "market.btcusdt.bbo",
   "id": "id1"
}

parameters

Parameter name Data Type Required Default Value Description Value Range
symbol string true NA Transaction symbol btcusdt, ethbtc… (value reference GET /v1/common/symbols)

Response

{
   "id": "id1",
   "status": "ok",
   "subbed": "market.btcusdt.bbo",
   "ts": 1489474081631 //system response time
}

Update example

{
    "ch": "market.btcusdt.bbo",
    "ts": 1761731251360,
    "tick":
    {
        "seqId": 63536598,
        "ask": 0.03553,
        "askSize": 0.0399,
        "bid": 0.03549,
        "bidSize": 0.0155,
        "quoteTime": 1761731251358,
        "symbol": "btcusdt"
    }
}

Data update field list

Field Data Type Description
symbol string transaction code
quoteTime long Handicap update time
bid float buy price
bidSize float buy quantity
ask float ask price
askSize float sell quantity
seqId int message sequence number

transaction details

Topic Subscription

This topic provides a tick-by-tick breakdown of the latest transactions in the market.

market.$symbol.trade.detail

Subscribe request

{
   "sub": "market.btcusdt.trade.detail",
   "id": "id1"
}

parameters

Parameter Data Type Required Default Value Description Value Range
symbol string true NA Transaction symbol btcusdt, ethbtc… (refer to GET /v1/common/symbols for values)

Response

{
   "id": "id1",
   "status": "ok",
   "subbed": "market.btcusdt.trade.detail",
   "ts": 1489474081631 //system response time
}

Update example

{
   "ch": "market.btcusdt.trade.detail",
   "ts": 1489474082831, //system update time
   "tick": {
         "id": 14650745135,
         "ts": 1533265950234, //trade time
         "data": [
             {
                 "amount": 0.0099,
                 "ts": 1533265950234, //trade time
                 "id": 146507451359183894799,
                 "tradeId": 102043494568,
                 "price": 401.74,
                 "direction": "buy"
             }
             // more Trade Detail data here
         ]
   }
}

Data update field list

Field Data Type Description
id integer Unique transaction ID (will be discarded)
tradeId integer Unique transaction ID (NEW)
amount float Volume (buy or sell side)
price float Transaction price
ts integer Transaction time (UNIX epoch time in millisecond)
direction string Active transaction party (order direction of taker): ‘buy’ or ‘sell’

Data Request

Support data request method to obtain transaction details data at one time (only up to 300 recent transaction records can be obtained):

{
   "req": "market.btcusdt.trade.detail",
   "id": "id11"
}

Market Overview

Topic Subscription

This topic provides a snapshot of the latest market overview within 24 hours. The snapshot frequency does not exceed 10 times per second.

market.$symbol.detail

Subscribe request

{
   "sub": "market.btcusdt.detail",
   "id": "id1"
}

parameters

Parameter Data Type Required Default Value Description Value Range
symbol string true NA Transaction symbol btcusdt, ethbtc, etc. (value reference GET /v1/common/symbols)

Response

{
   "id": "id1",
   "status": "ok",
   "subbed": "market.btcusdt.detail",
   "ts": 1489474081631 //system response time
}

Update example

{
   "ch": "market.btcusdt.detail",
   "ts": 1494496390001, //system update time
   "tick": {
     "amount": 12224.2922,
     "open": 9790.52,
     "close": 10195.00,
     "high": 10300.00,
     "id": 1494496390,
     "count": 15195,
     "low": 9657.00,
     "vol": 121906001.754751,
     "version": 126333992
   }
}

Data update field list

Field Data Type Description
id integer Unix time, also used as message ID
amount float 24-hour trading volume
count integer Number of transactions in 24 hours
open float 24-hour opening price
close float Latest price
low float 24-hour lowest price
high float 24-hour highest price
vol float 24-hour turnover
version integer Internal field

Data Request

Support data request method to obtain market summary data at one time:

{
   "req": "market.btcusdt.detail",
   "id": "id11"
}

Websocket assets and orders

Introduction

Access URL

Websocket assets and orders

wss://api.bitv.com/ws/v2

data compression

Data is not GZIP compressed.

Heartbeat message

When the user’s Websocket client connects to the WebSocket server, the server will periodically (currently set to 20 seconds) send a Ping message to it and include an integer value as follows:

{
"action": "ping",
"data": {
"ts": 1575537778295
}
}

When the user’s Websocket client receives this heartbeat message, it should return a Pong message containing the same integer value:

{
     "action": "pong",
     "data": {
           "ts": 1575537778295 // Use the ts value in the Ping message
     }
}

Valid values for action

Valid Values Value Description
sub Subscription data
req Data request
ping, pong Heartbeat data
push Push data, the data type sent from the server to the client

Frequency Limit

This version adopts a multi-dimensional frequency limiting strategy for users. The specific strategy is as follows:

Authentication

The authentication request format is as follows:

{
     "action": "req",
     "ch": "auth",
     "params": {
         "authType": "api",
         "accessKey": "e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx",
         "signatureMethod": "HmacSHA256",
         "signatureVersion": "2.1",
         "timestamp": "2019-09-01T18:16:16",
         "signature": "4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o="
     }
}

After successful authentication, the returned data format is as follows:

{
"action": "req",
"code": 200,
"ch": "auth",
"data": {}
}

Parameter Description

field required data type description
action true string Websocket data operation type, the fixed value for authentication is req
ch true string Request subject, the fixed value for authentication is auth
authType true string Authentication type, the fixed value for authentication is api. Note that this parameter is not included in the signature calculation.
accessKey true string AccessKey in the API Key you applied for
signatureMethod true string Signature method, the protocol for users to calculate the signature message hash, the fixed value is HmacSHA256
signatureVersion true string Signature protocol version, the fixed value is 2.1
timestamp true string Timestamp, the time (UTC time) when you make the request. Including this value in the query request helps prevent third parties from intercepting your request. Format: 2017-05-11T16:22:06 (in UTC time zone)
signature true string Signature, a computed value used to ensure that the signature is valid and has not been tampered with

Signature steps

For the signature steps, you can view them in the [Quick Start - Signature Verification] section.

Note: Data in JSON requests does not need to be URL encoded.

Subscribe to topics

After successfully establishing a connection with the Websocket server, the Websocket client sends a request like the following to subscribe to a specific topic:

{
"action": "sub",
"ch": "accounts.update"
}

If the subscription is successful, the Websocket client will receive the following message:

{
"action": "sub",
"code": 200,
"ch": "accounts.update#0",
"data": {}
}

request data

After successfully establishing the connection to the Websocket server, the Websocket client sends the following request to obtain one-time data:

{
     "action": "req",
     "ch": "topic",
}

After the request is successful, the Websocket client will receive the following message:

{
     "action": "req",
     "ch": "topic",
     "code": 200,
     "data": {} // request data body
}

error code

The following are the error codes, error messages, and descriptions of the WebSocket asset and order interfaces.

Error Code Error Message Description
200 True True returns
100 timeout off Timeout off
400 Bad Request Bad request
404 Not Found Service not found
429 Too Many Requests Exceeded the maximum number of connections for a single server or exceeded the maximum number of connections for a single IP
500 System exception System error
2000 invalid.ip Invalid IP
2001 invalid.json Invalid request JSON
2001 invalid.authType Signature verification method error
2001 invalid.action Invalid subscription event
2001 invalid.symbol Invalid trading pair
2001 invalid.ch Invalid subscription
2001 invalid.exchange Invalid exchange code
2001 missing.param.auth Missing signature verification parameters
2002 invalid.auth.state Authentication failed
2002 auth.fail Signature verification failed
2003 query.account.list.error Failed to query account list
4000 too.many.request Client uplink request frequency limit
4000 too.many.connection Number of connections with the same key

Subscribe to order updates

API Key permission: read

The update push of the order is triggered by any of the following events:

In the messages pushed by different event types, the list of fields is slightly different. Developers can design the returned data structure in the following two ways:

Subscribe to topics

orders#${symbol}

Subscription parameters

Subscribe request

{
"action": "sub",
"ch": "orders#btcusdt"
}

Response

{
"action": "sub",
"code": 200,
"ch": "orders#btcusdt",
"data": {}
}
Parameter Data Type Description
symbol string transaction code (wildcard * is supported)

Data update field list

Update example

{
"action": "push",
"ch": "orders#btcusdt",
"data":
{
"orderSize": "2.000000000000000000",
"orderCreateTime": 1583853365586,
"accountId": 992701,
"orderPrice": "77.000000000000000000",
"type": "sell-limit",
"orderId": 27163533,
"clientOrderId": "abc123",
"orderStatus": "submitted",
"symbol": "btcusdt",
"eventType": "creation",
"orderSource":"web"
}
}

When an order is placed –

Field Data Type Description
eventType string Event type, valid value: creation
symbol string Transaction code
accountId long Account ID
orderId long Order ID
clientOrderId string User-made order number (if any)
orderPrice string Order price (not applicable for market orders)
orderSize string Order size (invalid for market buy orders)
orderValue string Order amount (only valid for market buy orders)
type string Order type, valid values: buy-market, sell-market, buy-limit, sell-limit
orderStatus string Order status, valid value: submitted
orderCreateTime long Order creation time
orderSource string Order source

Note:

Update example

{
"action": "push",
"ch": "orders#btcusdt",
"data":
{
"tradePrice": "76.000000000000000000",
"tradeVolume": "1.013157894736842100",
"tradeId": 301,
"tradeTime": 1583854188883,
"aggressor": true,
"remainAmt": "0.000000000000000400000000000000000000",
"orderId": 27163536,
"type": "sell-limit",
"clientOrderId": "abc123",
"orderStatus": "filled",
"symbol": "btcusdt",
"eventType": "trade",
"orderSource":"web",
"execAmt":"0.0006",
"orderPrice": "76.000000000000000000",
"orderSize": "0.009"
}
}

When the order is filled –

Field Data Type Description
eventType string Event type, valid value: trade
symbol string Transaction code
tradePrice string Traded price
tradeVolume string Trade volume
orderId long Order ID
type string Order type, valid values: buy-market, sell-market, buy-limit, sell-limit
clientOrderId string User-made order number (if any)
tradeId long Trade ID
tradeTime long Trade time
aggressor bool Whether to be the active party of the transaction, valid values: true (taker), false (maker)
orderStatus string Order status, valid values: partial-filled, filled
remainAmt string Unexecuted quantity (buy order at market price is the unexecuted amount)
orderSize string Order quantity (not applicable for market buy orders)
orderValue string Order amount (only applicable for market buy orders)
orderPrice string Order price (not applicable for market orders)
orderSource string Order source
execAmt string Cumulative trading volume

Note:

Update example

{
"action": "push",
"ch": "orders#btcusdt",
"data":
{
"lastActTime": 1583853475406,
"remainAmt": "2.000000000000000000",
"orderId": 27163533,
"type": "sell-limit",
"clientOrderId": "abc123",
"orderStatus": "canceled",
"symbol": "btcusdt",
"eventType": "cancellation",
"orderSource": "web",
"orderPrice": "0.01",
"orderSize": "0.02",
"execAmt":0
}
}

When an order is canceled -

Field Data Type Description
eventType string Event type, valid value: cancellation
symbol string Transaction code
orderId long Order ID
type string Order type, valid values: buy-market, sell-market, buy-limit, sell-limit
clientOrderId string User-made order number (if any)
orderStatus string Order status, valid values: partial-canceled, canceled
remainAmt string Unexecuted quantity (buy order at market price is the unexecuted amount)
lastActTime long Last update time of the order

Note:

Subscribe to update transactions and cancellations after liquidation

API Key permission: read

Pushed only when the user’s order is filled or canceled. Among them, the order transaction is pushed one by one. If a taker order is executed with multiple maker orders at the same time, this interface will push the update one by one. However, the order of these transaction messages received by the user may not be completely consistent with the actual order of transactions. In addition, if the execution and cancellation of an order occur almost at the same time, for example, the remaining part of an IOC order is automatically canceled after the execution, the user may receive the order cancellation notification first, and then the transaction notification.

If the user needs to get order updates updated sequentially, it is recommended to subscribe to another channel orders#${symbol}.

Subscribe to topics

trade.clearing#${symbol}#${mode}

Subscription parameters

parameter data type required description
symbol string TRUE Transaction code (supports wildcard *)
mode int FALSE Push mode (0 - push only when the order is completed; 1 - push both when the order is completed and canceled; default value: 0)

Note:
Optional subscription parameter mode, if not filled or filled with 0, only transaction events will be pushed; if 1 is filled, transaction and cancellation events will be pushed.

Subscribe request

{
"action": "sub",
"ch": "trade.clearing#btcusdt#0"
}

Response

{
"action": "sub",
"code": 200,
"ch": "trade.clearing#btcusdt#0",
"data": {}
}

Update example

{
     "ch": "trade.clearing#btcusdt#0",
     "data": {
          "eventType": "trade",
          "symbol": "btcusdt",
          "orderId": 99998888,
          "tradePrice": "9999.99",
          "tradeVolume": "0.96",
          "orderSide": "buy",
          "aggressor": true,
          "tradeId": 919219323232,
          "tradeTime": 998787897878,
          "transactFee": "19.88",
          "feeDeduct": "0",
          "feeDeductType": "",
          "feeCurrency": "btc",
          "accountId": 9912791,
          "source": "spot-api",
          "orderPrice": "10000",
          "orderSize": "1",
          "clientOrderId": "a001",
          "orderCreateTime": 998787897878,
          "orderStatus": "partial-filled",
          "orderType": "buy-limit"
     }
}

Data update field list (when the order is completed)

Field Data Type Description
eventType string Event type (trade)
symbol string Transaction code
orderId long Order ID
tradePrice string Traded price
tradeVolume string Trade volume
orderSide string Order direction, valid values: buy, sell
orderType string Order type, valid values: buy-market, sell-market, buy-limit, sell-limit
aggressor bool Whether the trade was initiated by the active party, valid values: true, false
tradeId long Trade ID
tradeTime long Trade time (Unix time in milliseconds)
transactFee string Transaction fee (positive value) or transaction fee rebate (negative value)
feeCurrency string Transaction fee or transaction fee rebate currency (the transaction fee currency for buy orders is the base currency, the transaction fee currency for sell orders is the quote currency; the transaction fee rebate currency for buy orders is the denominated currency, and the transaction fee rebate currency for sell orders is the base currency)
feeDeduct string Transaction fee deduction
feeDeductType string Transaction fee deduction type
accountId long Account ID
source string Order source
orderPrice string Order price (not applicable for market orders)
orderSize string Order quantity (not applicable for market buy orders)
orderValue string Order amount (only applicable for market buy orders)
clientOrderId string User-defined order number
stopPrice string Order trigger price (only available for stop-loss orders)
operator string Order trigger direction (only applicable for take profit and stop-loss orders)
orderCreateTime long Order creation time
orderStatus string Order status, valid values: filled, partial-filled

Note:

Data update field list (when the order is canceled)

Field Data Type Description
eventType string Event type (cancellation)
symbol string Transaction code
orderId long Order ID
orderSide string Order direction, valid values: buy, sell
orderType string Order type, valid values: buy-market, sell-market, buy-limit, sell-limit
accountId long Account ID
source string Order source
orderPrice string Order price (not applicable for market orders)
orderSize string Order quantity (not applicable for market buy orders)
orderValue string Order amount (only applicable for market buy orders)
clientOrderId string User-defined order number
stopPrice string Order trigger price (only available for stop-loss orders)
operator string Order trigger direction (only applicable for take profit and stop-loss orders)
orderCreateTime long Order creation time
remainAmt string Open volume (for market buy orders, this field is defined as unfilled volume)
orderStatus string Order status, valid values: canceled, partial-canceled

Subscribe account changes

API Key permission: read

Subscribe to order updates under your account.

Subscribe to topics

accounts.update#${mode}

Users can choose any of the following ways to trigger account change push

  1. Push only when the account balance changes;

  2. Push both when the account balance changes or when the available balance changes, and push them separately.

Subscription parameters

Parameter Data Type Description
mode integer push mode, valid values: 0, 1, default value: 0

Subscription example

  1. Do not fill in the mode: accounts.update Push only when account balance changes;
  2. Fill in mode=0: accounts.update#0 Push only when account balance changes;
  3. Fill in mode=1: accounts.update#1 When the account balance changes or the available balance changes, both push and push separately.

Note: No matter which subscription mode the user adopts, after the subscription is successful, the server will first push the current account balance and available balance of each account, and then push subsequent account updates. When the initial value of each account is first pushed, the values of changeType and changeTime in the message are null.

Subscribe request

{
"action": "sub",
"ch": "accounts.update"
}

Response

{
"action": "sub",
"code": 200,
"ch": "accounts.update#0",
"data": {}
}

Update example

accounts.update#0:
{
"action": "push",
"ch": "accounts.update#0",
"data": {
"currency": "btc",
"accountId": 123456,
"balance": "23.111",
"changeType": "order.match",
"accountType": "trade",
"changeTime": 1568601800000,
"seqNum":1
}
}

accounts.update#1:
{
"action": "push",
"ch": "accounts.update#1",
"data": {
"currency": "btc",
"accountId": 33385,
"available": "2028.699426619837209087",
"changeType": "order.match",
"accountType": "trade",
"changeTime": 1574393385167,
"seqNum":1
}
}
{
"action": "push",
"ch": "accounts.update#1",
"data": {
"currency": "btc",
"accountId": 33385,
"balance": "2065.100267619837209301",
"changeType": "order.match",
"accountType": "trade",
"changeTime": 1574393385122,
"seqNum":1
}
}

Data update field list

Field Data Type Description
currency string Currency
accountId long Account ID
balance string Account balance (only pushed when the account balance changes)
available string Available balance (only pushed when the available balance changes)
changeType string Balance change type, valid values: order.place (order creation), order.match (order transaction), order-.efund (order transaction refund), order.cancel (order cancellation), order.fee-refund (deduct transaction fee)
accountType string Account type, valid values: trade, frozen, loan, interest
changeTime long Balance change time, UNIX time in milliseconds
seqNum long message sequence number

Note:
The account update pushes the amount received, and multiple transaction rebates generated by multiple transactions may be combined into the account.