NAV Navigation

General Info

General API Information

HTTP Return Codes

Error Codes

Sample Payload below:

{
  "code": -1121,
  "msg": "Invalid symbol."
}

General Information on Endpoints

LIMITS

General Info on Limits

IP Limits

Order Rate Limits

Endpoint security type

Security Type Description
NONE Endpoint can be accessed freely.
TRADE Endpoint requires sending a valid API-Key and signature.
USER_DATA Endpoint requires sending a valid API-Key and signature.
USER_STREAM Endpoint requires sending a valid API-Key.

SIGNED (TRADE and USER_DATA) Endpoint security

Timing security

if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow) 
{
    // process request
} 
else 
{
    // reject request
}

Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.

It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!

SIGNED Endpoint Examples for POST /api/v3/order

HMAC Keys

Here is a step-by-step example of how to send a valid signed payload from the Linux command line using echo, openssl, and curl.

Key Value
apiKey vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
secretKey NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j
Parameter Value
symbol LTCBTC
side BUY
type LIMIT
timeInForce GTC
quantity 1
price 0.1
recvWindow 5000
timestamp 1499827319559

Example 1: As a request body

[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'

Example 2: As a query string

[linux]$ echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"
(stdin)= c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'

Spot Account/Trade

Account Information (USER_DATA)

GET /api/v3/account

Get current account information.

Weight(IP): 10

Parameters

Name Type Mandatory Description
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "makerCommission": 15,
  "takerCommission": 15,
  "buyerCommission": 0,
  "sellerCommission": 0,
  "commissionRates": {
    "maker": "0.00150000",
    "taker": "0.00150000",
    "buyer": "0.00000000",
    "seller": "0.00000000"
  },
  "canTrade": true,
  "canWithdraw": true,
  "canDeposit": true,
  "brokered": false,
  "requireSelfTradePrevention": false,
  "updateTime": "123456789",
  "accountType": "SPOT",
  "balances": [
    {
      "asset": "LTC",
      "free": "4763368.68006011",
      "locked": "0.00000000"
    }
  ],
  "permissions": [
    "string"
  ]
}

Query Order (USER_DATA)

GET /api/v3/order

Check an order’s status.

Weight(IP): 2

Parameters

Name Type Mandatory Description
symbol STRING YES
orderId LONG NO
origClientOrderId STRING NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "orderListId": -1,
  "transactTime": "1507725176595",
  "price": 2,
  "stopPrice": 2,
  "origQty": 0,
  "executedQty": 0,
  "cummulativeQuoteQty": 0,
  "origQuoteOrderQty": 0,
  "side": "BUY",
  "type": "LIMIT",
  "timeInForce": "GTC",
  "status": "CANCELED",
  "icebergQty": 0,
  "origClientOrderId": "myOrder1",
  "updateTime": "1499827319559",
  "time": "1499827319559",
  "isWorking": true
}

New Order (TRADE)

POST /api/v3/order

Send in a new order.

Weight(UID): 1 Weight(IP): 1

Parameters

Name Type Mandatory Description
quoteOrderQty DECIMAL NO
stopPrice DECIMAL NO Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
newClientOrderId STRING NO A unique id among open orders. Automatically generated if not sent.
icebergQty DECIMAL NO Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
orderResponseType undefined NO Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.
symbol STRING YES
side undefined NO
type undefined NO
price DECIMAL NO
quantity DECIMAL NO
timeInForce undefined NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "orderListId": -1,
  "transactTime": "1507725176595"
}

Cancel Order (TRADE)

DELETE /api/v3/order

Cancel an active order.

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING YES
orderId LONG NO
origClientOrderId STRING NO
newClientOrderId STRING NO Used to uniquely identify this cancel. Automatically generated by default.
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "orderListId": -1,
  "transactTime": "1507725176595",
  "price": 2,
  "stopPrice": 2,
  "origQty": 0,
  "executedQty": 0,
  "cummulativeQuoteQty": 0,
  "origQuoteOrderQty": 0,
  "side": "BUY",
  "type": "LIMIT",
  "timeInForce": "GTC",
  "status": "CANCELED"
}

Current Open Orders (USER_DATA)

GET /api/v3/openorders

Get all open orders on a symbol. Careful when accessing this with no symbol.

Weight(IP): 3 for a single symbol; 40 when the symbol parameter is omitted;

Parameters

Name Type Mandatory Description
symbol STRING NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "orderListId": -1,
    "transactTime": "1507725176595",
    "price": 2,
    "stopPrice": 2,
    "origQty": 0,
    "executedQty": 0,
    "cummulativeQuoteQty": 0,
    "origQuoteOrderQty": 0,
    "side": "BUY",
    "type": "LIMIT",
    "timeInForce": "GTC",
    "status": "CANCELED"
  }
]

