NAV
Shell Python

Introduction

Welcome to the Binance.US API Documentation!

Our REST APIs offer access to:

Our WebSocket Steams offer access to:

General API Information

The base endpoint is: https://api.binance.us

All endpoints return either a JSON object or array.

Data is returned in ascending order: oldest first, newest last.

All times for the fields of staking, referrals, airdrops, etc. are in milliseconds.

Making Requests

Data Sources

These are the three sources ordered from the most up-to-date response to the one with potential delays in updates:

Some endpoints can have more than one data source(e.g. Memory => Database). This means that the endpoint will check the first data source. If it cannot find the value it's looking for it will check the next one etc.

API Terminology

These terms will be used throughout the documentation, so it is recommended that you read them to enhance your understanding of the API (especially for new users).

Enum Definitions

Symbol status (status):

Symbol type:

Order status (status):

Status Description
NEW The order has been accepted by the engine
PARTIALLY_FILLED Part of the order has been filled
FILLED The order has been completed
CANCELED The order has been canceled by the user
PENDING_CANCEL This is currently unused
REJECTED The order was not accepted by the engine and not processed
EXPIRED The order was canceled according to the order type's rules (e.g., LIMIT FOK orders with no fill, LIMIT IOC, or MARKET orders that partially fill), or by the exchange(e.g., orders canceled during liquidation or orders canceled during maintenance)

OCO Status (listStatusType):

Status Description
RESPONSE This is used when the ListStatus is responding to a failed action (e.g., Orderlist placement or cancelation)
EXEC_STARTED The order list has been placed, or there is an update to the order list status
ALL_DONE The order list has finished executing and is thus no longer active

OCO Order Status (listOrderStatus):

Status Description
EXECUTING Either an order list has been placed, or there is an update to the status of the list
ALL_DONE An order list has completed execution and is thus no longer active
REJECT The List Status is responding to a failed action during order placement, or the order was canceled

ContingencyType

Order types (orderTypes, type):

Order side (side):

Time in force (timeInForce):

Status Description
GTC "Good Till Canceled."
An order will be on the book unless the order is canceled
IOC "Immediate or Cancel."
An order will try to fill the order as much as it can before the order expires
FOK "Fill or Kill."
An order will expire if the full order cannot be filled upon execution

Kline/Candlestick chart intervals:

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

Rate limiters (rateLimitType)

Example - REQUEST_WEIGHT

{
    "rateLimitType": "REQUEST_WEIGHT",
    "interval": "MINUTE",
    "intervalNum": 1,
    "limit": 1200
}

Example - ORDERS

{
    "rateLimitType": "ORDERS",
    "interval": "SECOND",
    "intervalNum": 1,
    "limit": 10
}

Example - RAW_REQUESTS

{
    "rateLimitType": "RAW_REQUESTS",
    "interval": "MINUTE",
    "intervalNum": 5,
    "limit": 5000
}

Rate limit intervals (interval)

Authentication

Get API Keys

Important Reminder For Binance.US API Key Users

API Key Types

Binance.US currently offers two API key types: Exchange API Keys and Custodial Solution API Keys. Please read on for more information on the differences and instructions on how to set up your key type.

Exchange API Keys

Get Exchange API Keys

To create this API key type:

  1. Log into Binance.US with your account details

  2. Go to Settings > API management

  3. Click 'API' to create an Exchange API Key

Custodial Solution API Keys

Get Custodial Solution API Keys

After entering into a Custody Exchange Network agreement between a participating custody partner and Binance.US, users can create a Custodial Solution API key by:

  1. Log into Binance.US with your account details

  2. Go to Settings > API management

  3. Click 'Custodial Solution API' to create a Custodial Solution API Key

Authentication Types

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
MARKET_DATA Endpoint requires sending a valid API-Key

Authentication Timing

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.

Signature Authentication

Example 1 As a request body

# request body
# symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559

# Get HMAC SHA256 signature
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 result
# c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71

# Request signed endpoints, /api/v3/order as an example
curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.us/api/v3/order' -d 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
import urllib.parse
import hashlib
import hmac
import base64
import requests
import calendar
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A"
secret_key = "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"

uri_path = "/api/v3/order"
data = {
    "symbol": "BTCUSDT",
    "side": "BUY",
    "type": "LIMIT",
    "timeInForce": "GTC",
    "quantity": 1,
    "price": 0.1,
    "timestamp": int(round(time.time() * 1000))
}

binanceus_request(uri_path, data, api_key, secret_key)

Example 2 As a query string

# query string
# symbol=BTCUSDT&timestamp=1499827319559

# Get HMAC SHA256 signature
echo -n "symbol=BTCUSDT&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"

# stdin result
# c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71

# Request signed endpoints, /api/v3/order as an example
curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X GET 'https://api.binance.us/api/v3/openOrders?symbol=BTCUSDT&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
import urllib.parse
import hashlib
import hmac
import base64
import requests

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={**data, "signature": signature}
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key = "vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A"
secret_key = "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"

uri_path = "/api/v3/openOrders"
data = {
    "symbol": "BTCUSDT",
    "timestamp": 1499827319559
}

get_open_order_result = binanceus_request(uri_path, data, api_key, secret_key)

Example 3 Mixed query string and request body

# query string
# symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC

# request body
# quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559

# Get HMAC SHA256 signature
shell echo -n "symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTCquantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559" | openssl dgst -sha256 -hmac "NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j"

# stdin result
# 0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77

# Request signed endpoints, /api/v3/order as an example
curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.us/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC' -d 'quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=0fd168b8ddb4876a0358a8d14d0c9f3da0e9b20c5d52b2a00fcf7d1c602f9a77'

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

Error Responses

Error Responses

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

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

HTTP Errors

Server/Network Errors

- 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

Request Errors

- 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

- 1135 INVALID_JSON

- 2010 NEW_ORDER_REJECTED

- 2011 CANCEL_REJECTED

- 2013 NO_SUCH_ORDER

- 2014 BAD_API_KEY_FMT

- 2015 REJECTED_MBX_KEY

- 2016 NO_TRADING_WINDOW

- 2021 Order cancel-replace partially failed

- 2022 Order cancel-replace failed.

Matching Engine Errors

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 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
"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 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 are 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 this 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.

Filter Failure Errors

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_NUM_ORDERS" Account has too many open orders on the symbol
"Filter failure: MAX_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_ALGO_ORDERS" Account has too many open stop loss and/or take profit orders on the exchange

Rate Limits

IP Limits

Order Rate Limits

Withdrawal Rate Limits

Changelog

30/11/2022

WEBSOCKET

REST API

USER DATA STREAM

16/11/2022

15/11/2022

11/4/2022

9/20/2022

8/12/2022

6/15/2022

3/3/2022

1/21/2022

1/22/2021

Support

Get API Support

Have questions about our APIs? Find the help you need in our Telegram support group.

Contact Customer Support

For non-API issues, please submit a ticket here.

REST API

General Data Endpoints

System Information

Test Connectivity

Example

curl 'https://api.binance.us/api/v3/ping'
import requests

resp = requests.get('https://api.binance.us/api/v3/ping')

print(resp.json())

Response

{}

GET /api/v3/ping

Use this endpoint to test connectivity to the exchange.

Weight: 1

Parameters: NONE

Data Source: Memory

Get Server Time

Example

curl 'https://api.binance.us/api/v3/time'
import requests

resp = requests.get('https://api.binance.us/api/v3/time')

print(resp.json())

Response

{
  "serverTime": 1499827319559
}

GET /api/v3/time

Use this endpoint to get the exchange’s server time.

Weight: 1

Parameters: NONE

Data Source: Memory

Get System Status

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/system/status?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/system/status"
data = {
   "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
   "status": 0 // 0: normal, 1: system maintenance
}

GET /sapi/v1/system/status (HMAC SHA256)

Use this endpoint to fetch whether the system status is normal or under maintenance.

Weight: 1

Parameters:

Name Type Mandatory Description
timestamp LONG YES

Data Source: Memory

Exchange Information

Get Exchange Information

Example

curl 'https://api.binance.us/api/v3/exchangeInfo'
import requests

resp = requests.get('https://api.binance.us/api/v3/exchangeInfo')

print(resp.json())

Response

{
  "timezone": "UTC",
  "serverTime": 1565246363776,
  "rateLimits": [
    {
      //These are defined in the `ENUM definitions` section under `Rate Limiters (rateLimitType)`.
      //All limits are optional
    }
  ],
  "exchangeFilters": [
    //These are the defined filters in the `Filters` section.
    //All filters are optional.
  ],
  "symbols": [
    {
      "symbol": "ETHBTC",
      "status": "TRADING",
      "baseAsset": "ETH",
      "baseAssetPrecision": 8,
      "quoteAsset": "BTC",
      "quotePrecision": 8,
      "quoteAssetPrecision": 8,
      "baseCommissionPrecision": 8,
      "quoteCommissionPrecision": 8,
      "orderTypes": [
        "LIMIT",
        "LIMIT_MAKER",
        "MARKET",
        "STOP_LOSS",
        "STOP_LOSS_LIMIT",
        "TAKE_PROFIT",
        "TAKE_PROFIT_LIMIT"
      ],
      "icebergAllowed": true,
      "ocoAllowed": true,
      "quoteOrderQtyMarketAllowed": true,
      "allowTrailingStop": false
      "cancelReplaceAllowed": true,
      "isSpotTradingAllowed": true,
      "isMarginTradingAllowed": false,
      "filters": [
        //These are defined in the Filters section.
        //All filters are optional
      ]
    }
  ],
  "permissions": [
     "SPOT"
  ],
  "defaultSelfTradePreventionMode": "NONE",
  "allowedSelfTradePreventionModes": [
     "NONE"
  ]
}

GET /api/v3/exchangeInfo

Use this endpoint to get the current exchange trading rules and trading pair information.

Weight: 10

Parameters:

There are 4 possible options:

Options Example
No parameter curl -X GET "https://api.binance.us/api/v3/exchangeInfo"
symbol curl -X GET "https://api.binance.us/api/v3/exchangeInfo?symbol=BNBBTC"
symbols curl -X GET curl -X GET "https://api.binance.us/api/v3/exchangeInfo?symbols=%5B%22BNBBTC%22,%22BTCUSDT%22%5D"
or
curl -g GET 'https://api.binance.us/api/v3/exchangeInfo?symbols=["BTCUSDT","BNBBTC"]'
permissions curl -X GET "https://api.binance.us/api/v3/exchangeInfo?permissions=SPOT"

Notes:

Data Source: Memory

Market Data Endpoints

Trade Data

Get Recent Trades

Example

curl -X "GET" "https://api.binance.us/api/v3/trades?symbol=LTCBTC"
import requests

resp = requests.get('https://api.binance.us/api/v3/trades?symbol=LTCBTC')

print(resp.json())

Response

[
  {
    "id": 981492,
    "price": "0.00380100",
    "qty": "0.22000000",
    "quoteQty": "0.00083622",
    "time": 1637128016269,
    "isBuyerMaker": false,
    "isBestMatch": true
  },
]

GET /api/v3/trades

Use this endpoint to get the recent trades. Please note the maximum limit is 1,000 trades.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING YES
limit INT NO Default 500; max 1000

Data Source: Memory

Get Historical Trades

Example

curl -X "GET" "https://api.binance.us/api/v3/historicalTrades?symbol=<symbol>" \
     -H "X-MBX-APIKEY: <your_api_key>"
import requests

headers = {}
headers['X-MBX-APIKEY'] = <your_api_key>

resp = requests.get('https://api.binance.us/api/v3/historicalTrades?symbol=<symbol>', headers=headers)

print(resp.json())

Response

[
  {
    "id": 17,
    "price": "0.06800000",
    "qty": "1.00000000",
    "quoteQty": "0.06800000",
    "time": 1635489737109,
    "isBuyerMaker": false,
    "isBestMatch": true
  }
]

GET /api/v3/historicalTrades

Use this endpoint to get older trades. Please note the maximum limit is 1,000 trades.

Weight: 5

Parameters:

Name Type Mandatory Description
symbol STRING YES
limit INT NO Default 500; max 1000
fromId LONG NO TradeId to fetch from. Default gets most recent trades

Data Source: Database

Get Aggregate Trades

Example

curl -X "GET" "https://api.binance.us/api/v3/aggTrades?symbol=LTCBTC"
import requests

resp = requests.get('https://api.binance.us/api/v3/aggTrades?symbol=LTCBTC')

print(resp.json())

Response

[
  {
    "a": 874844,
    "p": "0.00379700",
    "q": "0.05000000",
    "f": 981493,
    "l": 981493,
    "T": 1637128220041,
    "m": true,
    "M": true
  }
]

GET /api/v3/aggTrades

Use this endpoint to get compressed, aggregate trades. Trades that fill at the same time, from the same order, with the same price, will have the quantity aggregated. Please note the maximum limit is 1,000 trades.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING YES
fromId LONG NO ID to get aggregate trades from INCLUSIVE
startTime LONG NO Timestamp in ms to get aggregate trades from INCLUSIVE
endTime LONG NO Timestamp in ms to get aggregate trades until INCLUSIVE
limit INT NO Default 500; max 1000

Data Source: Database

Get Order Book Depth

Example

curl -X "GET" "https://api.binance.us/api/v3/depth?symbol=LTCBTC"
import requests

resp = requests.get('https://api.binance.us/api/v3/depth?symbol=LTCBTC')

print(resp.json())

Response

{
  "lastUpdateId": 1027024,
  "bids": [
    [
      "0.00379200",
      "31.26000000"
    ]
  ],
  "asks": [
    [
      "0.00380100",
      "32.37000000"
    ]
  ]
}

GET /api/v3/depth

Use this endpoint to get order book depth (prices and quantities of bids and asks).

Weight(IP): Adjusted based on the limit:

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, the response will truncate to 5000

Data Source: Memory

Get Candlestick Data

Example

curl -X "GET" "https://api.binance.us/api/v3/klines?symbol=LTCBTC&interval=1m"
import requests

resp = requests.get('https://api.binance.us/api/v3/klines?symbol=LTCBTC&interval=1m')

print(resp.json())

Response

[
  [
    1499040000000,      // Open time
    "0.00386200",       // Open
    "0.00386200",       // High
    "0.00386200",       // Low
    "0.00386200",       // Close
    "0.47000000",  // Volume
    1499644799999,      // Close time
    "0.00181514",    // Quote asset volume
    1,                // Number of trades
    "0.47000000",    // Taker buy base asset volume
    "0.00181514",      // Taker buy quote asset volume
    "0" // Ignore.
  ]
]

GET /api/v3/klines

Use this endpoint to get Kline/candlestick bars for a token symbol. Klines are uniquely identified by their open time. Please note the maximum limit is 1,000 bars.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING YES
interval ENUM YES
startTime LONG NO
endTime LONG NO
limit INT NO Default 500; max 1000

Data Source: Database

Price Data

Get Live Ticker Price

Example

# Example A, symbol param provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/price?symbol=LTCBTC"

# Example B, no symbol provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/price"
# Example A, symbol param provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/price?symbol=LTCBTC')

print(resp.json())

# Example B, no symbol provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/price')

print(resp.json())

Response A

{
  "symbol": "LTCBTC",
  "price": "0.00378800"
}

Response B

[
  {
    "symbol": "BTCUSD",
    "price": "59705.0700"
  },
  {
    "symbol": "ETHUSD",
    "price": "4178.7200"
  }
]

GET /api/v3/ticker/price

Use this endpoint to get the live ticker price.

Weight(IP):

Parameter Symbols Provided Weight
symbol 1 1
symbol parameter is omitted 2
symbols Any 2

Parameters:

Name Type Mandatory Description
symbol STRING NO 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 STRING NO Exaples of accepted format for the symbols parameter: ["BTCUSDT", "BNBUSDT"] or %5B%22BTCUSDT%22, %22BNBUSDT%22%5D

Data Source: Memory

Get Average Price

Example

curl -X "GET" "https://api.binance.us/api/v3/avgPrice?symbol=LTCBTC"
import requests

resp = requests.get('https://api.binance.us/api/v3/avgPrice?symbol=LTCBTC')
print(resp.json())

Response

{
  "mins": 5,
  "price": "0.00378906"
}

GET /api/v3/avgPrice

Use this endpoint to get the current average price for a symbol.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING YES

Data Source: Memory

Get Best Order Book Price

Example

# Example A, symbol param provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/bookTicker?symbol=LTCBTC"

# Example B, no symbol provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/bookTicker"
# Example A, symbol param provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/bookTicker?symbol=LTCBTC')
print(resp.json())

# Example B, no symbol provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/bookTicker')
print(resp.json())

Response A

{
  "symbol": "LTCBTC",
  "bidPrice": "0.00378600",
  "bidQty": "3.50000000",
  "askPrice": "0.00379100",
  "askQty": "26.69000000"
}

Response B

[
  {
    "symbol": "BTCUSD",
    "bidPrice": "59614.7400",
    "bidQty": "0.07100000",
    "askPrice": "59630.2500",
    "askQty": "0.07100000"
  },
  {
    "symbol": "ETHUSD",
    "bidPrice": "4171.2800",
    "bidQty": "0.72000000",
    "askPrice": "4172.3700",
    "askQty": "5.40000000"
  },
]

GET /api/v3/ticker/bookTicker

Use this endpoint to get the best available order book price.

Weight(IP):

Parameter Symbols Provided Weight
symbol 1 1
symbol parameter is omitted 2
symbols Any 2

Parameters:

Name Type Mandatory Description
symbol STRING NO Parameter symbol and symbols cannot be used in combination. If neither parameter is sent, bookTickers for all symbols will be returned in an array
symbols STRING NO Exaples of accepted format for the symbols parameter: ["BTCUSDT", "BNBUSDT"] or %5B%22BTCUSDT%22, %22BNBUSDT%22%5D

Data Source: Memory

Get 24h Price Change Statistics

Example

# Example A, symbol param provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/24hr?symbol=BNBBTC"

# Example B, no symbol provided
curl -X "GET" "https://api.binance.us/api/v3/ticker/24hr"
# Example A, symbol param provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/24hr?symbol=BNBBTC')

print(resp.json())

# Example B, no symbol provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker/24hr')

print(resp.json())

Response A

{
  "symbol": "BNBBTC",
  "priceChange": "-0.00046450",
  "priceChangePercent": "-4.659",
  "weightedAvgPrice": "0.00978390",
  "prevClosePrice": "0.00997050",
  "lastPrice": "0.00950520",
  "lastQty": "0.09000000",
  "bidPrice": "0.00950060",
  "bidQty": "0.25000000",
  "askPrice": "0.00950520",
  "askQty": "13.74000000",
  "openPrice": "0.00996970",
  "highPrice": "0.01012120",
  "lowPrice": "0.00950500",
  "volume": "7936.25000000",
  "quoteVolume": "77.64747556",
  "openTime": 1637042984994,
  "closeTime": 1637129384994,
  "firstId": 1851686,
  "lastId": 1856703,
  "count": 5018
}

Response B

[
  {
    "symbol": "BTCUSD",
    "priceChange": "-1267.1100",
    "priceChangePercent": "-2.083",
    "weightedAvgPrice": "60099.2142",
    "prevClosePrice": "60842.0600",
    "lastPrice": "59566.4300",
    "lastQty": "0.03454900",
    "bidPrice": "59525.6600",
    "bidQty": "0.07100000",
    "askPrice": "59543.0900",
    "askQty": "0.42600000",
    "openPrice": "60833.5400",
    "highPrice": "61406.0700",
    "lowPrice": "58585.4900",
    "volume": "1675.88065900",
    "quoteVolume": "100719110.6761",
    "openTime": 1637043019764,
    "closeTime": 1637129419764,
    "firstId": 25821891,
    "lastId": 25894571,
    "count": 72681
  },
  {
    "symbol": "ETHUSD",
    "priceChange": "-160.0800",
    "priceChangePercent": "-3.701",
    "weightedAvgPrice": "4233.5077",
    "prevClosePrice": "4326.0600",
    "lastPrice": "4165.8000",
    "lastQty": "2.42310000",
    "bidPrice": "4165.2100",
    "bidQty": "0.00484000",
    "askPrice": "4165.4100",
    "askQty": "6.12000000",
    "openPrice": "4325.8800",
    "highPrice": "4349.1400",
    "lowPrice": "4065.6400",
    "volume": "20975.27292000",
    "quoteVolume": "88798979.5292",
    "openTime": 1637043020441,
    "closeTime": 1637129420441,
    "firstId": 23606820,
    "lastId": 23673128,
    "count": 66309
  },
]

GET /api/v3/ticker/24hr

Use this endpoint to get price change data for the past 24hrs.

Weight(IP):

Parameter Symbols Provided Weight
symbol 1 1
symbol parameter is omitted 40
symbols 1-20 1
21-100 20
101 or more 40
symbols parameter is omitted 40

Parameters:

Name Type Mandatory Description
symbol STRING NO Parameter symbol and symbols cannot be used in combination. If neither parameter is sent, tickers for all symbols will be returned in an array
symbols STRING NO Exaples of accepted format for the symbols parameter: ["BTCUSDT", "BNBUSDT"] or %5B%22BTCUSDT%22, %22BNBUSDT%22%5D
type ENUM NO Supported values: FULL or MINI.
If none provided,the default is FULL.
FULL is the default value and the response that is currently being returned from the endpoint.
MINI omits the following fields from the response: priceChangePercent, weightedAvgPrice,bidPrice, bidQty, askPrice, askQty, and lastQty

Data Source: Memory

Get Rolling Window Price Change Statistics

Example

# Example A, symbol param provided
curl -X "GET" "https://api.binance.us/api/v3/ticker?symbol=BNBBTC"

# Example A, symbols param provided
curl -X "GET" "https://api.binance.us/api/v3/ticker?symbols=%5B%22BTCUSDT%22,%22BNBBTC%22%5D"
# Example A, symbol param provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker?symbol=BNBBTC')

print(resp.json())

# Example B, symbols provided
import requests

resp = requests.get('https://api.binance.us/api/v3/ticker?symbols=%5B%22BTCUSDT%22,%22BNBBTC%22%5D')

print(resp.json())

Response A

{
  "symbol":             "BNBBTC",
  "priceChange":        "-8.00000000",  // Absolute price change
  "priceChangePercent": "-88.889",      // Relative price change in percent
  "weightedAvgPrice":   "2.60427807",   // QuoteVolume / Volume
  "openPrice":          "9.00000000",
  "highPrice":          "9.00000000",
  "lowPrice":           "1.00000000",
  "lastPrice":          "1.00000000",
  "volume":             "187.00000000",
  "quoteVolume":        "487.00000000", // Sum of (price * volume) for all trades
  "openTime":           1641859200000,  // Open time for ticker window
  "closeTime":          1642031999999,  // Current Time of the Request
  "firstId":            0,              // Trade IDs
  "lastId":             60,
  "count":              61              // Number of trades in the interval
}

Response B

[
  {
    "symbol": "BTCUSDT",
    "priceChange": "-154.13000000",
    "priceChangePercent": "-0.740",
    "weightedAvgPrice": "20677.46305250",
    "openPrice": "20825.27000000",
    "highPrice": "20972.46000000",
    "lowPrice": "20327.92000000",
    "lastPrice": "20671.14000000",
    "volume": "72.65112300",
    "quoteVolume": "1502240.91155513",
    "openTime": 1655432400000,
    "closeTime": 1655446835460,
    "firstId": 11147809,
    "lastId": 11149775,
    "count": 1967
  },
  {
    "symbol": "BNBBTC",
    "priceChange": "0.00008530",
    "priceChangePercent": "0.823",
    "weightedAvgPrice": "0.01043129",
    "openPrice": "0.01036170",
    "highPrice": "0.01049850",
    "lowPrice": "0.01033870",
    "lastPrice": "0.01044700",
    "volume": "166.67000000",
    "quoteVolume": "1.73858301",
    "openTime": 1655432400000,
    "closeTime": 1655446835460,
    "firstId": 2351674,
    "lastId": 2352034,
    "count": 361
  }
]

GET /api/v3/ticker

Use this endpoint to get the price change data within a requested window of time.

Note: openTime reverts to the start of the minute (e.g. 09:17:00 UTC, instead of 09:17:47:99). closeTime is the current time of the request (including seconds and milliseconds). Therefore, the effective window can be up to 59999ms (59 seconds) longer than the specified windowSize.

E.g. If the closeTime is 1641287867099 (January 04, 2022 09:17:47:099 UTC), and the windowSize is 1d. the openTime will be: 1641201420000 (January 3, 2022, 09:17:00 UTC).

Weight:

2 for each requested symbol regardless of windowSize.

The weight for this request will cap at 100 once the number of symbols in the request is more than 50.

Parameters:

Name Type Mandatory Description
symbol



symbols
STRING YES Either symbol or symbols must be provided
Examples of accepted format for the symbols parameter:
["BTCUSDT","BNBUSDT"]
or
%5B%22BTCUSDT%22,%22BNBUSDT%22%5D

The maximum number of symbols allowed in a request is 100
windowSize ENUM NO Defaults to 1d if no parameter provided
Supported windowSize values:
1m, 2m ... 59m for minutes
1h, 2h ... 23h - for hours
1d ... 7d - for days

Units cannot be combined (e.g. 1d2h is not allowed)
type ENUM NO Supported values: FULL or MINI.
If none provided,the default is FULL.
FULL is the default value and the response that is currently being returned from the endpoint.
MINI omits the following fields from the response: priceChangePercent, weightedAvgPrice,bidPrice, bidQty, askPrice, askQty, and lastQty

Data Source: Database

User Data Endpoints

User Account Data

Get User Account Information

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/account?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/account"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

get_account_result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, get_account_result))

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":"BTC",
            "free":"4723846.89208129",
            "locked":"0.00000000"
        },
        {
            "asset":"LTC",
            "free":"4763368.68006011",
            "locked":"0.00000000"
        }
    ],
    "permissions":[
        "SPOT"
    ]
}

GET /api/v3/account (HMAC SHA256)

Use this endpoint to get current account information.

Weight: 10

Parameters:

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

Data Source: Database

Get User Account Status

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v3/accountStatus?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v3/accountStatus"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

// Response A
{
    "msg": "Order failed:Low Order fill rate! Will be reactivated after 5 minutes.",
    "success": true,
    "objs": [
        "5"
    ]
}

// Response B
{
    "msg": "Normal",
    "success": true
}

Get /sapi/v3/accountStatus (HMAC SHA256)

Use this endpoint to fetch account status details.

Weight: 1

Parameters:

Name Type Mandatory Description
timestamp LONG YES

Data Source: Database

Get User API Trading Status

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v3/apiTradingStatus?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v3/apiTradingStatus"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "success": true,     // Query result
    "status": {          // API trading status detail
        "isLocked": false,   // API trading function is locked or not
        "plannedRecoverTime": 0,  // If API trading function is locked, this is the planned recover time
        "triggerCondition": {
            "GCR": 150,  // Number of GTC orders
            "IFER": 150, // Number of FOK/IOC orders
            "UFR": 300   // Number of orders
        },
        "indicators": {  // The indicators updated every 30 seconds
           "BTCUSDT": [  // The symbol
            {
            "i": "UFR",  // Unfilled Ratio (UFR)
            "c": 20,     // Count of all orders
            "v": 0.05,   // Current UFR value
            "t": 0.995   // Trigger UFR value
            },
            {
            "i": "IFER", // IOC/FOK Expiration Ratio (IFER)
            "c": 20,     // Count of FOK/IOC orders
            "v": 0.99,   // Current IFER value
            "t": 0.99    // Trigger IFER value
            },
            {
            "i": "GCR",  // GTC Cancellation Ratio (GCR)
            "c": 20,     // Count of GTC orders
            "v": 0.99,   // Current GCR value
            "t": 0.99    // Trigger GCR value
            }
            ],
            "ETHUSDT": [
            {
            "i": "UFR",
            "c": 20,
            "v": 0.05,
            "t": 0.995
            },
            {
            "i": "IFER",
            "c": 20,
            "v": 0.99,
            "t": 0.99
            },
            {
            "i": "GCR",
            "c": 20,
            "v": 0.99,
            "t": 0.99
            }
            ]
        },
        "updateTime": 1547630471725   // The query result return time
    }
}

GET /sapi/v3/apiTradingStatus (HMAC SHA256)

Use this endpoint to fetch account API trading status details.

Weight: 1

Parameters:

Name Type Mandatory Description
recvWindow LONG NO
timestamp LONG YES

Data Source: Database

Get Asset Distribution History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/asset/assetDistributionHistory?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/asset/assetDistributionHistory"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "rows":[
        {
            "amount": "10.00000000",
            "asset": "BHFT",
            "divTime": 1563189166000,
            "category": "BHFT distribution",
            "tranId": 2968885920
        },
        {
            "amount": "10.00000000",
            "asset": "BHFT",
            "divTime": 1563189165000,
            "category": "BHFT distribution",
            "tranId": 2968885920
        }
    ],
    "total": 2
}

GET /sapi/v1/asset/assetDistributionHistory (HMAC SHA256)

Use this endpoint to query asset distribution records, including rebate and airdrop, etc.

Weight: 1

Parameters:

Name Type Mandatory Description
asset STRING NO Distribution asset
category STRING NO Distribution category (e.g.,rebate, airdrop)
startTime LONG NO Distribution start time
endTime LONG NO Distribution end time
limit INT NO Limit rows (default: 20, max: 500)
timestamp LONG YES Current timestamp

Data Source: database

Quick Disable Crypto Withdrawal

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/account/quickDisableWithdrawal?timestamp=$timestamp&signature=$signature"  \
  -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/account/quickDisableWithdrawal"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Post /sapi/v1/account/quickDisableWithdrawal (HMAC SHA256)

Use this endpoint to disable crypto withdrawals.

Weight: 1

Parameters:

Name Type Mandatory Description
timestamp LONG YES

Data Source: Database

Quick Enable Crypto Withdrawal

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/account/quickEnableWithdrawal?timestamp=$timestamp&signature=$signature"  \
  -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/account/quickEnableWithdrawal"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Post /sapi/v1/account/quickEnableWithdrawal (HMAC SHA256)

Use this endpoint to enable crypto withdrawals.

Weight: 1

Parameters:

Name Type Mandatory Description
timestamp LONG YES

Data Source: Database

Get User’s Spot Asset Snapshot

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
type=<type>
startTime=<startTime>
endTime=<endTime>
limit=<limit>

api_url="https://api.binance.us"