Cancel all Open Orders on a Symbol (TRADE)

DELETE /api/v3/openorders

Cancels all active orders on a symbol.

This includes OCO orders.

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING YES
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "orderListId": -1,
    "transactTime": "1507725176595",
    "price": 2,
    "stopPrice": 2,
    "origQty": 0,
    "executedQty": 0,
    "cummulativeQuoteQty": 0,
    "origQuoteOrderQty": 0,
    "side": "BUY",
    "type": "LIMIT",
    "timeInForce": "GTC",
    "status": "CANCELED"
  }
]

All Orders (USER_DATA)

GET /api/v3/allorders

Get all account orders; active, canceled, or filled.

Weight(IP): 10 with symbol

Parameters

Name Type Mandatory Description
symbol STRING YES
orderId LONG NO
limit INT NO Default 500; max 1000.
startTime int64 NO
endTime int64 NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "orderListId": -1,
    "transactTime": "1507725176595",
    "price": 2,
    "stopPrice": 2,
    "origQty": 0,
    "executedQty": 0,
    "cummulativeQuoteQty": 0,
    "origQuoteOrderQty": 0,
    "side": "BUY",
    "type": "LIMIT",
    "timeInForce": "GTC",
    "status": "CANCELED"
  }
]

Query OCO (USER_DATA)

GET /api/v3/orderlist

Retrieves a specific OCO based on provided optional parameters

Weight(IP): 2

Parameters

Name Type Mandatory Description
orderListId LONG NO Either orderListId or origClientOrderId must be provided
origClientOrderId STRING NO Either orderListId or origClientOrderId must be provided
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": "1563417480525",
  "orders": [
    {
      "symbol": "BTCUSDT",
      "orderId": 28,
      "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP"
    }
  ]
}

Cancel OCO (TRADE)

DELETE /api/v3/orderlist

Cancel an entire Order List.

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING YES
orderListId LONG NO Either orderListId or listClientOrderId must be provided
listClientOrderId STRING NO Either orderListId or listClientOrderId must be provided
newClientOrderId STRING NO Used to uniquely identify this cancel. Automatically generated by default
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": "1563417480525",
  "orders": [
    {
      "symbol": "BTCUSDT",
      "orderId": 28,
      "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP"
    }
  ],
  "orderReports": [
    {
      "symbol": "BTCUSDT",
      "orderId": 28,
      "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
      "orderListId": -1,
      "transactTime": "1507725176595",
      "price": 2,
      "stopPrice": 2,
      "origQty": 0,
      "executedQty": 0,
      "cummulativeQuoteQty": 0,
      "origQuoteOrderQty": 0,
      "side": "BUY",
      "type": "LIMIT",
      "timeInForce": "GTC",
      "status": "CANCELED"
    }
  ]
}

Query Open OCO (USER_DATA)

GET /api/v3/openorderlist

Weight(IP): 3

Parameters

Name Type Mandatory Description
symbol STRING YES
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "orderListId": 0,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
    "transactionTime": "1563417480525",
    "orders": [
      {
        "symbol": "BTCUSDT",
        "orderId": 28,
        "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP"
      }
    ]
  }
]

Query all OCO (USER_DATA)

GET /api/v3/allorderlist

Retrieves all OCO based on provided optional parameters

Weight(IP): 10

Parameters

Name Type Mandatory Description
fromId LONG NO If supplied, neither startTime or endTime can be provided
startTime int64 NO
endTime int64 NO
limit INT NO Default Value: 500; Max Value: 1000
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "orderListId": 0,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
    "transactionTime": "1563417480525",
    "orders": [
      {
        "symbol": "BTCUSDT",
        "orderId": 28,
        "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP"
      }
    ]
  }
]

New OCO (TRADE)

POST /api/v3/order/oco

Send in a new OCO

Weight(UID): 2 Weight(IP): 1

Parameters

Name Type Mandatory Description
stopPrice DECIMAL YES
limitIcebergQty DECIMAL NO
stopIcebergQty DECIMAL NO
stopLimitPrice DECIMAL NO If provided, stopLimitTimeInForce is required.
limitClientOrderId STRING NO A unique Id for the limit order
listClientOrderId STRING NO A unique Id for the entire orderList
stopClientOrderId STRING NO A unique Id for the stop loss/stop loss limit leg
stopLimitTimeInForce undefined NO Valid values are GTC/FOK/IOC
orderResponseType undefined NO Set the response JSON.
trailingDelta LONG NO
symbol STRING YES
side undefined NO
type undefined NO
price DECIMAL NO
quantity DECIMAL NO
timeInForce undefined NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "symbol": "BTCUSDT",
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": "1563417480525",
  "orders": [
    {
      "symbol": "BTCUSDT",
      "orderId": 28,
      "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP"
    }
  ]
}