signature=`echo -n "type=$type&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/accountSnapshot?type=$type&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"

import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
snapshot_type='SPOT'

uri_path = "/sapi/v1/accountSnapshot"
data = {
    "type": snapshot_type,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "code": 200,
    "msg": "",
    "snapshotVos": []
}

GET /sapi/v1/accountSnapshot (HMAC SHA256)

Use this endpoint to get a snapshot of user’s assets in spot orders.

Weight: 1

Parameters:

Name Type Mandatory Description
type STRING YES The unique value is 'SPOT'
startTime LONG NO
endTime LONG NO
limit INT NO
offset INT NO Default value: 5
timestamp LONG YES

Data Source: Database

Get Trade Fee

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X GET "$api_url/sapi/v1/asset/query/trading-fee?timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = '/sapi/v1/asset/query/trading-fee'
data = {"timestamp": int(round(time.time() * 1000))}

get_account_result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, get_account_result))

Response

[
    {
        "symbol": "1INCHUSD",
        "makerCommission": "0.004",
        "takerCommission": "0.006"
    },
    {
        "symbol": "1INCHUSDT",
        "makerCommission": "0.004",
        "takerCommission": "0.006"
     }
]

GET /sapi/v1/asset/query/trading-fee (HMAC SHA256)

Use this endpoint to get your current maker & taker fee rates for spot trading based on your VIP level or manual fee adjustment. Discount for using BNB to pay fees (25% off) is not factored in.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING NO, if not specified, will return all Symbol name

Data Source: Database

Get Past 30 days Trade Volume

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X GET "$api_url/sapi/v1/asset/query/trading-volume?timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import requests
import time

api_url = "https://api.binance.us"


# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac


# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload = {
       **data,
       "signature": signature,
    }
   req = requests.get((api_url + uri_path), params=payload, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
uri_path = '/sapi/v1/asset/query/trading-volume'
data = {"timestamp": int(round(time.time() * 1000))}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "past30DaysTradingVolume": 100
}

GET /sapi/v1/asset/query/trading-volume (HMAC SHA256)

Use this endpoint to get total trade volume for the past 30 days, calculated on a rolling basis every day at 0:00 AM (UTC).

Weight: 1

Parameters: NONE

Data Source: Database

Sub-account Data

Get Sub-account Information

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v3/sub-account/list?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v3/sub-account/list"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "success": true,
    "subAccounts": [
        {
            "email": "123@test.com",
            "status": "enabled",
            "activated": true,
            "mobile": "91605290",
            "gAuth": true,
            "createTime": 1544433328000
        },
        {
            "email": "321@test.com",
            "status": "disabled",
            "activated": true,
            "mobile": "22501238",
            "gAuth": true,
            "createTime": 1544433328000
        }
    ]
}

GET /sapi/v3/sub-account/list (HMAC SHA256)

Use this endpoint to get your sub-account list.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING NO Sub-account email
status STRING NO Sub-account status: enabled or disabled
page INT NO Default value: 1
limit INT NO Default value: 500
recvWindow LONG NO
timestamp LONG YES

Data Source: Database

Get Sub-account Transfer History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v3/sub-account/transfer/history?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v3/sub-account/transfer/history"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
  "msg": "string",
  "success": true,
  "transfers": [
    {
      "asset": "BNB",
      "from": "aa.email.com",
      "qty": "10",
      "time": 1637789299,
      "to": "bb.email.com"
    }
  ]
}

GET /sapi/v3/sub-account/transfer/history (HMAC SHA256)

Use this endpoint to fetch sub-account asset transfer history.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING NO Sub-account email
startTime LONG NO
endTime LONG NO
page INT NO The transfer history batch number (each batch contains at most 500 transfer history records)
limit INT NO Default value: 500
timestamp LONG YES

Data Source Database

Execute Sub-account Transfer

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

fromEmail=<your_from_email>
toEmail=<your_to_email>
asset=<asset>
amount=<amount>

api_url="https://api.binance.us"

signature=`echo -n "fromEmail=$fromEmail&toEmail=$toEmail&asset=$asset&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v3/sub-account/transfer?fromEmail=$fromEmail&toEmail=$toEmail&asset=$asset&amount=$amount&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url="https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    print('postdata: {}', postdata)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    print('Signature: {}', signature)
    payload={
        **data,
        "signature": signature,
    }
    req = requests.post((api_url + uri_path), params=payload, headers=headers)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>

fromEmail=<your_from_email>
toEmail=<your_to_email>
asset=<asset>
amount=<amount>
uri_path = "/sapi/v3/sub-account/transfer"
data = {
    "asset": asset,
    "amount": amount,
    "toEmail": toEmail,
    "fromEmail": fromEmail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
  "msg": "Success",
  "success": true,
  "txnId": "2966662589"
}

POST /sapi/v3/sub-account/transfer(HMAC SHA256)

Use this endpoint to execute an asset transfer between the master account and a sub-account.

Weight: 1

Parameters:

Name Type Mandatory Description
fromEmail STRING YES Sender email
toEmail STRING YES Recipient email
asset STRING YES
amount DECIMAL YES
timestamp LONG YES

Data Source: Database

Get Sub-account Assets

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

email="ios@mt.com"

signature=`echo -n "email=$email&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v3/sub-account/assets?email=$email&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"

import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

your_email=<your_your_email>
uri_path = "/sapi/v3/sub-account/assets"
data = {
    "timestamp": int(round(time.time() * 1000)),"email": your_email
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "balances":
    [
        {
            "asset":"BTC", //asset
            "Free":0, //free
            "Locked":0 //locked
        },
        {
            "asset":"BNB",
            "free":98,
            "locked":0
        },
        {
            "asset":"ETH",
            "free":0,
            "locked":0
        },
        {
            "asset":"LTC",
            "free":0,
            "locked":0
        },
        {
            "asset":"USDT",
            "free":0,
            "locked":0
        }
    ],
    "success":true
}

GET /sapi/v3/sub-account/assets (HMAC SHA256)

Use this endpoint to fetch sub-account assets.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING YES Sub-account Email
timestamp LONG YES

Data Source: Database

Get Master Account's Total USD Value

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
email=<email>
page=<page>
size=<size>

api_url="https://api.binance.us"

signature=`echo -n "email=$email&page=$page&size=$size&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/sub-account/spotSummary?email=$email&page=$page&size=$size&timestamp=$timestamp&signature=$signature" \
   -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
email=<email>
page=<page>
size=<size>

uri_path = "/sapi​/v1​/sub-account​/spotSummary"
data = {
    "email":email,
    "page":page,
    "size":size,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "totalCount": 2,
    "masterAccountTotalAsset": 401,
    "spotSubUserAssetBtcVoList": [
        {
            "email": "test001@123.com",
            "totalAsset": 201
        },
        {
            "email": "test002@123.com",
            "totalAsset": 200
        }
    ]
}

GET ​/sapi​/v1​/sub-account​/spotSummary (HMAC SHA256)

Use this endpoint to get the total value of assets in the master account in USD.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING NO
page INT NO
size INT NO
timestamp LONG YES

Data Source: Database

Get Sub-account Status List

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
email=<email>


api_url="https://api.binance.us"

signature=`echo -n "email=$email&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url​​/sapi​/v1​/sub-account​/status?email=$email&timestamp=$timestamp&signature=$signature" \
  -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
email=<email>

uri_path = "​​/sapi​/v1​/sub-account​/status"
data = {
    "email":email,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "email": "test001@123.com",
        "insertTime": 1652944721676,
        "mobile": "XXXXXXXXXX",
        "isUserActive": true,
        "isMarginEnabled": true,
        "isSubUserEnabled": false,
        "isFutureEnabled": false
    },
    {
        "email": "test002@123.com",
        "insertTime": 1652944721676,
        "mobile": "XXXXXXXXXX",
        "isUserActive": true,
        "isMarginEnabled": false,
        "isSubUserEnabled": true,
        "isFutureEnabled": false
    }
]

GET ​​/sapi​/v1​/sub-account​/status (HMAC SHA256)

Use this endpoint to get a status list of sub-accounts.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING YES
timestamp LONG YES

Data Source: Database

Trade Order Endpoints

General Orders

Get Order Rate Limits

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

recvWindow=<recvWindow>

api_url="https://api.binance.us"

signature=`echo -n "recvWindow=$recvWindow&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/rateLimit/order?recvWindow=$recvWindow&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
    }
    req = requests.get((api_url + uri_path), params=payload, headers=headers)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>

recvWindow = <recvWindow>

uri_path = "/api/v3/rateLimit/order"
data = {
    "recvWindow": recvWindow,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "rateLimitType": "ORDERS",
    "interval": "SECOND",
    "intervalNum": 10,
    "limit": 100,
    "count": 0
  },
  {
    "rateLimitType": "ORDERS",
    "interval": "DAY",
    "intervalNum": 1,
    "limit": 200000,
    "count": 0
  }
]

GET /api/v3/rateLimit/order (HMAC SHA256)

Get the current trade order count rate limits for all time intervals.

Weight: 20

Parameters:

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

Data Source: Memory

Create New Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>

api_url="https://api.binance.us"

signature=`echo -n "symbol=$symbol&side=$side&type=$type&quantity=$quantity&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/api/v3/order?symbol=$symbol&side=$side&type=$type&quantity=$quantity&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>

uri_path = "/api/v3/order"
data = {
    "symbol": symbol,
    "side": side,
    "type": type,
    "quantity": quantity,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response ACK:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595
}

Response RESULT:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "0.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL",
  "workingTime":1507725176595,
  "selfTradePreventionMode": "NONE"
}

Response FULL:

{
  "symbol": "BTCUSDT",
  "orderId": 28,
  "orderListId": -1, //Unless OCO, value will be -1
  "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
  "transactTime": 1507725176595,
  "price": "0.00000000",
  "origQty": "10.00000000",
  "executedQty": "10.00000000",
  "cummulativeQuoteQty": "10.00000000",
  "status": "FILLED",
  "timeInForce": "GTC",
  "type": "MARKET",
  "side": "SELL",
  "workingTime":1507725176595,
  "selfTradePreventionMode": "NONE"
  "fills": [
    {
      "price": "4000.00000000",
      "qty": "1.00000000",
      "commission": "4.00000000",
      "commissionAsset": "USDT",
      "tradeId": 56
    },
    {
      "price": "3999.00000000",
      "qty": "5.00000000",
      "commission": "19.99500000",
      "commissionAsset": "USDT",
      "tradeId": 57
    },
    {
      "price": "3998.00000000",
      "qty": "2.00000000",
      "commission": "7.99600000",
      "commissionAsset": "USDT",
      "tradeId": 58
    },
    {
      "price": "3997.00000000",
      "qty": "1.00000000",
      "commission": "3.99700000",
      "commissionAsset": "USDT",
      "tradeId": 59
    },
    {
      "price": "3995.00000000",
      "qty": "1.00000000",
      "commission": "3.99500000",
      "commissionAsset": "USDT",
      "tradeId": 60
    }
  ]
}

POST /api/v3/order (HMAC SHA256)

Use this endpoint to place a new trade order.

Weight: 1

Parameters:

Name Type Mandatory Description
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD)
side ENUM YES Order side (e.g., BUY, SELL)
type ENUM YES Order type (e.g., LIMIT, MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER)
timeInForce ENUM NO
quantity DECIMAL NO
quoteOrderQty DECIMAL NO
price DECIMAL NO Order price
newClientOrderId STRING NO A unique ID among open orders. Automatically generated if not sent.
Orders with the same newClientOrderID can be accepted only when the previous one is filled, otherwise the order will be rejected
stopPrice DECIMAL NO Used with STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT orders
trailingDelta LONG NO Used with STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT orders.
For more details on SPOT implementation on trailing stops, please refer to Trailing Stop FAQ
icebergQty DECIMAL NO Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order
newOrderRespType ENUM NO Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL; all other orders default to ACK
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Some additional mandatory parameters based on order type:

Type Additional Mandatory Parameters Additional Information
LIMIT timeInForce, quantity, price
MARKET quantity or quoteOrderQty MARKET orders using the quantity field specifies the amount of the base asset the user wants to buy or sell at the market price.
E.g., a MARKET order on BTCUSDT will specify how much BTC the user is buying or selling

MARKET orders using quoteOrderQty specify the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty.
E.g., Using the symbol BTCUSDT:
BUY side, the order will buy as many BTC as quoteOrderQty USDT can.
SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT
STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice,trailingDelta This will execute a LIMIT order when the stopPrice is reached
TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice,trailingDelta This will execute a LIMIT order when the stopPrice is reached
LIMIT_MAKER quantity, price This is a LIMIT order that will be rejected if the order immediately matches and trades as a taker.
This is also known as a POST-ONLY order

Other info:

Trigger order price rules against market price for both MARKET and LIMIT versions:

Data Source: Matching Engine

Test New Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>

api_url="https://api.binance.us"

signature=`echo -n "symbol=$symbol&side=$side&type=$type&quantity=$quantity&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/api/v3/order/test?symbol=$symbol&side=$side&type=$type&quantity=$quantity&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>