Account Trade List (USER_DATA)

GET /api/v3/mytrades

Get trades for a specific account and symbol.

Weight(IP): 10

Parameters

Name Type Mandatory Description
symbol STRING YES
orderId LONG NO This can only be used in combination with symbol.
startTime int64 NO
endTime int64 NO
fromId LONG NO TradeId to fetch from. Default gets most recent trades.
limit INT NO Default 500; max 1000.
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "id": 28457,
    "orderId": 100234,
    "orderListId": -1,
    "price": 4.000001,
    "qty": 12,
    "quoteQty": 48.00001,
    "commission": 10.1,
    "commissionAsset": "BNB",
    "time": "1499865549590",
    "isBuyer": true,
    "isMaker": false,
    "isBestMatch": true
  }
]

Create a ListenKey (USER_STREAM)

POST /api/v3/userdatastream

Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes.

Weight: 1

200 Response

{
  "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}

Wallet Endpoints

Trade Fee (USER_DATA)

GET /sapi/v1/asset/tradefee

Fetch trade fee

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "symbol": "BTCUSDT",
    "makerCommission": 0,
    "takerCommission": 0
  }
]

Deposit Address (supporting network) (USER_DATA)

GET /sapi/v1/capital/deposit/address

Fetch deposit address with network.

Weight(IP): 10

Parameters

Name Type Mandatory Description
coin STRING YES
network STRING NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "address": "1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv",
  "coin": "BTC",
  "tag": "",
  "url": "https://btc.com/1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv"
}

Deposit History (supporting network) (USER_DATA)

GET /sapi/v1/capital/deposit/hisrec

Fetch deposit history.

Weight(IP): 1

Parameters

Name Type Mandatory Description
network STRING NO
coin STRING NO
txId STRING NO
status undefined NO 0(0:pending,6: credited but cannot withdraw, 7=Wrong Deposit,8=Waiting User confirm, 1:success)
startTime int64 NO Default: 90 days from current timestamp
endTime int64 NO Default: present timestamp
offset INT NO Default:0
limit INT NO Default:1000, Max:1000
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "id": "769800519366885376",
    "amount": "0.001",
    "coin": "BNB",
    "network": "BNB",
    "status": 0,
    "address": "bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23",
    "addressTag": "101764890",
    "txId": "98A3EA560C6B3336D348B6C83F0F95ECE4F1F5919E94BD006E5BF3BF264FACFC",
    "insertTime": "1661493146000",
    "transferType": 0,
    "confirmTimes": "1/1",
    "unlockConfirm": 0,
    "walletType": 0
  }
]

Withdraw History (supporting network) (USER_DATA)

GET /sapi/v1/capital/withdraw/history

Fetch withdraw history.

Weight(IP): 1

Parameters

Name Type Mandatory Description
coin STRING NO
withdrawOrderId STRING NO
status undefined NO 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6:Completed)
offset INT NO
limit INT NO Default: 1000, Max: 1000
startTime int64 NO Default: 90 days from current timestamp
endTime int64 NO Default: present timestamp
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "id": "b6ae22b3aa844210a7041aee7589627c",
    "amount": "8.91000000",
    "transactionFee": "0.004",
    "coin": "USDT",
    "status": 6,
    "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60",
    "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268",
    "applyTime": "2019-10-12 11:12:02",
    "network": "ETH",
    "transferType": 0,
    "info": "The address is not valid. Please confirm with the recipient",
    "confirmNo": 3,
    "walletType": 1,
    "txKey": "",
    "completeTime": "2023-03-23 16:52:41",
    "withdrawOrderId": "WITHDRAWtest123"
  }
]

Withdraw(USER_DATA)

POST /sapi/v1/capital/withdraw/apply

Submit a withdraw request.

Weight(IP): 10

Parameters

Name Type Mandatory Description
coin STRING YES
network STRING NO
address STRING YES
addressTag STRING NO Secondary address identifier for coins like XRP,XMR etc.
amount DECIMAL YES
withdrawOrderId STRING NO client id for withdraw
transactionFeeFlag undefined NO When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account. Default false.
name STRING NO Description of the address. Space in name should be encoded into %20.
walletType INT NO The wallet type for withdraw,0-spot wallet ,1-funding wallet. Default walletType is the current “selected wallet” under wallet->Fiat and Spot/Funding->Deposit
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "id": 0
}

All Coins’ Information (USER_DATA)

GET /sapi/v1/capital/config/getall

Get information of coins (available for deposit and withdraw) for user.