uri_path = "/api/v3/order/test"
data = {
    "symbol": symbol,
    "side": side,
    "type": type,
    "quantity": quantity,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{}

POST /api/v3/order/test (HMAC SHA256)

Use this endpoint to test new order creation and signature/recvWindow long. The endpoint creates and validates a new order but does not send it into the matching engine.

Weight: 1

Parameters:

Same as POST /api/v3/order

Data Source: Memory

Get Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
orderId=<orderId>
symbol=<symbol>

api_url="https://api.binance.us"

signature=`echo -n "orderId=$orderId&symbol=$symbol&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/order?orderId=$orderId&symbol=$symbol&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
orderId=<orderId>
symbol=<symbol>

uri_path = "/api/v3/order"
data = {
    "orderId": orderId,
    "symbol": symbol,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
  "symbol": "LTCBTC",
  "orderId": 1,
  "orderListId": -1 //Unless part of an OCO, the value will always be -1.
  "clientOrderId": "myOrder1",
  "price": "0.1",
  "origQty": "1.0",
  "executedQty": "0.0",
  "cummulativeQuoteQty": "0.0",
  "status": "NEW",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY",
  "stopPrice": "0.0",
  "icebergQty": "0.0",
  "time": 1499827319559,
  "updateTime": 1499827319559,
  "isWorking": true,
  "origQuoteOrderQty": "0.000000",
  "workingTime":1507725176595,
  "selfTradePreventionMode": "NONE"
}

GET /api/v3/order (HMAC SHA256)

Use this endpoint to check a trade order's status.

Weight: 2

Parameters:

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

Notes:

Data Source: Database

Get All Open Orders

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/openOrders?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/openOrders"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "symbol": "LTCBTC",
    "orderId": 1,
    "orderListId": -1, //Unless OCO, the value will always be -1
    "clientOrderId": "myOrder1",
    "price": "0.1",
    "origQty": "1.0",
    "executedQty": "0.0",
    "cummulativeQuoteQty": "0.0",
    "status": "NEW",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY",
    "stopPrice": "0.0",
    "icebergQty": "0.0",
    "time": 1499827319559,
    "updateTime": 1499827319559,
    "isWorking": true,
    "origQuoteOrderQty": "0.000000"
  }
]

GET /api/v3/openOrders (HMAC SHA256)

Use this endpoint to get all open trade orders for a token symbol. Do not access this without a token symbol as this would return all pair data.

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

Parameters:

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

Data Source: Database

Cancel Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
orderId=<orderId>
symbol=<symbol>

api_url="https://api.binance.us"

signature=`echo -n "orderId=$orderId&symbol=$symbol&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "DELETE" "$api_url/api/v3/order?orderId=$orderId&symbol=$symbol&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
orderId=<orderId>
symbol=<symbol>

uri_path = "/api/v3/order"
data = {
  "orderId": orderId,
  "symbol": symbol,
  "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

{
  "symbol": "LTCBTC",
  "origClientOrderId": "myOrder1",
  "orderId": 4,
  "orderListId": -1, //Unless part of an OCO, the value will always be -1.
  "clientOrderId": "cancelMyOrder1",
  "price": "2.00000000",
  "origQty": "1.00000000",
  "executedQty": "0.00000000",
  "cummulativeQuoteQty": "0.00000000",
  "status": "CANCELED",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY",
  "selfTradePreventionMode": "NONE"
}

DELETE /api/v3/order (HMAC SHA256)

Use this endpoint to cancel an active trade order.

Weight: 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 LONG NO The value cannot be greater than 60000
timestamp LONG YES

Either orderId or origClientOrderId must be sent.

Data Source: Matching Engine

Cancel Open Orders for Symbol

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>

api_url="https://api.binance.us"

signature=`echo -n "symbol=$symbol&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "DELETE" "$api_url/api/v3/openOrders?symbol=$symbol&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>

uri_path = "/api/v3/openOrders"
data = {
    "symbol": symbol,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

[
  {
    "symbol": "BTCUSDT",
    "origClientOrderId": "KZJijIsAFf5BU5oxkWTAU3",
    "orderId": 0,
    "orderListId": -1,
    "clientOrderId": "8epSIUMvNCknntXcSzWs7H",
    "price": "0.10000000",
    "origQty": "1.00000000",
    "executedQty": "0.00000000",
    "cummulativeQuoteQty": "0.00000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY"
  }
]

DELETE /api/v3/openOrders (HMAC SHA256)

Use this endpoint to cancels all active trade orders on a token symbol (this includes OCO orders).

Weight: 1

Parameters

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

Data Source: Matching Engine

Get Trades

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "symbol=BNBBTC&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/myTrades?symbol=BNBBTC&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/myTrades"
data = {
    "timestamp": int(round(time.time() * 1000)),
    "symbol": "BNBBTC"
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "symbol": "BNBBTC",
    "id": 28457,
    "orderId": 100234,
    "orderListId": -1,
    "price": "4.00000100",
    "qty": "12.00000000",
    "quoteQty": "48.000012",
    "commission": "10.10000000",
    "commissionAsset": "BNB",
    "time": 1499865549590,
    "isBuyer": true,
    "isMaker": false,
    "isBestMatch": true
  }
]

GET /api/v3/myTrades (HMAC SHA256)

Use this endpoint to get trade data for a specific account and token symbol.

Weight: 10 with symbol

Parameters:

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

Notes:

Data Source: Memory => Database

Replace Order

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
side=<side>
type=<type>
cancelReplaceMode=<cancelReplaceMode>
cancelOrderId=<cancelOrderId>
timeInForce=<timeInForce>
quantity=<quantity>
price=<price>
api_url="https://api.binance.us"
parameter_concat="symbol=$symbol&side=$side&type=$type&cancelReplaceMode=$cancelReplaceMode&cancelOrderId=$cancelOrderId&timeInForce=$timeInForce&quantity=$quantity&price=$price&timestamp=$timestamp"
signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/api/v3/order/cancelReplace?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path),headers=headers,data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/order/cancelReplace"
data = {
    "timestamp": int(round(time.time() * 1000)),
    "symbol":<symbol>
    "side":<side>
    "type":<type>
    "cancelReplaceMode":<cancelReplaceMode>
    "cancelOrderId":<cancelOrderId>
    "timeInForce":<timeInForce>
    "quantity":<quantity>
    "price":<price>
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

//Both the cancel order placement and new order placement succeeded.
{
  "cancelResult": "SUCCESS",
  "newOrderResult": "SUCCESS",
  "cancelResponse": {
    "symbol": "BTCUSDT",
    "origClientOrderId": "DnLo3vTAQcjha43lAZhZ0y",
    "orderId": 9,
    "orderListId": -1,
    "clientOrderId": "osxN3JXAtJvKvCqGeMWMVR",
    "price": "0.01000000",
    "origQty": "0.000100",
    "executedQty": "0.00000000",
    "cummulativeQuoteQty": "0.00000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "SELL",
    "selfTradePreventionMode": "NONE"
  },
  "newOrderResponse": {
    "symbol": "BTCUSDT",
    "orderId": 10,
    "orderListId": -1,
    "clientOrderId": "wOceeeOzNORyLiQfw7jd8S",
    "transactTime": 1652928801803,
    "price": "0.02000000",
    "origQty": "0.040000",
    "executedQty": "0.00000000",
    "cummulativeQuoteQty": "0.00000000",
    "status": "NEW",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY",
    "workingTime": 1652928801803,
    "fills": [],
    "selfTradePreventionMode": "NONE"
  }
}

POST /api/v3/order/cancelReplace (HMAC SHA256)

Cancels an existing order and places a new order on the same symbol.

Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.

A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED), will still increase the order count by 1.

Weight(IP):1

Parameters:

Name Type Mandatory Description
symbol STRING YES
side ENUM YES
type ENUM YES
cancelReplaceMode ENUM YES The allowed values are:
STOP_ON_FAILURE - If the cancel request fails, the new order placement will not be attempted.
ALLOW_FAILURE - new order placement will be attempted even if cancel request fails.
timeInForce ENUM NO
quantity DECIMAL NO
quoteOrderQty DECIMAL NO
price DECIMAL NO
cancelNewClientOrderId STRING NO Used to uniquely identify this cancel. Automatically generated by default.
cancelOrigClientOrderId STRING NO Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
cancelOrderId LONG NO Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence.
newClientOrderId STRING NO Used to identify the new order.
strategyId INT NO
strategyType INT NO The value cannot be less than 1000000.
stopPrice DECIMAL NO
trailingDelta LONG NO
icebergQty DECIMAL NO
newOrderRespType ENUM NO Allowed values:ACK, RESULT, FULL MARKET and LIMIT orders types default to FULL; all other orders default to ACK
recvWindow LONG NO The value cannot be greater than 60000
timestamp LONG YES

Notes:

Similar to POST /api/v3/order, additional mandatory parameters are determined by type.

Response format varies depending on whether the processing of the message succeeded, partially succeeded, or failed.

Data Source: Matching Engine

OCO Orders

Create New OCO Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
side=<side>
quantity=<quantity>
price=<price>
stopPrice=<stopPrice>
stopLimitPrice=<stopLimitPrice>
stopLimitTimeInForce=<stopLimitTimeInForce>

api_url="https://api.binance.us"

signature=`echo -n "symbol=$symbol&side=$side&quantity=$quantity&price=$price&stopPrice=$stopPrice&stopLimitPrice=$stopLimitPrice&stopLimitTimeInForce=$stopLimitTimeInForce&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/api/v3/order/oco?symbol=$symbol&side=$side&quantity=$quantity&price=$price&stopPrice=$stopPrice&stopLimitPrice=$stopLimitPrice&stopLimitTimeInForce=$stopLimitTimeInForce&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
symbol=<symbol>
side=<side>
quantity=<quantity>
price=<price>
stopPrice=<stopPrice>
stopLimitPrice=<stopLimitPrice>
stopLimitTimeInForce=<stopLimitTimeInForce>

uri_path = "/api/v3/order/oco"
data = {
    "timestamp": int(round(time.time() * 1000)),
    "symbol": symbol,
    "side": side,
    "quantity": quantity,
    "price": price,
    "stopPrice": stopPrice,
    "stopLimitPrice": stopLimitPrice,
    "stopLimitTimeInForce": stopLimitTimeInForce
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": 1563417480525,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos",
      "transactTime": 1563417480525,
      "price": "0.000000",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "STOP_LOSS",
      "side": "BUY",
      "stopPrice": "0.960664",
      "workingTime": -1,
      "selfTradePreventionMode": "NONE"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl",
      "transactTime": 1563417480525,
      "price": "0.036435",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "BUY",
      "workingTime": 1563417480525,
      "selfTradePreventionMode": "NONE"
    }
  ]
}

POST /api/v3/order/oco (HMAC SHA256)

Weight: 1

Use this endpoint to place a new OCO(one-cancels-the-other) order.

Parameters:

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

Other Info:

Data Source: Matching Engine

Get OCO Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
orderListId=<orderListId>

api_url="https://api.binance.us"

signature=`echo -n "orderListId=$orderListId&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/orderList?orderListId=$orderListId&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
orderListId=<orderListId>

uri_path = "/api/v3/orderList"
data = {
    "orderListId": orderListId,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
  "orderListId": 27,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "h2USkA5YQpaXHPIrkd96xE",
  "transactionTime": 1565245656253,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 4,
      "clientOrderId": "qD1gy3kc3Gx0rihm9Y3xwS"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 5,
      "clientOrderId": "ARzZ9I00CPM8i3NhmU9Ega"
    }
  ]
}

GET /api/v3/orderList (HMAC SHA256)

Weight: 2

Use this endpoint to retrieve a specific OCO order based on provided optional parameters.

Parameters:

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

Data Source: Database

Get All OCO Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/allOrderList?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/allOrderList"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "orderListId": 29,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "amEEAXryFzFwYF1FeRpUoZ",
    "transactionTime": 1565245913483,
    "symbol": "LTCBTC",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 4,
        "clientOrderId": "oD7aesZqjEGlZrbtRpy5zB"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 5,
        "clientOrderId": "Jr1h6xirOxgeJOUuYQS7V3"
      }
    ]
  },
  {
    "orderListId": 28,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "hG7hFNxJV6cZy3Ze4AUT4d",
    "transactionTime": 1565245913407,
    "symbol": "LTCBTC",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 2,
        "clientOrderId": "j6lFOfbmFMRjTYA7rRJ0LP"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 3,
        "clientOrderId": "z0KCjOdditiLS5ekAFtK81"
      }
    ]
  }
]

GET /api/v3/allOrderList (HMAC SHA256)

Weight: 10

Use this endpoint to retrieve all OCO orders based on provided optional parameters. Please note the maximum limit is 1,000 orders.

Parameters

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

Data Source: Database

Get Open OCO Orders

Example


# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/api/v3/openOrderList?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/api/v3/openOrderList"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "orderListId": 31,
    "contingencyType": "OCO",
    "listStatusType": "EXEC_STARTED",
    "listOrderStatus": "EXECUTING",
    "listClientOrderId": "wuB13fmulKj3YjdqWEcsnp",
    "transactionTime": 1565246080644,
    "symbol": "1565246079109",
    "orders": [
      {
        "symbol": "LTCBTC",
        "orderId": 4,
        "clientOrderId": "r3EH2N76dHfLoSZWIUw1bT"
      },
      {
        "symbol": "LTCBTC",
        "orderId": 5,
        "clientOrderId": "Cv1SnyPD3qhqpbjpYEHbd2"
      }
    ]
  }
]

GET /api/v3/openOrderList (HMAC SHA256)

Use this endpoint to query open OCO orders.

Weight: 3

Parameters

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

Data Source: Database

Cancel OCO Order

Example


# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
orderListId=<orderListId>

api_url="https://api.binance.us"

signature=`echo -n "symbol=$symbol&orderListId=$orderListId&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "DELETE" "$api_url/api/v3/orderList?symbol=$symbol&orderListId=$orderListId&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
symbol=<symbol>
orderListId=<orderListId>

uri_path = "/api/v3/orderList"
data = {
  "symbol": symbol,
  "orderListId": orderListId,
  "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "ALL_DONE",
  "listOrderStatus": "ALL_DONE",
  "listClientOrderId": "C3wyj4WVEktd7u9aVBRXcN",
  "transactionTime": 1574040868128,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "pO9ufTiFGg3nw2fOdgeOXa"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "TXOvglzXuaubXAaENpaRCB"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "origClientOrderId": "pO9ufTiFGg3nw2fOdgeOXa",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "unfWT8ig8i0uj6lPuYLez6",
      "price": "1.00000000",
      "origQty": "10.00000000",
      "executedQty": "0.00000000",
      "cummulativeQuoteQty": "0.00000000",
      "status": "CANCELED",
      "timeInForce": "GTC",
      "type": "STOP_LOSS_LIMIT",
      "side": "SELL",
      "stopPrice": "1.00000000",
      "selfTradePreventionMode": "NONE"
    },
    {
      "symbol": "LTCBTC",
      "origClientOrderId": "TXOvglzXuaubXAaENpaRCB",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "unfWT8ig8i0uj6lPuYLez6",
      "price": "3.00000000",
      "origQty": "10.00000000",
      "executedQty": "0.00000000",
      "cummulativeQuoteQty": "0.00000000",
      "status": "CANCELED",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "SELL",
      "selfTradePreventionMode": "NONE"
    }
  ]
}

DELETE /api/v3/orderList (HMAC SHA256)

Weight: 1

Use this endpoint to cancel an entire order list.

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 LONG NO The value cannot be greater than 60000
timestamp LONG YES

Additional notes:

Data Source: Matching Engine

OTC Endpoints

Get Supported Coin Pairs

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/otc/coinPairs?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    params={
        **data,
        "signature": signature,
        }           
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/otc/coinPairs"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "fromCoin": "BTC",
        "toCoin": "USDT",
        "fromCoinMinAmount": 0.1,
        "fromCoinMaxAmount": 100,
        "toCoinMinAmount": 1000,
        "toCoinMaxAmount": 500000
    },
    {
        "fromCoin": "USDT",
        "toCoin": "BNB",
        "fromCoinMinAmount": 2000,
        "fromCoinMaxAmount": 600000,
        "toCoinMinAmount": 10,
        "toCoinMaxAmount": 4000
    }
]

GET /sapi/v1/otc/coinPairs (HMAC SHA256)

Use this endpoint to get a list of supported coin pairs.

Weight: 1

Parameters:

Name Type Mandatory Description
fromCoin STRING NO From coin name, e.g. BTC, SHIB
toCoin STRING NO To coin name, e.g. USDT, KSHIB
timestamp LONG YES

Data Source: Database

Request for Quote

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
from_coin=BTC
to_coin=USDT
request_coin=BTC
request_amount=1

api_url="https://api.binance.us"

signature=`echo -n "fromCoin=$from_coin&toCoin=$to_coin&requestCoin=$request_coin&requestAmount=$request_amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/otc/quotes" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    --data-urlencode "fromCoin=$from_coin&toCoin=$to_coin&requestCoin=$request_coin&requestAmount=$request_amount&timestamp=$timestamp&signature=$signature"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    payload={
        **data,
        "signature": signature,
        }           
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/otc/quotes"
data = {
    "fromCoin": "BTC",
    "toCoin": "USDT",
    "requestCoin": "BTC",
    "requestAmount": 1,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "symbol": "BTCUSDT", 
    "ratio": 50550.26,
    "inverseRatio": 0.00001978,
    "validTimestamp": 1641806714,
    "toAmount": 50550.26,
    "fromAmount": 1
}

POST /sapi/v1/otc/quotes (HMAC SHA256)

Use this endpoint to request a quote for a from-to coin pair.

Weight: 1

Parameters:

Name Type Mandatory Description
fromCoin STRING YES From coin name, e.g. SHIB
toCoin STRING YES To coin name, e.g. KSHIB
requestCoin STRING YES Request coin name, e.g. SHIB
requestAmount DECIMAL YES Amount of request coin, e.g. 50000
timestamp LONG YES

Data Source: Database

Place OTC Trade Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
quote_id=<quoteId>

api_url="https://api.binance.us"

signature=`echo -n "quoteId=$quote_id&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/otc/orders" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    --data-urlencode "quoteId=$quote_id&timestamp=$timestamp&signature=$signature"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    payload={
        **data,
        "signature": signature,
        }           
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/otc/orders"
data = {
    "quoteId": "4e5446f2cc6f44ab86ab02abf19a2fd2",
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "orderId": "10002349",
    "createTime": 1641906714,
    "orderStatus": "PROCESS"  // Status: PROCESS / ACCEPT_SUCCESS / SUCCESS / FAIL
}