Weight(IP): 10

Parameters

Name Type Mandatory Description
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "coin": "BTC",
    "depositAllEnable": true,
    "free": 0.08074558,
    "freeze": 0,
    "ipoable": 0,
    "ipoing": 0,
    "isLegalMoney": false,
    "locked": 0,
    "storage": 0,
    "trading": false,
    "withdrawAllEnable": false,
    "name": "Bitcoin",
    "withdrawing": 0,
    "networkList": [
      {
        "addressRegex": "^(bnb1)[0-9a-z]{38}$",
        "coin": "BTC",
        "depositDesc": "Wallet Maintenance, Deposit Suspended",
        "depositEnable": false,
        "isDefault": false,
        "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
        "minConfirm": 1,
        "name": "BEP2",
        "network": "BNB",
        "resetAddressStatus": false,
        "specialTips": "Both a MEMO and an Address are required to successfully deposit your BEP2-BTCB tokens to Hitobit.",
        "unlockConfirm": 0,
        "withdrawDesc": "Wallet Maintenance, Withdrawal Suspended",
        "withdrawEnable": false,
        "withdrawFee": 0.0000022,
        "withdrawIntegerMultiple": 1e-8,
        "withdrawMax": 10000000000,
        "withdrawMin": 0.0000044,
        "sameAddress": true,
        "estimatedArrivalTime": 25,
        "busy": false
      }
    ]
  }
]

Market Data Endpoints

Order Book

GET /api/v3/depth

Weight(IP):

Limit Weight
1-100 1
101-500 5
501-1000 10
1001-5000 50

Parameters

Name Type Mandatory Description
symbol STRING YES
limit INT NO Default 100; max 5000.If limit > 5000, then the response will truncate to 5000.
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "s": "BTC",
  "T": "1565246363776",
  "U": 1027024,
  "lastUpdateId": 1027024,
  "pu": 1027024,
  "bids": [
    {
      "price": 4,
      "quantity": 431
    }
  ],
  "asks": [
    {
      "price": 4,
      "quantity": 431
    }
  ]
}

24hr Ticker Price Change Statistics

GET /api/v3/ticker/24hr

24 hour rolling window price change statistics. Careful when accessing this with no symbol.

Weight(IP):

ParameterSymbols ProvidedWeight
symbol 1 1
symbol parameter is omitted40
symbols 1 - 20 1
21 - 100 20
101 or more40
symbols parameter is omitted40

Parameters

Name Type Mandatory Description
symbol STRING NO Parameter symbol and symbols cannot be used in combination.
symbols undefined NO Examples of accepted format for the symbols parameter: [“BTCUSDT”,“BNBUSDT”]
type undefined NO Supported values: FULL or MINI.

Detailed descriptions

symbol: Parameter symbol and symbols cannot be used in combination. If neither parameter is sent, prices for all symbols will be returned in an array.

symbols: Examples of accepted format for the symbols parameter: [“BTCUSDT”,“BNBUSDT”] or %5B%22BTCUSDT%22,%22BNBUSDT%22%5D

type: Supported values: FULL or MINI. If none provided, the default is FULL

Symbol Price Ticker

GET /api/v3/ticker/price

Latest price for a symbol or symbols.

Weight(IP):

ParameterSymbols ProvidedWeight
symbol 1 1
symbol parameter is omitted2
symbolsAny2

Parameters

Name Type Mandatory Description
symbol STRING NO Parameter symbol and symbols cannot be used in combination.
symbols undefined NO Examples of accepted format for the symbols parameter: [“BTCUSDT”,“BNBUSDT”]

Detailed descriptions

symbol: Parameter symbol and symbols cannot be used in combination. If neither parameter is sent, prices for all symbols will be returned in an array.

symbols: Examples of accepted format for the symbols parameter: [“BTCUSDT”,“BNBUSDT”] or %5B%22BTCUSDT%22,%22BNBUSDT%22%5D

200 Response

{
  "symbol": "BTCUSDT",
  "Price": 4.000002
}

Kline/Candlestick Data

GET /api/v3/klines

Kline/candlestick bars for a symbol.

Klines are uniquely identified by their open time.

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING YES
interval undefined YES
limit INT NO Default 500; max 1000.
startTime int64 NO
endTime int64 NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "openTime": "1499040000000",
    "open": 0.0163479,
    "high": 0.8,
    "low": 0.015758,
    "close": 0.015771,
    "baseVolume": 148976.11,
    "closeTime": "1499644799999",
    "quoteVolume": 2434.1907,
    "tradeCount": 308,
    "takerBuyBaseVolume": 1756.874,
    "takerBuyQuoteVolume": 28.466944,
    "ignore": 0
  }
]

Recent Trades List

GET /api/v3/trades

Get recent trades.

Weight(IP): 1

Parameters

Name Type Mandatory Description
symbol STRING YES
limit INT NO Default 500; max 1000.
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

[
  {
    "id": 28457,
    "Price": 4.000001,
    "BaseQuantity": 12,
    "QuoteQuantity": 48.00001,
    "Time": "1499865549590",
    "isBuyerMaker": true,
    "IsBestMatch": true
  }
]

Exchange Information

GET /api/v3/exchangeinfo

Current exchange trading rules and symbol information

Weight(IP): 10

Parameters

Name Type Mandatory Description
symbol STRING NO
symbols undefined NO
recvWindow INT NO The value cannot be greater than 60000
timestamp LONG YES

200 Response

{
  "timeZone": "UTC",
  "serverTime": "1565246363776",
  "rateLimits": [
    {
      "Interval": "MINUTE",
      "rateLimitType": "REQUEST_WEIGHT",
      "intervalNum": 1,
      "Limit": 1200
    }
  ],
  "symbols": [
    {
      "symbol": "ETHBTC",
      "status": "TRADING",
      "baseAsset": "ETH",
      "baseAssetPrecision": 8,
      "quoteAsset": "BTC",
      "quotePrecision": 8,
      "orderTypes": [
        "LIMIT"
      ],
      "iceBergAllowed": true,
      "isSpotTradingAllowed": true,
      "isMarginTradingAllowed": true,
      "ocoAllowed": true,
      "quoteOrderQtyMarketAllowed": true,
      "baseCommissionPrecision": 1,
      "quoteCommissionPrecision": 1,
      "permissions": [
        "SPOT"
      ],
      "filters": [
        {
          "filterType": "UNKNOWN"
        }
      ],
      "defaultSelfTradePreventionMode": "NONE",
      "allowedSelfTradePreventionModes": [
        null
      ],
      "allowTrailingStop": false,
      "cancelReplaceAllowed": false
    }
  ],
  "exchangeFilters": [
    null
  ]
}

Test Connectivity

GET /api/v3/ping

Test connectivity to the Rest API.

Weight(IP): 1

Check Server Time

GET /api/v3/time

Test connectivity to the Rest API and get the current server time.

Weight(IP): 1

200 Response

{
  "serverTime": 0
}

General WSS information

Websocket Limits

Live Subscribing/Unsubscribing to streams

Subscribe to a stream

  {
    "method": "SUBSCRIBE",
    "params": [
      "btcusdt@aggTrade",
      "btcusdt@depth"
    ],
    "id": 1
  }
  {
    "result": null,
    "id": 1
  }

Unsubscribe to a stream

  {
    "method": "UNSUBSCRIBE",
    "params": [
      "btcusdt@depth"
    ],
    "id": 312
  }
  {
    "result": null,
    "id": 312
  }

Listing Subscriptions

  {
    "method": "LIST_SUBSCRIPTIONS",
    "id": 3
  }
  {
    "result": [
      "btcusdt@aggTrade"
    ],
    "id": 3
  }

Error Messages

Error Message Description
{“code”: 0, “msg”: “Unknown property”,“id”: %s} Parameter used in the SET_PROPERTY or GET_PROPERTY was invalid
{“code”: 1, “msg”: “Invalid value type: expected Boolean”} Value should only be true or false
{“code”: 2, “msg”: “Invalid request: property name must be a string”} Property name provided was invalid
{“code”: 2, “msg”: “Invalid request: request ID must be an unsigned integer”} Parameter id had to be provided or the value provided in the id parameter is an unsupported type
{“code”: 2, “msg”: “Invalid request: unknown variant %s, expected one of SUBSCRIBE, UNSUBSCRIBE, LIST_SUBSCRIPTIONS, SET_PROPERTY, GET_PROPERTY at line 1 column 28”} Possible typo in the provided method or provided method was neither of the expected values
{“code”: 2, “msg”: “Invalid request: too many parameters”} Unnecessary parameters provided in the data
{“code”: 2, “msg”: “Invalid request: property name must be a string”} Property name was not provided
{“code”: 2, “msg”: “Invalid request: missing field method at line 1 column 73”} method was not provided in the data
{“code”:3,“msg”:“Invalid JSON: expected value at line %s column %s”} JSON data sent has incorrect syntax.

Detailed Stream information

Aggregate Trade Streams

The Aggregate Trade Streams push trade information that is aggregated for a single taker order.

Stream Name: <symbol>@aggTrade

Update Speed: Real-time

Payload:

{
  "e": "aggTrade",    // Event type
  "E": 1672515782136, // Event time
  "s": "BNBBTC",      // Symbol
  "a": 12345,         // Aggregate trade ID
  "p": "0.001",       // Price
  "q": "100",         // Quantity
  "f": 100,           // First trade ID
  "l": 105,           // Last trade ID
  "T": 1672515782136, // Trade time
  "m": true,          // Is the buyer the market maker?
  "M": true           // Ignore
}

Trade Streams

The Trade Streams push raw trade information; each trade has a unique buyer and seller.

Stream Name: <symbol>@trade

Update Speed: Real-time

Payload:

{
  "e": "trade",       // Event type
  "E": 1672515782136, // Event time
  "s": "BNBBTC",      // Symbol
  "t": 12345,         // Trade ID
  "p": "0.001",       // Price
  "q": "100",         // Quantity
  "b": 88,            // Buyer order ID
  "a": 50,            // Seller order ID
  "T": 1672515782136, // Trade time
  "m": true,          // Is the buyer the market maker?
  "M": true           // Ignore
}

Kline/Candlestick Streams

The Kline/Candlestick Stream push updates to the current klines/candlestick every second.

Kline/Candlestick chart intervals:

s-> seconds; m -> minutes; h -> hours; d -> days; w -> weeks; M -> months

Stream Name: <symbol>@kline_<interval>

Update Speed: 1000ms for 1s, 2000ms for the other intervals

Payload:

{
  "e": "kline",         // Event type
  "E": 1672515782136,   // Event time
  "s": "BNBBTC",        // Symbol
  "k": {
    "t": 1672515780000, // Kline start time
    "T": 1672515839999, // Kline close time
    "s": "BNBBTC",      // Symbol
    "i": "1m",          // Interval
    "f": 100,           // First trade ID
    "L": 200,           // Last trade ID
    "o": "0.0010",      // Open price
    "c": "0.0020",      // Close price
    "h": "0.0025",      // High price
    "l": "0.0015",      // Low price
    "v": "1000",        // Base asset volume
    "n": 100,           // Number of trades
    "x": false,         // Is this kline closed?
    "q": "1.0000",      // Quote asset volume
    "V": "500",         // Taker buy base asset volume
    "Q": "0.500",       // Taker buy quote asset volume
    "B": "123456"       // Ignore
  }
}

Individual Symbol Mini Ticker Stream

24hr rolling window mini-ticker statistics. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs.

Stream Name: <symbol>@miniTicker

Update Speed: 1000ms

Payload:

  {
    "e": "24hrMiniTicker",  // Event type
    "E": 1672515782136,     // Event time
    "s": "BNBBTC",          // Symbol
    "c": "0.0025",          // Close price
    "o": "0.0010",          // Open price
    "h": "0.0025",          // High price
    "l": "0.0010",          // Low price
    "v": "10000",           // Total traded base asset volume
    "q": "18"               // Total traded quote asset volume
  }

All Market Mini Tickers Stream

24hr rolling window mini-ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.

Stream Name: !miniTicker@arr

Update Speed: 1000ms

Payload:

[
  {
    // Same as <symbol>@miniTicker payload
  }
]

Individual Symbol Ticker Streams

24hr rolling window ticker statistics for a single symbol. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs.

Stream Name: <symbol>@ticker

Update Speed: 1000ms

Payload:

{
  "e": "24hrTicker",  // Event type
  "E": 1672515782136, // Event time
  "s": "BNBBTC",      // Symbol
  "p": "0.0015",      // Price change
  "P": "250.00",      // Price change percent
  "w": "0.0018",      // Weighted average price
  "x": "0.0009",      // First trade(F)-1 price (first trade before the 24hr rolling window)
  "c": "0.0025",      // Last price
  "Q": "10",          // Last quantity
  "b": "0.0024",      // Best bid price
  "B": "10",          // Best bid quantity
  "a": "0.0026",      // Best ask price
  "A": "100",         // Best ask quantity
  "o": "0.0010",      // Open price
  "h": "0.0025",      // High price
  "l": "0.0010",      // Low price
  "v": "10000",       // Total traded base asset volume
  "q": "18",          // Total traded quote asset volume
  "O": 0,             // Statistics open time
  "C": 86400000,      // Statistics close time
  "F": 0,             // First trade ID
  "L": 18150,         // Last trade Id
  "n": 18151          // Total number of trades
}

All Market Tickers Stream

24hr rolling window ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.

Stream Name: !ticker@arr

Update Speed: 1000ms

Payload:

[
  {
    // Same as <symbol>@ticker payload
  }
]

Individual Symbol Book Ticker Streams

Pushes any update to the best bid or ask’s price or quantity in real-time for a specified symbol. Multiple <symbol>@bookTicker streams can be subscribed to over one connection.

Stream Name: <symbol>@bookTicker