POST /sapi/v1/otc/orders (HMAC SHA256)

Use this endpoint to place an order using an acquired quote.

Weight: 1

Parameters:

Name Type Mandatory Description
quoteId STRING YES Quote ID, e.g. 15848701022
timestamp LONG YES

Data Source: Database

Get OTC Trade Order

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
orderid=<your_order_id>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/otc/orders/$orderid?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    params={
        **data,
        "signature": signature,
        }           
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/otc/orders/10002349"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "quoteId": "4e5446f2cc6f44ab86ab02abf19a2fd2",
    "orderId": "10002349", 
    "orderStatus": "SUCCESS",
    "fromCoin": "BTC",
    "fromAmount": 1,
    "toCoin": "USDT",
    "toAmount": 50550.26,
    "ratio": 50550.26,
    "inverseRatio": 0.00001978,
    "createTime": 1641806714
}

GET /sapi/v1/otc/orders/{orderId} (HMAC SHA256)

Use this endpoint to query OTC trade order details.

Weight: 1

Parameters:

Name Type Mandatory Description
orderId STRING YES Order ID, e.g., 10002349
timestamp LONG YES

Data Source: Database

Get All OTC Trade Orders

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/otc/orders?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    params={
        **data,
        "signature": signature,
        }           
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/otc/orders"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "quoteId": "4e5446f2cc6f44ab86ab02abf19a2fd2",
        "orderId": "10002349", 
        "orderStatus": "SUCCESS",
        "fromCoin": "BTC",
        "fromAmount": 1,
        "toCoin": "USDT",
        "toAmount": 50550.26,
        "ratio": 50550.26,
        "inverseRatio": 0.00001978,
        "createTime": 1641806714
    },
    {
        "quoteId": "15848645308",
        "orderId": "10002380", 
        "orderStatus": "PROCESS",
        "fromCoin": "SHIB",
        "fromAmount": 10000,
        "toCoin": "KSHIB",
        "toAmount": 10,
        "ratio": 0.001,
        "inverseRatio": 1000,
        "createTime": 1641916714
    }
]

GET /sapi/v1/otc/orders (HMAC SHA256)

Use this endpoint to query OTC trade orders by condition.

Weight: 1

Parameters:

Name Type Mandatory Description
orderId STRING NO Order ID
fromCoin STRING NO From coin name, e.g., BTC, KSHIB
toCoin STRING NO To coin name, e.g., USDT, SHIB
startTime LONG NO Start timestamp
endTime LONG NO End timestamp
limit INT NO Description: Default: 10; max: 100
timestamp LONG YES

Data Source: Database

Get All OCBS Trade Orders

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/ocbs/orders?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    params={
        **data,
        "signature": signature,
        }           
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/ocbs/orders"
data = {
    "timestamp": int(round(time.time() * 1000)),
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
   "total": 2,
   "dataList": [
      {
        "quoteId": "4e5446f2cc6f44ab86ab02abf19a7654",
        "orderId": "10090821212", 
        "orderStatus": "SUCCESS",
        "fromCoin": "BTC",
        "fromAmount": 1,
        "toCoin": "USD",
        "toAmount": 50550.26,
        "feeCoin": "USD",
        "feeAmount": 0.26,
        "ratio": 50550.26,
        "createTime": 1641806714
      },
      {
        "quoteId": "4e5446f2cc6f44ab86ab02abf19abvd",
        "orderId": "1000238000", 
        "orderStatus": "FAIL",
        "fromCoin": "USD",
        "fromAmount": 1000.5,
        "toCoin": "ETH",
        "toAmount": 0.5,
        "feeCoin": "USD",
        "feeAmount": 0.5,
        "ratio": 2000,
        "createTime": 1641916714
      }
  ]
}

GET /sapi/v1/ocbs/orders (HMAC SHA256)

Use this endpoint to query all OCBS orders by condition.

Weight: 1

Parameters:

Name Type Mandatory Description
orderId STRING NO Order ID
startTime LONG NO Start timestamp
endTime LONG NO End timestamp
limit INT NO default: 10; max: 100
timestamp LONG YES

Data Source: Database

Wallet Endpoints

Asset Fees & Wallet Status

Get Asset Fees & Wallet Status

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/config/getall?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/capital/config/getall"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "coin": "BCH",
        "depositAllEnable": true,
        "withdrawAllEnable": true,
        "name": "BCH",
        "free": "0",
        "locked": "0",
        "freeze": "0",
        "withdrawing": "0",
        "ipoing": "0",
        "ipoable": "0",
        "storage": "0",
        "isLegalMoney": false,
        "trading": true,
        "networkList": [
            {
                "network": "BCH",
                "coin": "BCH",
                "withdrawIntegerMultiple": "0.00000001",
                "isDefault": true,
                "depositEnable": true,
                "withdrawEnable": true,
                "depositDesc": "",
                "withdrawDesc": "",
                "name": "Bitcoin Cash",
                "resetAddressStatus": false,
                "withdrawFee": "0",
                "withdrawMin": "0",
                "withdrawMax": "9999999"
            },
            {
                "network": "BNB",
                "coin": "BCH",
                "withdrawIntegerMultiple": "0.00000001",
                "isDefault": false,
                "depositEnable": true,
                "withdrawEnable": true,
                "depositDesc": "",
                "withdrawDesc": "",
                "name": "BEP222ee",
                "resetAddressStatus": false,
                "addressRegex": "^(bnb1)[0-9a-z]{38}$",
                "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
                "withdrawFee": "0",
                "withdrawMin": "0",
                "withdrawMax": "9999999",
                "minConfirm": 15,
                "unLockConfirm": 3
            },
            {
                "network": "BSC",
                "coin": "BCH",
                "withdrawIntegerMultiple": "0.00000001",
                "isDefault": false,
                "depositEnable": true,
                "withdrawEnable": true,
                "depositDesc": "",
                "withdrawDesc": "",
                "name": "BSC (BEP20)",
                "resetAddressStatus": false,
                "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
                "memoRegex": "",
                "withdrawFee": "0",
                "withdrawMin": "0",
                "withdrawMax": "9999999",
                "minConfirm": 0,
                "unLockConfirm": 0
            }
        ]
    },
    {
    "coin": "PAX",
    "depositAllEnable": true,
    "withdrawAllEnable": true,
    "name": "PAX",
    "free": "0",
    "locked": "0",
    "freeze": "0",
    "withdrawing": "0",
    "ipoing": "0",
    "ipoable": "0",
    "storage": "0",
    "isLegalMoney": false,
    "trading": false,
    "networkList": [
        {
            "network": "BNB",
            "coin": "PAX",
            "withdrawIntegerMultiple": "0",
            "isDefault": false,
            "depositEnable": true,
            "withdrawEnable": true,
            "depositDesc": "",
            "withdrawDesc": "",
            "specialTips": "",
            "name": "BEP222ee",
            "resetAddressStatus": false,
            "addressRegex": "^(bnb1)[0-9a-z]{38}$",
            "memoRegex": "^[0-9A-Za-z\\-_]{1,120}$",
            "withdrawFee": "0",
            "withdrawMin": "0",
            "withdrawMax": "9999999",
            "minConfirm": 15,
            "unLockConfirm": 3
        }
    ]
    }
]

GET /sapi/v1/capital/config/getall (HMAC SHA256)

Use this endpoint to fetch the details of all crypto assets including fees, withdrawal limits, and network status.

Weight: 1

Parameters:

Name Type Mandatory Description
recvWindow LONG NO
timestamp LONG YES

Data Source: Memory

Withdrawals

Withdraw Crypto

Example

#!/bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>
network=<network>
address=<address>
amount=<amount>

api_url="https://api.binance.us"

signature=`echo -n "coin=$coin&network=$network&address=$address&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

payload="coin=$coin&network=$network&address=$address&amount=$amount&timestamp=$timestamp&signature=$signature"

curl -X "POST" "$api_url/sapi/v1/capital/withdraw/apply" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    -d $payload
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>
network=<network>
address=<address>
amount=<amount>

uri_path = "/sapi/v1/capital/withdraw/apply"
data = {
    "coin": coin,
    "network": network,
    "address": address,
    "amount": amount,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

    {"id":"4e7f4f31560041ee880b5386f06d4053"}

POST /sapi/v1/capital/withdraw/apply (HMAC SHA256)

Use this endpoint to submit a crypto withdrawal request.

Weight: 1

Parameters:

Name Type Mandatory Description
coin STRING YES
network STRING YES Specify the withdrawal network (e.g. 'ERC20' or 'BEP20'). Please ensure the address type is correct for the chosen network
withdrawOrderId STRING NO Client ID for withdraw
address STRING YES
addressTag STRING NO Memo: Acts as a secondary address identifier for coins like XRP, XMR etc.
amount DECIMAL YES
recvWindow LONG NO
timestamp LONG YES

Data Source: Memory

Withdraw Fiat (via SEN)

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
paymentAccount=<paymentAccount>
amount=<amount>

api_url="https://api.binance.us"

signature=`echo -n "paymentAccount=$paymentAccount&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/fiatpayment/apply/withdraw" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    --data-urlencode "paymentAccount=$paymentAccount&amount=$amount&timestamp=$timestamp&signature=$signature"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
paymentAccount=<paymentAccount>
amount=<amount>

uri_path = "/sapi/v1/fiatpayment/apply/withdraw"
data = {
    "timestamp": int(round(time.time() * 1000)),
    "paymentAccount": paymentAccount,
    "amount": amount
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "orderId": "6c2ff984890145fdac2b7160299062f0"
}

POST /sapi/v1/fiatpayment/apply/withdraw (HMAC SHA256)

Use this endpoint to submit a USD withdraw request via Silvergate Exchange Network (SEN).

Weight: 1

Parameters:

Name Type Mandatory Description
paymentChannel STRING NO default value="SILVERGATE"
paymentMethod STRING NO default value="SEN"
paymentAccount STRING YES The account to which the user wants to withdraw funds
fiatCurrency STRING NO default value="USD"
amount DECIMAL YES The amount
recvWindow LONG NO
timestamp LONG YES

Get Crypto Withdrawal History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/withdraw/history?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/capital/withdraw/history"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "id": "4e7f4f31560041ee880b5386f06d4053",
    "amount": "0.9",
    "transactionFee": "0.1",
    "coin": "BNB",
    "status": 2,
    "address": "0xd709f9d0bbc6b0e746a13142dfe353086edf87c2",
    "applyTime": "2022-02-18 03:36:04",
    "network": "BSC",
    "transferType": 0
  }
]

GET /sapi/v1/capital/withdraw/history (HMAC SHA256)

Use this endpoint to fetch your crypto withdrawal history.

Weight: 1

Parameters:

Name Type Mandatory Description
coin STRING YES
withdrawOrderId STRING NO Client ID for withdraw
status INT NO 0: email sent, 1: canceled, 2: awaiting approval, 3: rejected, 4: processing, 5: failure, 6: completed
startTime LONG NO Default: 90 days from current timestamp
endTime LONG NO Default: present timestamp
offset INT NO Default: 0
limit INT NO Default: 1000, max: 1000
recvWindow LONG NO
timestamp LONG YES

Data Source: Database

Get Fiat Withdrawal History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/fiatpayment/query/withdraw/history?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/fiatpayment/query/withdraw/history"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "assetLogRecordList": [
        {
            "orderId":"6c2ff984890145fdac2b7160299062f0",
            "paymentAccount": "4a992541-c12d-4cca-bbd6-df637f801526",
            "paymentChannel": "PRIMETRUST",
            "paymentMethod": "WIRE_INTERNATIONAL",
            "orderStatus": "Processing",
            "amount": "65",
        "transactionFee": "20",
            "platformFee": "0"
        }
    ]
}

GET /sapi/v1/fiatpayment/query/withdraw/history (HMAC SHA256)

Use this endpoint to fetch your fiat (USD) withdrawal history.

Weight: 1

Parameters:

Name Type Mandatory Description
fiatCurrency STRING NO
orderId STRING NO
offset INT NO
paymentChannel STRING NO
paymentMethod STRING NO
startTime LONG NO Default to 90 days from current timestamp
endTime LONG NO Default to current timestamp
recvWindow Long NO
timestamp Long YES

Deposits

Get Crypto Deposit Address

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>

api_url="https://api.binance.us"

signature=`echo -n "coin=$coin&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/deposit/address?coin=$coin&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>

uri_path = "/sapi/v1/capital/deposit/address"
data = {
    "coin": coin,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
  "coin": "BNB",
  "address": "0xcf1988d27e402086941284313b632466fdf28a22",
  "tag": "",
  "url": "0xcf1988d27e402086941284313b632466fdf28a22"
}

GET /sapi/v1/capital/deposit/address (HMAC SHA256)

Use this endpoint to fetch a deposit address for a particular crypto asset.

Weight: 1

Parameters:

Name Type Mandatory Description
coin STRING YES
network STRING NO
recvWindow LONG NO
timestamp LONG YES

Get Crypto Deposit History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>

api_url="https://api.binance.us"

signature=`echo -n "coin=$coin&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/deposit/hisrec?coin=$coin&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
coin=<coin>

uri_path = "/sapi/v1/capital/deposit/hisrec"
data = {
    "coin": coin,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
  {
    "amount": "8.73234",
    "coin": "BNB",
    "network": "BSC",
    "status": 1,
    "address": "0xd709f9d0bbc6b0e746a13142dfe353086edf87c2",
    "addressTag": "",
    "txId": "0xa9ebf3f4f60bc18bd6bdf4616ff8ffa14ef93a08fe79cad40519b31ea1044290",
    "insertTime": 1638342348000,
    "transferType": 0,
    "confirmTimes": "0/0"
  }
]

GET /sapi/v1/capital/deposit/hisrec (HMAC SHA256)

Use this endpoint to fetch your crypto deposit history.

Weight: 1

Parameters:

Name Type Mandatory Description
coin STRING YES
status INT NO 0: pending, 6: credited but cannot withdraw, 1: success
startTime LONG NO Default: 90 days from current timestamp
endTime LONG NO Default: present timestamp
offset INT NO Default: 0
limit INT NO Default: 1000, max: 1000
recvWindow LONG NO
timestamp LONG YES

Data Source: Memory

Get Fiat Deposit History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/fiatpayment/query/deposit/history?timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/fiatpayment/query/deposit/history"
data = {
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "assetLogRecordList": [
        {
            "orderId":"a1d377c72de544f2ba881399f5ad36bb",
            "paymentAccount": "4a992541-c12d-4cca-bbd6-df637f801526",
            "paymentChannel": "Silvergate",
            "paymentMethod": "SEN",
            "orderStatus": "Failed",
            "amount": "0.95",
        "transactionFee": "0.05",
            "platformFee": "0"
        }
    ]
}

GET /sapi/v1/fiatpayment/query/deposit/history (HMAC SHA256)

Use this endpoint to fetch your fiat (USD) deposit history.

Weight: 1

Parameters:

Name Type Mandatory Description
fiatCurrency STRING NO
orderId STRING NO
offset INT NO
paymentChannel STRING NO
paymentMethod STRING NO
startTime LONG NO Default to 90 days from current timestamp
endTime LONG NO Default to current timestamp
recvWindow Long NO
timestamp Long YES

Get Sub-account Deposit Address

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

email="ios@mt.com"
coin="BNB"

signature=`echo -n "email=$email&coin=$coin&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/sub-account/deposit/address?email=$email&coin=$coin&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
your_email=<your_your_email>
uri_path = "/sapi/v1/capital/sub-account/deposit/address"
data = {
    "timestamp": int(round(time.time() * 1000)), "email": your_email, "coin": "ETH"
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "coin": "BNB", // coin
    "address": "0xf79b6274f18425441b8f05c0a711d171c0fe119f", // address
    "tag": "", //memo
    "url": "https://etherscan.io/address/0xf79b6274f18425441b8f05c0a711d171c0fe119f" //Blockchain browser address
}

GET /sapi/v1/capital/sub-account/deposit/address (HMAC SHA256)

Use this endpoint to fetch a sub-account’s deposit address.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING YES Sub-account Email
coin STRING YES coin
network STRING NO Network (If empty, returns the default network)

Data Source: Database

Get Sub-account Deposit History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

email="ios@mt.com"

signature=`echo -n "email=$email&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/capital/sub-account/deposit/history?email=$email&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
your_email=<your_your_email>
uri_path = "/sapi/v1/capital/sub-account/deposit/history"
data = {
    "timestamp": int(round(time.time() * 1000)), "email": your_email
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "amount": "9.9749",//deposit amount
        "coin": "BTC", //coin
        "network": "btc", //network
        "status": 4,
        "address": "bc1qxurvdd7tzn09agdvg3j8xpm3f7e978y07wg83s",
        "addressTag": "",
        "txId": "0x1b4b8c8090d15e3c1b0476b1c19118b1f00066e01de567cd7bc5b6e9c100193f",
        "insertTime": 1652942429211,
        "transferType": 0,
        "confirmTimes": "0/0"
    }
]

GET /sapi/v1/capital/sub-account/deposit/history (HMAC SHA256)

Use this endpoint to fetch sub-account deposit history.

Weight: 1

Parameters:

Name Type Mandatory Description
email STRING YES Sub-account Email
coin STRING NO coin
status INT NO 0 (0:pending, 6:credited but cannot withdraw, 1:success)
startTime LONG NO
endTime LONG NO
limit INT NO
offset INT NO default: 0

Data Source: Database

Convert Dust to BNB

Convert Dust to BNB

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

asset=<asset>

signature=`echo -n "asset=$asset&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X POST "$api_url/sapi/v1/asset/dust?asset=$asset&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
    }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
asset = <asset>
uri_path = "/sapi/v1/asset/dust"
data = {
    "timestamp": int(round(time.time() * 1000)),"asset":asset
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
   "totalTransferred": "0.00289855",
   "totalServiceCharge": "0.00005797",
   "transferResult": [
        {
            "tranId": 28822799,
            "fromAsset": "LTC",
            "amount": "0.2",
            "transferredAmount": "0.00289855",
            "serviceChargeAmount": "0.00005797",
            "operateTime": 1659583487273,
            "result": "S"
        }
   ]
}

POST /sapi/v1/asset/dust (HMAC SHA256)

Use this endpoint to convert dust assets to BNB.

Weight(UID): 10

Parameters:

Name Type Mandatory Description
asset ARRAY YES This assets being converted. For example: asset=BTC&asset=ETH

Data Source: Database

Get Convert Dust to BNB History

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

startTime=<startTime>
endTime=<endTime>

api_url="https://api.binance.us"

signature=`echo -n "startTime=$startTime&endTime=$endTime&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X GET "$api_url/sapi/v1/asset/query/dust-logs?startTime=$startTime&endTime=$endTime&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
    }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
startTime=<startTime>
endTime=<endTime>

uri_path = "/sapi/v1/asset/query/dust-logs"
data = {"timestamp": int(round(time.time() * 1000)),"startTime":startTime,"endTime":endTime}
get_account_result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, get_account_result))

Response

{
   "total": 1,
   "userDustConvertHistory": [
        {
            "operateTime": 1659583487000,
            "totalServiceChargeAmount": "0.00005797",
            "totalTransferredAmount": "0.00284058",
            "userAssetDribbletDetails": [
                {
                    "fromAsset": "LTC",
                    "amount": "0.2",
                    "transferredAmount": "0.00284058",
                    "serviceChargeAmount": "0.00005797",
                    "operateTime": 1659583487000,
                    "tranId": 28822799
                }
            ]
        }
   ]
}

GET /sapi/v1/asset/query/dust-logs (HMAC SHA256)

Use this endpoint to get dust to BNB conversion history.

Weight(IP): 1

Parameters:

Name Type Mandatory Description
startTime LONG YES Start time
endTime LONG YES End time

Data Source: Database

Get Assets That Can Be Converted Into BNB

Example

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X GET "$api_url/sapi/v1/asset/query/dust-assets?timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/asset/query/dust-assets"
data = {"timestamp": int(round(time.time() * 1000))}

get_account_result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, get_account_result))

Response

{
    "convertibleAssets":[
        {
            "asset": "BTC",
            "availableBalance": "0.0001",
            "convertedBNB": "0.0028987",
            "usdValueConvertedBNB": "2.0001",
            "conversionFee": "0.00005797",
            "receivedBNB": "0.00284073"
        },
        {
            "asset": "USDT",
            "availableBalance": "14.286",
            "convertedBNB": "0.02029026",
            "usdValueConvertedBNB": "14.00028",
            "conversionFee": "0.00040581",
            "receivedBNB": "0.01988445"
        }
    ],
    "totalConvertedBNB": "0.02318896",
    "usdValueTotalConvertedBNB": "16.00038",
    "totalConversionFee": "0.00046378",
    "totalReceivedBNB": "0.02272518",
    "feeRate": "0.02",
    "withinRestrictedTime": false
}

GET /sapi/v1/asset/query/dust-assets (HMAC SHA256)

Use this endpoint to get your dust assets that can be converted to BNB.

Weight(IP): 1

Parameters: NONE

Data Source: Database

Referral Endpoints

Get Referral Reward History

Example


# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
userBizType=<your userBizType>
page=<page>
rows=<row>

api_url="https://api.binance.us"

signature=`echo -n "userBizType=$userBizType&page=$page&rows=$rows&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/marketing/referral/reward/history?userBizType=$userBizType&page=$page&rows=$rows&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec) 
    params={
        **data,
        "signature": signature,
        }           
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
userBizType=<your userBizType>
page=<page>
rows=<row>

uri_path = "/sapi/v1/marketing/referral/reward/history"
data = {
    "userBizType": userBizType,
    "page": page,
    "rows": rows,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "total": 1,
    "rows": [
        {
            "userId": 350991652,
            "rewardAmount": "8",
            "receiveDateTime": 1651131084091,
            "rewardType": "USD"
        }
    ]
}

GET /sapi/v1/marketing/referral/reward/history (HMAC SHA256)

Use this endpoint to get the user’s referral reward history.

Weight: 1

Parameters:

Name Type Mandatory Description
userBizType INT YES user business type(0: referrer, 1: referee)
page INT YES
rows INT YES min: 1, max: 200
timestamp LONG YES

Data Source: Database

Custodial Solution Endpoints

User Account Data (Custodial)

Get Account Balance

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "GET" "$api_url/sapi/v1/custodian/balance?$parameter_concat&signature=$signature" \
  -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload={
        **data,
        "signature": signature,
      }
   req = requests.get((api_url + uri_path), params=payload, headers=headers)
   return req.text

api_key = <your_api_key>
  secret_key = <your_secret_key>
  rail = <rail>
uri_path = "/sapi/v1/custodian/balance"
  data = {
      "rail": rail,
      "timestamp": int(round(time.time() * 1000))
  }
result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))


Response

{
      "exchangeWalletBalance": [
          {
              "asset": "BNB",
              "free": "0.0083686",
              "locked": "0",
              "lastUpdatedTime": 1662535206000
          }
      ],
      "custodialAcctBalance": [
          {
              "asset": "BTC",
              "free": "9.02933865",
              "locked": "0",
              "lastUpdatedTime": 1658478839000
          },
          {
              "asset": "ETHT",
              "free": "61.00129998",
              "locked": "0",
              "inSettlement": "25.17",
              "lastUpdatedTime": 1663752210000
          }
     ]
  }

GET /sapi/v1/custodian/balance (HMAC SHA256)

Use this endpoint to get balance information for Binance.US exchange wallet and Binance.US custodial sub-account.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
timestamp LONG YES

Data Source: Database

Get Supported Asset List

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/supportedAssetList?rail=$rail&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

uri_path = "/sapi/v1/custodian/supportedAssetList"
data = {
    "rail": rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "transferEligible":[
        {
            "asset": "BTC",
            "precision": 8,
            "network": [
                "BTC"
            ]
        },
        {
            "asset": "ETH",
            "precision": 8,
            "network": [
                "ETH"
            ]
        }
    ],
    "settlementEligible":[
        {
            "asset": "BTC",
            "precision": 8,
            "network": [
                "BTC"
            ]
        },
        {
            "asset": "ETH",
            "precision": 8,
            "network": [
                "ETH"
            ]
        }
    ]
}

GET /sapi/v1/custodian/supportedAssetList (HMAC SHA256)

Use this endpoint to get a list of assets supported with custodial solutions including eligibility for transfer (from custodial partner) and settlement (to custodial partner).

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
timestamp LONG YES Current timestamp.

Data Source: Database

Transfer (Custodial)

Transfer From Exchange Wallet

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
asset=<asset>
amount=<amount>

api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&asset=$asset&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

payload="rail=$rail&asset=$asset&amount=$amount&timestamp=$timestamp&signature=$signature"

curl -X "POST" "$api_url/sapi/v1/custodian/walletTransfer" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    -d $payload
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.post((api_url + uri_path), headers=headers, data=params)

   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
asset=<asset>
amount=<amount>

uri_path = "/sapi/v1/custodian/walletTransfer"
data = {
    "rail": rail,
    "asset": asset,
    "amount": amount,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "asset": "BTC",
    "amount": 1,
    "clientOrderId": "1663752208086",
    "transferId": "2022092709232937542366",
    "status": "SUCCESS",
    "createTime": 1664276400000
}

POST /sapi/v1/custodian/walletTransfer (HMAC SHA256)

Use this endpoint to request an asset transfer from your Binance.US exchange wallet to your Binance.US custodial sub-account.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
asset STRING YES
amount DECIMAL YES
clientOrderId STRING NO Your reference ID for the order, must be unique. Automatically generated if not sent.
timestamp LONG YES Current timestamp.

Data Source: Database

Transfer From Custodian

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
asset=<asset>
amount=<amount>

api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&asset=$asset&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

payload="rail=$rail&asset=$asset&amount=$amount&timestamp=$timestamp&signature=$signature"

curl -X "POST" "$api_url/sapi/v1/custodian/custodianTransfer" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    -d $payload
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.post((api_url + uri_path), headers=headers, data=params)

   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
asset=<asset>
amount=<amount>

uri_path = "/sapi/v1/custodian/custodianTransfer"
data = {
    "rail": rail,
    "asset": asset,
    "amount": amount,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "asset": "BTC",
    "amount": 1,
    "clientOrderId": "1663752208086",
    "transferId": "2022092709232937542366",
    "custodyAccountId": "custodyAccountId",
    "custodyAccountName": "custodyAccountName",
    "status": "Transfer request received ",
    "createTime": 1664276400000
}


POST /sapi/v1/custodian/custodianTransfer (HMAC SHA256)

Use this endpoint to request an asset transfer from a custodial partner account to the Binance.US custodial sub-account.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
asset STRING YES
amount DECIMAL YES
clientOrderId STRING NO Your reference ID for the order, must be unique. Automatically generated if not sent.
timestamp LONG YES Current timestamp.

Data Source: Database

Undo Transfer

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
originTransferId=<originTransferId>


api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&originTransferId=$originTransferId&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

payload="rail=$rail&originTransferId=$originTransferId&timestamp=$timestamp&signature=$signature"

curl -X "POST" "$api_url/sapi/v1/custodian/undoTransfer" \
    -H "X-MBX-APIKEY: $api_key" \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
    -d $payload
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.post((api_url + uri_path), headers=headers, data=params)

   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
originTransferId=<originTransferId>


uri_path = "/sapi/v1/custodian/undoTransfer"
data = {
    "rail": rail,
    "originTransferId": originTransferId,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "transferId": "2022092709232937542366",
    "asset": "BTC",
    "amount": 1
}

POST /sapi/v1/custodian/undoTransfer (HMAC SHA256)

Use this endpoint to undo a previous transfer from your custodial partner.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
originTransferId STRING YES Previous transfer ID.
timestamp LONG YES Current timestamp.

Data Source: Database

Get Exchange Wallet Transfer

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/walletTransferHistory?rail=$rail&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

uri_path = "/sapi/v1/custodian/walletTransferHistory"
data = {
    "rail": rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
   "data": [
       {
            "transferId": "2022092709232937542366",
            "clientOrderId": "1663752208086",
            "asset": "BTC",
            "amount": 1,
            "status": "SUCCESS",
            "createTime": 1664276400000,
            "updateTime": 1664276400000
        }
   ],
   "total": 1
}


GET /sapi/v1/custodian/walletTransferHistory (HMAC SHA256)

Use this endpoint to check a Binance.US exchange wallet transfer status.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
transferId STRING NO
clientOrderId STRING NO
asset STRING NO BTC,etc
startTime LONG NO Default: 90 days from current timestamp
endTime LONG NO Default: current timestamp
page INT NO defaultValue:1
limit INT NO defaultValue:20, max:100
timestamp LONG YES Current timestamp.

Data Source: Database

Get Custodian Transfer

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

api_url="https://api.binance.us"

signature=`echo -n "rail=$rail&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/custodianTransferHistory?rail=$rail&timestamp=$timestamp&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

uri_path = "/sapi/v1/custodian/custodianTransferHistory"
data = {
    "rail": rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))


Response

{
   "data": [
       {
            "transferId": "2022092709232937542366",
            "clientOrderId": "1663752208086",
            "asset": "BTC",
            "amount": 1,
            "status": "SUCCESS",
            "expressTrade": FALSE,
            "createTime": 1664276400000,
            "updateTime": 1664276400000
        }
   ],
   "total": 1
}


GET /sapi/v1/custodian/custodianTransferHistory (HMAC SHA256)

Use this endpoint to check the status of a transfer from a custodial partner account, including ExpressTrade transfer, Custodian transfer and Undo Transfer.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
transferId STRING NO
clientOrderId STRING NO
expressTradeTransfer BOOLEAN NO Default FALSE
asset STRING NO BTC,etc
startTime LONG NO Default: 90 days from current timestamp
endTime LONG NO Default: current timestamp
page INT NO defaultValue:1
limit INT NO defaultValue:20, max:100
timestamp LONG YES Current timestamp.

Data Source: Database

Trade Order (Custodial)