Update Speed: Real-time

Payload:

{
  "u":400900217,     // order book updateId
  "s":"BNBUSDT",     // symbol
  "b":"25.35190000", // best bid price
  "B":"31.21000000", // best bid qty
  "a":"25.36520000", // best ask price
  "A":"40.66000000"  // best ask qty
}

Diff. Depth Stream

Order book price and quantity depth updates used to locally manage an order book.

Stream Name: <symbol>@depth OR <symbol>@depth@100ms

Update Speed: 1000ms or 100ms

Payload:

{
  "e": "depthUpdate", // Event type
  "E": 1672515782136, // Event time
  "s": "BNBBTC",      // Symbol
  "U": 157,           // First update ID in event
  "u": 160,           // Final update ID in event
  "b": [              // Bids to be updated
    [
      "0.0024",       // Price level to be updated
      "10"            // Quantity
    ]
  ],
  "a": [              // Asks to be updated
    [
      "0.0026",       // Price level to be updated
      "100"           // Quantity
    ]
  ]
}

How to manage a local order book correctly

  1. Open a stream to wss://stream.hitobit.com:443/stream?streams=bnbbtc@depth.
  2. Buffer the events you receive from the stream.
  3. Get a depth snapshot from https://api.hitobit.com/api/v3/depth?symbol=BNBBTC&limit=1000 .
  4. Drop any event where u is <= lastUpdateId in the snapshot.
  5. The first processed event should have U <= lastUpdateId+1 AND u >= lastUpdateId+1.
  6. While listening to the stream, each new event’s U should be equal to the previous event’s u+1.
  7. The data in each event is the absolute quantity for a price level.
  8. If the quantity is 0, remove the price level.
  9. Receiving an event that removes a price level that is not in your local order book can happen and is normal.

Note: Due to depth snapshots having a limit on the number of price levels, a price level outside of the initial snapshot that doesn’t have a quantity change won’t have an update in the Diff. Depth Stream. Consequently, those price levels will not be visible in the local order book even when applying all updates from the Diff. Depth Stream correctly and cause the local order book to have some slight differences with the real order book. However, for most use cases the depth limit of 5000 is enough to understand the market and trade effectively.

Error codes

Errors consist of two parts: an error code and a message. Codes are universal, but messages can vary. Here is the error JSON payload:

{
  "code":-1121,
  "msg":"Invalid symbol."
}

10xx - General Server or Network issues

-1000 UNKNOWN

-1001 DISCONNECTED

-1002 UNAUTHORIZED

-1003 TOO_MANY_REQUESTS

-1006 UNEXPECTED_RESP

-1007 TIMEOUT

-1008 SERVER_BUSY

-1014 UNKNOWN_ORDER_COMPOSITION

-1015 TOO_MANY_ORDERS

-1016 SERVICE_SHUTTING_DOWN

-1020 UNSUPPORTED_OPERATION

-1021 INVALID_TIMESTAMP

-1022 INVALID_SIGNATURE

11xx - Request issues

-1100 ILLEGAL_CHARS

-1101 TOO_MANY_PARAMETERS

-1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED

-1103 UNKNOWN_PARAM

-1104 UNREAD_PARAMETERS

-1105 PARAM_EMPTY

-1106 PARAM_NOT_REQUIRED

-1108 PARAM_OVERFLOW

-1111 BAD_PRECISION

-1112 NO_DEPTH

-1114 TIF_NOT_REQUIRED

-1115 INVALID_TIF

-1116 INVALID_ORDER_TYPE

-1117 INVALID_SIDE

-1118 EMPTY_NEW_CL_ORD_ID

-1119 EMPTY_ORG_CL_ORD_ID

-1120 BAD_INTERVAL

-1121 BAD_SYMBOL

-1125 INVALID_LISTEN_KEY

-1127 MORE_THAN_XX_HOURS

-1128 OPTIONAL_PARAMS_BAD_COMBO

-1130 INVALID_PARAMETER

-1134 BAD_STRATEGY_TYPE

-1135 INVALID_JSON

-1145 INVALID_CANCEL_RESTRICTIONS

-1151 DUPLICATE_SYMBOLS

-2010 NEW_ORDER_REJECTED

-2011 CANCEL_REJECTED

-2013 NO_SUCH_ORDER

-2014 BAD_API_KEY_FMT

-2015 REJECTED_MBX_KEY

-2016 NO_TRADING_WINDOW

-2026 ORDER_ARCHIVED

Messages for -1010 ERROR_MSG_RECEIVED -2010 NEW_ORDER_REJECTED and -2011 CANCEL_REJECTED

This code is sent when an error has been returned by the matching engine. The following messages which will indicate the specific error:

Error message Description
“Unknown order sent.” The order (by either orderId, clOrdId, origClOrdId) could not be found
“Duplicate order sent.” The clOrdId is already in use.
“Market is closed.” The symbol is not trading.
“Account has insufficient balance for requested action.” Not enough funds to complete the action.
“Market orders are not supported for this symbol.” MARKET is not enabled on the symbol.
“Iceberg orders are not supported for this symbol.” icebergQty is not enabled on the symbol.
“Stop loss orders are not supported for this symbol.” STOP_LOSS is not enabled on the symbol.
“Stop loss limit orders are not supported for this symbol.” STOP_LOSS_LIMIT is not enabled on the symbol.
“Take profit orders are not supported for this symbol.” TAKE_PROFIT is not enabled on the symbol.
“Take profit limit orders are not supported for this symbol.” TAKE_PROFIT_LIMIT is not enabled on the symbol.
“Price * QTY is zero or less.” price * quantity is too low.
“IcebergQty exceeds QTY.” icebergQty must be less than the order quantity.
“This action is disabled on this account.” Contact customer support; some actions have been disabled on the account.
“This account may not place or cancel orders.” Contact customer support; the account has trading ability disabled.
“Unsupported order combination” The orderType, timeInForce, stopPrice, and/or icebergQty combination isn’t allowed.
“Order would trigger immediately.” The order’s stop price is not valid when compared to the last traded price.
“Cancel order is invalid. Check origClOrdId and orderId.” No origClOrdId or orderId was sent in.
“Order would immediately match and take.” LIMIT_MAKER order type would immediately match and trade, and not be a pure maker order.
“The relationship of the prices for the orders is not correct.” The prices set in the OCO is breaking the Price rules.
The rules are:
SELL Orders: Limit Price > Last Price > Stop Price
BUY Orders: Limit Price < Last Price < Stop Price
“OCO orders are not supported for this symbol” OCO is not enabled on the symbol.
“Quote order qty market orders are not support for this symbol.” MARKET orders using the parameter quoteOrderQty are not enabled on the symbol.
“Trailing stop orders are not supported for this symbol.” Orders using trailingDelta are not enabled on the symbol.
“Order cancel-replace is not supported for this symbol.” POST /api/v3/order/cancelReplace is not enabled for the symbol.
“This symbol is not permitted for this account.” Account does not have permission to trade on this symbol.
“This symbol is restricted for this account.” Account does not have permission to trade on this symbol.
“Order was not canceled due to cancel restrictions.” Either cancelRestrictions was set to ONLY_NEW but the order status was not NEW
or
cancelRestrictions was set to ONLY_PARTIALLY_FILLED but the order status was not PARTIALLY_FILLED.

Errors regarding POST /api/v3/order/cancelReplace

-2021 Order cancel-replace partially failed

This code is sent when either the cancellation of the order failed or the new order placement failed but not both.

-2022 Order cancel-replace failed.

This code is sent when both the cancellation of the order failed and the new order placement failed.

Filter failures

Error message Description
“Filter failure: PRICE_FILTER” price is too high, too low, and/or not following the tick size rule for the symbol.
“Filter failure: PERCENT_PRICE” price is X% too high or X% too low from the average weighted price over the last Y minutes.
“Filter failure: LOT_SIZE” quantity is too high, too low, and/or not following the step size rule for the symbol.
“Filter failure: MIN_NOTIONAL” price * quantity is too low to be a valid order for the symbol.
“Filter failure: ICEBERG_PARTS” ICEBERG order would break into too many parts; icebergQty is too small.
“Filter failure: MARKET_LOT_SIZE” MARKET order’s quantity is too high, too low, and/or not following the step size rule for the symbol.
“Filter failure: MAX_POSITION” The account’s position has reached the maximum defined limit.
This is composed of the sum of the balance of the base asset, and the sum of the quantity of all open BUY orders.
“Filter failure: MAX_NUM_ORDERS” Account has too many open orders on the symbol.
“Filter failure: MAX_NUM_ALGO_ORDERS” Account has too many open stop loss and/or take profit orders on the symbol.
“Filter failure: MAX_NUM_ICEBERG_ORDERS” Account has too many open iceberg orders on the symbol.
“Filter failure: TRAILING_DELTA” trailingDelta is not within the defined range of the filter for that order type.
“Filter failure: EXCHANGE_MAX_NUM_ORDERS” Account has too many open orders on the exchange.
“Filter failure: EXCHANGE_MAX_NUM_ALGO_ORDERS” Account has too many open stop loss and/or take profit orders on the exchange.
“Filter failure: EXCHANGE_MAX_NUM_ICEBERG_ORDERS” Account has too many open iceberg orders on the exchange.