Create New Order (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature
timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>
price=<price>
timeInForce=<timeInForce>
asset=<asset>
allowExpressTrade=<allowExpressTrade>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&symbol=$symbol&side=$side&type=$type&quantity=$quantity&price=$price&timeInForce=$timeInForce&asset=$asset&allowExpressTrade=$allowExpressTrade&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "POST" "$api_url/sapi/v1/custodian/order?$parameter_concat&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
rail=<rail>
symbol=<symbol>
side=<side>
type=<type>
quantity=<quantity>
price=<price>
timeInForce=GTC
asset=<asset>
allowExpressTrade=<allowExpressTrade>

uri_path = "/sapi/v1/custodian/order"
data = {
    "rail":rail,
    "symbol": symbol,
    "side": side,
    "type": type,
    "quantity": quantity,
    "price":price,
    "timeInForce": timeInForce,
    "asset":asset,
    "allowExpressTrade":allowExpressTrade,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
  "symbol": "ETHTUSD",
  "orderId": 70,
  "orderListId": -1,
  "clientOrderId": "7c713b92cce34358b23fcf1fcd9953bc",
  "price": "18",
  "origQty": "1",
  "executedQty": "0",
  "cummulativeQuoteQty": "0",
  "status": "NEW",
  "timeInForce": "GTC",
  "type": "LIMIT",
  "side": "BUY",
  "expressTradeFlag": false
}


POST /sapi/v1/custodian/order (HMAC SHA256)

Use this endpoint to place a new trade order.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD)
side ENUM YES Order side (e.g., BUY, SELL)
type ENUM YES (Order type (e.g., LIMIT, MARKET, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER))
timeInForce ENUM NO
quantity DECIMAL NO
quoteOrderQty DECIMAL NO
price DECIMAL NO Order price
stopPrice DECIMAL NO Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders
icebergQty DECIMAL NO Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order
asset STRING NO Optional. When allowExpressTrade=true, enter the asset you are selling. E.g. If symbol = BTCUSD, and side = BUY, enter “USD”.
allowExpressTrade BOOLEAN NO Default false; if true, when Binance.US Custodial sub-account Balance is smaller than the order amount, full amount will be transferred from custodial partner account.
timestamp LONG YES Current timestamp.

Some additional mandatory parameters based on order type:

Type Additional Mandatory Parameters Additional Information
LIMIT timeInForce, quantity, price
MARKET quantity or quoteOrderQty MARKET orders using the quantity field specifies the amount of the base asset the user wants to buy or sell at the market price. E.g., a MARKET order on BTCUSDT will specify how much BTC the user is buying or selling MARKET orders using quoteOrderQty specify the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty. E.g., Using the symbol BTCUSDT:BUY side, the order will buy as many BTC as quoteOrderQty USDT can. SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT
STOP_LOSS quantity, stopPrice This will execute a MARKET order when the stopPrice is reached
STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice This will execute a LIMIT order when the stopPrice is reached
TAKE_PROFIT quantity, stopPrice This will execute a MARKET order when the stopPrice is reached
TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice This will execute a LIMIT order when the stopPrice is reached
LIMIT_MAKER quantity, price This is a LIMIT order that will be rejected if the order immediately matches and trades as a taker. This is also known as a POST-ONLY order

Data Source: Database

Create New OCO Order (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
symbol=<symbol>
side=<side>
quantity=<quantity>
price=<price>
stopPrice=<stopPrice>
stopLimitPrice=<stopLimitPrice>
stopLimitTimeInForce=<stopLimitTimeInForce>
asset=<asset>
allowExpressTrade=<allowExpressTrade>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&symbol=$symbol&side=$side&quantity=$quantity&price=$price&stopPrice=$stopPrice&stopLimitPrice=$stopLimitPrice&stopLimitTimeInForce=$stopLimitTimeInForce&asset=$asset&allowExpressTrade=$allowExpressTrade&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "POST" "$api_url/sapi/v1/custodian/ocoOrder?$parameter_concat&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"
# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.post((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
rail=<rail>
symbol=<symbol>
side=<side>
quantity=<quantity>
price=<price>
stopPrice=<stopPrice>
stopLimitPrice=<stopLimitPrice>
stopLimitTimeInForce=<stopLimitTimeInForce>
asset=<asset>
allowExpressTrade=<allowExpressTrade>

uri_path = "/sapi/v1/custodian/ocoOrder"
data = {
    "rail":rail,
    "symbol": symbol,
    "side": side,
    "quantity": quantity,
    "price": price,
    "stopPrice": stopPrice,
    "stopLimitPrice": stopLimitPrice,
    "stopLimitTimeInForce": stopLimitTimeInForce,
    "asset":asset,
    "allowExpressTrade":allowExpressTrade,
    "timestamp": int(round(time.time() * 1000))
}
result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "EXEC_STARTED",
  "listOrderStatus": "EXECUTING",
  "listClientOrderId": "JYVpp3F0f5CAG15DhtrqLp",
  "transactionTime": 1563417480525,
  "symbol": "LTCBTC",
  "expressTradeFlag": false,
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "Kk7sqHb9J6mJWTMDVW7Vos",
      "transactTime": 1563417480525,
      "price": "0.000000",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "STOP_LOSS",
      "side": "BUY",
      "stopPrice": "0.960664"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "xTXKaGYd4bluPVp78IVRvl",
      "transactTime": 1563417480525,
      "price": "0.036435",
      "origQty": "0.624363",
      "executedQty": "0.000000",
      "cummulativeQuoteQty": "0.000000",
      "status": "NEW",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "BUY"
    }
  ]
}



POST /sapi/v1/custodian/ocoOrder (HMAC SHA256)

Use this endpoint to place a new OCO(one-cancels-the-other) order.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).e.g.,ANCHORAGE
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD)
side ENUM YES Order side (e.g., BUY, SELL)
quantity DECIMAL YES
limitClientOrderId STRING NO A unique ID for the limit order
price DECIMAL YES
limitIcebergQty DECIMAL NO
stopClientOrderId STRING NO A unique ID for the stop loss/stop loss limit leg
stopPrice DECIMAL YES
stopLimitPrice DECIMAL NO If provided, stopLimitTimeInForce is required
stopIcebergQty DECIMAL NO
stopLimitTimeInForce ENUM NO Valid values are GTC/FOK/IOC
asset STRING NO Optional. When allowExpressTrade=true, enter the asset you are selling. E.g. If symbol = BTCUSD, and side = BUY, enter “USD”.
allowExpressTrade BOOLEAN NO Default false; if true, when Binance.US Custodial sub-account Balance is smaller than the order amount, full amount will be transferred from custodial partner account.
timestamp LONG YES

Other Info: Price Restrictions: SELL: Limit Price > Last Price > Stop Price BUY: Limit Price < Last Price < Stop Price Quantity Restrictions: Both legs must have the same quantity. ICEBERG quantities however do not have to be the same Order Rate Limit OCO counts as 2 orders against the order rate limit.

Data Source: Matching Engine

Get All Open Orders (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "GET" "$api_url/sapi/v1/custodian/openOrders?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
uri_path = "/sapi/v1/custodian/openOrders"
data = {
    "rail":rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response


[
  {
         "symbol": "LTCBTC",
         "orderId": 1,
         "orderListId": -1, //Unless OCO, the value will always be -1
         "clientOrderId": "myOrder1",
         "price": "0.1",
         "origQty": "1.0",
         "executedQty": "0.0",
         "cummulativeQuoteQty": "0.0",
         "status": "NEW",
         "timeInForce": "GTC",
         "type": "LIMIT",
         "side": "BUY",
         "stopPrice": "0.0",
         "icebergQty": "0.0",
         "time": 1499827319559,
         "updateTime": 1499827319559,
         "isWorking": true,
         "origQuoteOrderQty": "0.000000",
         "expressTradeFlag": true
  }
]

GET /sapi/v1/custodian/openOrders (HMAC SHA256)

Use this endpoint to get all open trade orders for a token symbol. Do not access this without a token symbol as this would return all pair data.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING NO Order trading pair (e.g., BTCUSD, ETHUSD).
timestamp LONG YES Current timestamp.

Data Source: Matching Engine

Get Order (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
orderId=<orderId>
symbol=<symbol>

api_url="https://api.binance.us"

parameter_concat="rail=$rail&orderId=$orderId&symbol=$symbol&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/order?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
orderId=<orderId>
symbol=<symbol>

uri_path = "/sapi/v1/custodian/order"
data = {
    "rail": rail,
    "orderId": orderId,
    "symbol": symbol,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
         "symbol": "LTCBTC",
         "orderId": 1,
         "orderListId": -1, //Unless OCO, the value will always be -1
         "clientOrderId": "myOrder1",
         "price": "0.1",
         "origQty": "1.0",
         "executedQty": "0.0",
         "cummulativeQuoteQty": "0.0",
         "status": "NEW",
         "timeInForce": "GTC",
         "type": "LIMIT",
         "side": "BUY",
         "stopPrice": "0.0",
         "icebergQty": "0.0",
         "time": 1499827319559,
         "updateTime": 1499827319559,
         "isWorking": true,
         "origQuoteOrderQty": "0.000000",
         "expressTradeFlag": true
 }


GET /sapi/v1/custodian/order (HMAC SHA256)

Use this endpoint to check a trade order's status.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD).
orderId LONG YES
timestamp LONG YES Current timestamp.

Data Source: Database

Get Order History (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "GET" "$api_url/sapi/v1/custodian/orderHistory?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"


import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
uri_path = "/sapi/v1/custodian/orderHistory"
data = {
    "rail":rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))



Response

[
  {
    "symbol": "1565776717369",
    "orderId": 11,
    "orderListId": -1,
    "clientOrderId": "mhUTILjXKS0BHTaBG0is1p",
    "price": "0.0000",
    "origQty": "5.000000",
    "executedQty": "5.000000",
    "cummulativeQuoteQty": "9.5000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "TAKE_PROFIT",
    "side": "BUY",
    "stopPrice": "2.0000",
    "icebergQty": "0.000000",
    "time": 1565776718390,
    "updateTime": 1565776718779,
    "isWorking": true,
    "origQuoteOrderQty": "0.000000",
    "expressTradeFlag": false
  }
]

GET /sapi/v1/custodian/orderHistory (HMAC SHA256)

Use this endpoint to check an order's status as well as past orders.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING NO Order trading pair (e.g., BTCUSD, ETHUSD).
startTime LONG NO
endTime LONG NO
fromId LONG NO defaultValue:1
limit INT NO defaultValue:200
timestamp LONG YES

If the symbol is not sent, orders for all symbols will be returned in an array.

Data Source: Matching Engine

Get Trade History (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "GET" "$api_url/sapi/v1/custodian/tradeHistory?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"


import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
uri_path = "/sapi/v1/custodian/tradeHistory"
data = {
    "rail":rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "symbol": "BTCUSD",
        "price": "10000",
        "qty": "1",
        "quoteQty": "10000",
        "time": 1662027374093,
        "isBuyer": true,
        "isMaker": false,
        "isBestMatch": true,
        "orderId": 115,
        "orderListId": -1,
        "commission": "0",
        "commissionAsset": "BTC"
    },
    {
        "symbol": "BTCUSD",
        "price": "5000",
        "qty": "0.0001",
        "quoteQty": "0.5",
        "time": 1662029127602,
        "isBuyer": false,
        "isMaker": false,
        "isBestMatch": true,
        "orderId": 111,
        "orderListId": -1,
        "commission": "0",
        "commissionAsset": "USD"
    }
]

GET /sapi/v1/custodian/tradeHistory (HMAC SHA256)

Use this endpoint to get past trade data.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING NO Order trading pair (e.g., BTCUSD, ETHUSD).
orderId LONG NO
startTime LONG NO
endTime LONG NO
fromId LONG NO
limit INT NO defaultValue:200
timestamp LONG YES

Notes: If fromId is set, it will get orders >= than fromId. Otherwise most recent orders are returned.

Data Source: Database

Cancel Order (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature
timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
symbol=<symbol>
orderId=<orderId>
api_url="https://api.binance.us"
parameter_concat="rail=$rail&symbol=$symbol&orderId=$orderId&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "DELETE" "$api_url/sapi/v1/custodian/cancelOrder?$parameter_concat&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
rail=<rail>
symbol=<symbol>
orderId=<orderId>
uri_path = "/sapi/v1/custodian/cancelOrder"
data = {
    "rail":rail,
    "symbol": symbol,
    "orderId":orderId,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

{
   "symbol": "LTCBTC",
   "origClientOrderId": "myOrder1",
   "orderId": 4,
   "orderListId": -1, //Unless part of an OCO, the value will always be -1.
   "clientOrderId": "cancelMyOrder1",
   "price": "2.00000000",
   "origQty": "1.00000000",
   "executedQty": "0.00000000",
   "cummulativeQuoteQty": "0.00000000",
   "status": "CANCELED",
   "timeInForce": "GTC",
   "type": "LIMIT",
   "side": "BUY"
 }


DELETE /sapi/v1/custodian/cancelOrder (HMAC SHA256)

Use this endpoint to cancel an active trade order.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD).
orderId LONG NO Either orderId or origClientOrderId must be sent.
origClientOrderId STRING NO Either orderId or origClientOrderId must be sent.
newClientOrderId STRING NO Used to uniquely identify this cancel. Automatically generated by default
timestamp LONG YES

Data Source: Matching Engine

Cancel Open Orders for Symbol (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature
timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
symbol=<symbol>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&symbol=$symbol&timestamp=$timestamp"
signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "DELETE" "$api_url/sapi/v1/custodian/cancelOrdersBySymbol?$parameter_concat&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
rail=<rail>
symbol=<symbol>
uri_path = "/sapi/v1/custodian/cancelOrdersBySymbol"
data = {
    "rail":rail,
    "symbol": symbol,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

[
  {
    "symbol": "BTCUSDT",
    "origClientOrderId": "KZJijIsAFf5BU5oxkWTAU3",
    "orderId": 0,
    "orderListId": -1,
    "clientOrderId": "8epSIUMvNCknntXcSzWs7H",
    "price": "0.10000000",
    "origQty": "1.00000000",
    "executedQty": "0.00000000",
    "cummulativeQuoteQty": "0.00000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY"
  }
]

DELETE /sapi/v1/custodian/cancelOrdersBySymbol (HMAC SHA256)

Use this endpoint to cancel all active trade orders on a token symbol (this includes OCO orders).

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD).
timestamp LONG YES

Data Source: Matching Engine

Cancel OCO Order (Cust.)

Example

#! /bin/bash
# Get HMAC SHA256 signature
timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
symbol=<symbol>
orderListId=<orderListId>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&symbol=$symbol&orderListId=$orderListId&timestamp=$timestamp"
signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`
curl -X "DELETE" "$api_url/sapi/v1/custodian/cancelOcoOrder?$parameter_concat&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
        }
    req = requests.delete((api_url + uri_path), headers=headers, data=payload)
    return req.text

api_key = <your_api_key>
secret_key = <your_secret_key>
rail=<rail>
symbol=<symbol>
orderListId=<orderListId>
uri_path = "/sapi/v1/custodian/cancelOcoOrder"
data = {
    "rail":rail,
    "symbol": symbol,
    "orderListId":orderListId,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("DELETE {}: {}".format(uri_path, result))

Response

{
  "orderListId": 0,
  "contingencyType": "OCO",
  "listStatusType": "ALL_DONE",
  "listOrderStatus": "ALL_DONE",
  "listClientOrderId": "C3wyj4WVEktd7u9aVBRXcN",
  "transactionTime": 1574040868128,
  "symbol": "LTCBTC",
  "orders": [
    {
      "symbol": "LTCBTC",
      "orderId": 2,
      "clientOrderId": "pO9ufTiFGg3nw2fOdgeOXa"
    },
    {
      "symbol": "LTCBTC",
      "orderId": 3,
      "clientOrderId": "TXOvglzXuaubXAaENpaRCB"
    }
  ],
  "orderReports": [
    {
      "symbol": "LTCBTC",
      "origClientOrderId": "pO9ufTiFGg3nw2fOdgeOXa",
      "orderId": 2,
      "orderListId": 0,
      "clientOrderId": "unfWT8ig8i0uj6lPuYLez6",
      "price": "1.00000000",
      "origQty": "10.00000000",
      "executedQty": "0.00000000",
      "cummulativeQuoteQty": "0.00000000",
      "status": "CANCELED",
      "timeInForce": "GTC",
      "type": "STOP_LOSS_LIMIT",
      "side": "SELL",
      "stopPrice": "1.00000000"
    },
    {
      "symbol": "LTCBTC",
      "origClientOrderId": "TXOvglzXuaubXAaENpaRCB",
      "orderId": 3,
      "orderListId": 0,
      "clientOrderId": "unfWT8ig8i0uj6lPuYLez6",
      "price": "3.00000000",
      "origQty": "10.00000000",
      "executedQty": "0.00000000",
      "cummulativeQuoteQty": "0.00000000",
      "status": "CANCELED",
      "timeInForce": "GTC",
      "type": "LIMIT_MAKER",
      "side": "SELL"
    }
  ]
}

DELETE /sapi/v1/custodian/cancelOcoOrder (HMAC SHA256)

Use this endpoint to cancel an entire order list.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
symbol STRING YES Order trading pair (e.g., BTCUSD, ETHUSD).
orderListId LONG YES
listClientOrderId STRING NO
newClientOrderId STRING NO
timestamp LONG YES

Data Source: Matching Engine

Settlement (Custodial)

Get Settlement Settings

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/settlementSetting?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

uri_path = "/sapi/v1/custodian/settlementSetting"
data = {
    "rail": rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "settlementActive": true,
    "frequencyInHours": 24,
    "nextTriggerTime": 1646524800000
}



GET /sapi/v1/custodian/settlementSetting (HMAC SHA256)

Use this endpoint to get current settlement settings (status, schedule and next trigger time).

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
timestamp LONG YES Current timestamp.

Data Source: Database

Get Settlement History

Example

#! /bin/bash
# Get HMAC SHA256 signature

timestamp=`date +%s000`
api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>
api_url="https://api.binance.us"

parameter_concat="rail=$rail&timestamp=$timestamp"

signature=`echo -n $parameter_concat | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/custodian/settlementHistory?$parameter_concat&signature=$signature" \
     -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    params={
        **data,
        "signature": signature,
        }
    req = requests.get((api_url + uri_path), params=params, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
rail=<rail>

uri_path = "/sapi/v1/custodian/settlementHistory"
data = {
    "rail": rail,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "records": [
        {
            "status": "PROCESS",
            "triggerTime": 1660074030009,
            "settlementId": "1a22baf2329845b997eff2bc9a700504",
            "settlementAssets": [
                {
                    "asset": "USDC_T",
                    "settleTo": "0xc80e62a4Bb86c42D1a0Cda3dCBcCb26830D92F2B",
                    "network": "ETH",
                    "amount": "10"
                }
            ]
        },
        {
            "status": "FAILURE",
            "triggerTime": 1659081889724,
            "settlementId": "d9e69bb7386f4ebaa1689559b549ef25",
            "settlementAssets": []
        },
        {
            "status": "FAILURE",
            "triggerTime": 1659079319905,
            "settlementId": "58ca799c596f43a792e8add27dc42d56",
            "settlementAssets": []
        },
        {
            "status": "FAILURE",
            "triggerTime": 1658981047109,
            "settlementId": "3ab30503bf6d43bc8ea8112f6f6b2c91",
            "settlementAssets": []
        }
    ],
    "total": 4
}


GET /sapi/v1/custodian/settlementHistory (HMAC SHA256)

Use this endpoint to check your settlement history.

Weight: 1

Parameters:

Name Type Mandatory Description
rail STRING YES Custodial partner (all uppercase).
startTime LONG NO
endTime LONG NO
limit INT NO defaultValue:5, max:100
page INT NO defaultValue:1

Data Source: Database

Staking Endpoints

Get Staking Asset Information

Example


timestamp=`date +%s000`

api_key=<your_api_key>
stakingAsset=<stakingAsset>
api_url="https://api.binance.us"
secret_key=<your_secret_key>

signature=`echo -n "stakingAsset=$stakingAsset&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/staking/asset?stakingAsset=$stakingAsset&timestamp=$timestamp&signature=$signature" \
-H "X-MBX-APIKEY: $api_key" \
-H "Content-Type:application/json"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a GET request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload = {
       **data,
       "signature":signature,
   }
   req = requests.post((api_url + uri_path), data=payload, headers=headers)
   return req.text

api_url="https://api.binance.us"
uri_path = "/sapi/v1/staking/asset"
data = {
"stakingAsset":$stakingAsset,
"timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "stakingAsset": "BNB",  // Asset is being staked
        "rewardAsset": "BNB",  // Asset received as staking reward
        "apr": "0.0517",  // Annualized rate of return without rewards restaked
        "apy": "0.04",  // Annualized rate of return with rewards restaked
        "unstakingPeriod": 168,  // Amount of time to unstake asset in hours
        "minStakingLimit": "0.01", // Minimum amount allowed for staking
        "maxStakingLimit": "10000", // Maximum amount allowed for staking
        "autoRestake": true // Are rewards for this asset automatically restaked
    }
]


GET sapi/v1/staking/asset (HMAC SHA256)

Use this endpoint to get staking information for a supported asset (or assets)

Weight: 1

Parameters:

Name Type Mandatory Description
stakingAsset String NO Asset symbol (e.g. BNB). If empty, returns all staking assets

Data Source: Database

Stake Asset

Example


timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
stakingAsset=<your_asset>
amount=<your_amount>
autoRestake=<your_autoRestake>
api_url="https://api.binance.us"

signature=`echo -n "stakingAsset=$stakingAsset&amount=$amount&autoRestake=$autoRestake&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/staking/stake?userId=$userId&asset=$asset&amount=$amount&autoRestake=$autoRestake&timestamp=$timestamp&signature=$signature" \
-H "X-MBX-APIKEY: $api_key" \
-H "Content-Type:application/x-www-form-urlencoded;charset=utf-8"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload = {
       **data,
       "signature":signature,
   }
   req = requests.post((api_url + uri_path), data=payload, headers=headers)
   return req.text

api_url="https://api.binance.us"
uri_path = "/sapi/v1/staking/stake"
data = {
"stakingAsset":"$stakingAsset",
"amount":$amount,
"autoRestake":$autoRestake,
"timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
   "code": "000000",
   "message": "success",
   "data":
       {
           "result": "SUCCESS",
           "purchaseRecordId": "111"
       },
   "success": true
}

POST sapi/v1/staking/stake (HMAC SHA256)

Use this endpoint to stake a supported asset.

Weight: 1

Parameters:

Name Type Mandatory Description
stakingAsset STRING YES Asset symbol (e.g. BNB)
amount DECIMAL YES Staking amount
autoRestake BOOLEAN NO If need auto restaking - default: true

Data Source: Database

Unstake Asset

Example


timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>
stakingAsset=<your_asset>
amount=<your_amount>

api_url="https://api.binance.us"

signature=`echo -n "stakingAsset=$stakingAsset&amount=$amount&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "POST" "$api_url/sapi/v1/staking/unstake?stakingAsset=$stakingAsset&amount=$amount&timestamp=$timestamp&signature=$signature" \
-H "X-MBX-APIKEY: $api_key" \
-H "Content-Type:application/x-www-form-urlencoded;charset=utf-8"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers={}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload = {
       **data,
       "signature": signature,
   }
   req = requests.post((api_url + uri_path), data=payload, headers=headers)
   return req.text

 api_url="https://api.binance.us"
uri_path = "/sapi/v1/staking/unstake"
data = {
"stakingAsset":$stakingAsset,
"amount":$amount,
"timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("POST {}: {}".format(uri_path, result))

Response

{
    "code": "000000",
    "message": "success",
    "data":
        {
            "result": "SUCCESS"
        },
    "success": true
}

POST sapi/v1/staking/unstake (HMAC SHA256)

Use this endpoint to unstake a staked asset.

Weight: 1

Parameters:

Name Type Mandatory Description
stakingAsset STRING YES Asset symbol (e.g. BNB)
amount DECIMAL YES Unstaking amount

Data Source: Database

Get Staking Balance

Example


timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

asset=<asset>

signature=`echo -n "asset=$asset&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/staking/stakingBalance?asset=$asset&timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

# get binanceus signature
def get_binanceus_signature(data, secret):
    postdata = urllib.parse.urlencode(data)
    message = postdata.encode()
    byte_key = bytes(secret, 'UTF-8')
    mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
    return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
    headers = {}
    headers['X-MBX-APIKEY'] = api_key
    signature = get_binanceus_signature(data, api_sec)
    payload={
        **data,
        "signature": signature,
    }
    req = requests.get((api_url + uri_path), params=payload, headers=headers)
    return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>
api_url="https://api.binance.us";

asset=<asset>
uri_path = "/sapi/v1/staking/stakingBalance"
data = {
    "asset":asset,
    "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
    "code": "000000",
    "message": "success",
    "data": [
        {
            "asset": "BNB",
            "stakingAmount": "3882.50133916",
            "rewardAsset": "BNB",
            "apr": "0.0517",
            "apy": "0.0869",
            "autoRestake": true
        }
    ],
    "status": ["holding"],
    "success": true
}

GET /sapi/v1/staking/stakingBalance (HMAC SHA256)

Use this endpoint to get the staking balance for an asset(or assets).

Weight: 1

Parameters:

Name Type Mandatory Description
asset String NO Staked asset. If empty, returns all assets with balances.

Data Source: Database

Get Staking History

Example


timestamp=`date +%s000`

api_key=<your_api_key>
asset=<asset>
startTime=<startTime>
endTime=<endTime>
Page=<page>
limit=<limit>
api_url="https://api.binance.us"

signature=`echo -n "asset=$asset&startTime=$startTime&endTime=$endTime&page=$page&limit=<limit>&timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/staking/history?asset=$asset&startTime=$startTime&endTime=$endTime&page=$page&limit=<limit>&timestamp=$timestamp&signature=$signature" \
-H "X-MBX-APIKEY: $api_key" \
-H "Content-Type:application/json"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a GET request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   payload = {
       **data,
       "signature":signature,
   }
   req = requests.post((api_url + uri_path), data=payload, headers=headers)
   return req.text

api_url="https://api.binance.us"
uri_path = "/sapi/v1/staking/history"
data = {
"asset":$asset,
startTime:$startTime,
endTime:$endTime,
page:$page,
limit:$limit,
"timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

[
    {
        "asset": "ETH",
        "amount": "2500", // amount of the transaction
        "type": "staked", //transaction type
        "initiatedTime": 1663096490748, // transaction initiation time
        "status": "SUCCESS" //// status of the transaction
    },
    {
        "asset": "ETH",
        "amount": "1",
        "type": "staked",
        "initiatedTime": 1665462088011,
        "status": "SUCCESS"
    }
]


GET sapi/v1/staking/history (HMAC SHA256)

Use this endpoint to get the staking history of an asset (or assets) within a given time range.

Weight: 1

Parameters:

Name Type Mandatory Description
asset STRING NO Asset symbol (e.g. BNB). If empty, returns all assets with history
startTime LONG NO UNIX Timestamp
endTime LONG NO UNIX Timestamp
page INT NO Page number - default: 1
limit INT NO Default value: 500 (each page contains at most 500 records)

Data Source: Database

Get Staking Rewards History

Example

# Get HMAC SHA256 signature

timestamp=`date +%s000`

api_key=<your_api_key>
secret_key=<your_secret_key>

api_url="https://api.binance.us"

signature=`echo -n "timestamp=$timestamp" | openssl dgst -sha256 -hmac $secret_key`

curl -X "GET" "$api_url/sapi/v1/staking/stakingRewardsHistory?timestamp=$timestamp&signature=$signature" \
    -H "X-MBX-APIKEY: $api_key"
import urllib.parse
import hashlib
import hmac
import base64
import requests
import time

api_url = "https://api.binance.us"

# get binanceus signature
def get_binanceus_signature(data, secret):
   postdata = urllib.parse.urlencode(data)
   message = postdata.encode()
   byte_key = bytes(secret, 'UTF-8')
   mac = hmac.new(byte_key, message, hashlib.sha256).hexdigest()
   return mac

# Attaches auth headers and returns results of a POST request
def binanceus_request(uri_path, data, api_key, api_sec):
   headers = {}
   headers['X-MBX-APIKEY'] = api_key
   signature = get_binanceus_signature(data, api_sec)
   params={
       **data,
       "signature": signature,
       }
   req = requests.get((api_url + uri_path), params=params, headers=headers)
   return req.text

api_key=<your_api_key>
secret_key=<your_secret_key>

uri_path = "/sapi/v1/staking/stakingRewardsHistory"
data = {
   "asset": "BNB",
   "startTime": 1658475133000,
   "endTime": 1658475133593,
   "timestamp": int(round(time.time() * 1000))
}

result = binanceus_request(uri_path, data, api_key, secret_key)
print("GET {}: {}".format(uri_path, result))

Response

{
   "code": "000000",
   "message": "success",
   "data": [
       {
           "asset": "BNB",
           "amount": "0.03371769",
           "usdValue": "20.23",
           "time": 1658475133009,
           "tranId": 3123201,
           "autoRestaked": false
       }
   ],
   "total": 1,
   "success": true
}

GET /sapi/v1/staking/stakingRewardsHistory (HMAC SHA256)

Use this endpoint to get the staking rewards history for an asset(or assets) within a given time range.

Weight: 1

Parameters:

Name Type Mandatory Description
asset String NO Staked asset. If empty, returns all assets with balances.
startTime LONG NO Start time
endTime LONG NO End time
page INTEGER NO The transfer history batch number(each batch contains at most 500 transfer history records)
limit INTEGER NO Default value: 500

Data Source: Database

Filters

Filters define trading rules for a symbol or an exchange.

Filters come in two forms: symbol filters and exchange filters.

Symbol Filters

Price Filter

ExchangeInfo format:

{
  "filterType": "PRICE_FILTER",
  "minPrice": "0.00000100",
  "maxPrice": "100000.00000000",
  "tickSize": "0.00000100"
}

The PRICE_FILTER defines the price rules for a symbol. There are three parts:

Any of the above variables can be set to 0, which disables that rule in the price filter. In order to pass the price filter, the following must be true for price/stopPrice of the enabled rules:

Percent Price Filter

ExchangeInfo format:

{
  "filterType": "PERCENT_PRICE",
  "multiplierUp": "1.3000",
  "multiplierDown": "0.7000",
  "avgPriceMins": 5
}

The PERCENT_PRICE filter defines valid range for a price based on the average of the previous trades. avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.

In order to pass the percent price, the following must be true for price: