GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing www.okcoin.com (truncated) — Okcoin Developer Documentation | Okcoin Official Website | Okcoin

NAV
    • Overview
      • V5 API Key Creation
      • Production Trading Services
      • Transaction timeouts
        • REST
        • WebSocket
    • REST API
      • Authentication
        • Generating an APIKey
        • Making Requests
        • Signature
      • Trade
        • Place order
        • Place multiple orders
        • Cancel order
        • Cancel multiple orders
        • Amend order
        • Amend multiple orders
        • Get order details
        • Get order List
        • Get order history (last 7 days)
        • Get order history (last 3 months)
        • Get transaction details (last 3 days)
        • Get transaction details (last 3 months)
        • Place algo order
        • Cancel algo order
        • Cancel advance algo order
        • Get algo order list
        • Get algo order history
      • Funding
        • Get currencies
        • Get balance
        • Get account asset valuation
        • Funds transfer
        • Get funds transfer state
        • Asset bills details
        • Lightning deposits
        • Get deposit address
        • Get deposit history
        • Withdrawal
        • Lightning withdrawals
        • Cancel withdrawal
        • Get withdrawal history
      • Account
        • Get balance
        • Get bills details (last 7 days)
        • Get bills details (last 3 months)
        • Get account configuration
        • Get maximum buy/sell amount or open amount
        • Get maximum available tradable amount
        • Get fee rates
        • Get maximum withdrawals
      • OTC-Desk RFQ
        • Available Pairs
        • Request Quote
        • Place Order
        • Order Details
        • Order History
      • Fiat
        • Deposit
        • Cancel deposit
        • Get deposit history
        • Withdrawal
        • Cancel withdrawal
        • Get withdrawal history
        • Get channel info
      • SubAccount
        • View sub-account list
        • Query the APIKey of a sub-account
        • Get sub-account trading balance
        • Get sub-account funding balance
        • History of sub-account transfer
        • Master accounts manage the transfers between sub-accounts
      • Market data
        • Get tickers
        • Get ticker
        • Get order book
        • Get candlesticks
        • Get candlesticks history
        • Get trades
        • Get trades history
        • Get 24H total volume
        • Get oracle
        • Get exchange rate
      • Public data
        • Get instruments
        • Get system time
      • Status
    • WebSocket API
      • Overview
      • Connect
      • Login
      • Subscribe
      • Unsubscribe
      • Trade
        • Place order
        • Place multiple orders
        • Cancel order
        • Cancel multiple orders
        • Amend order
        • Amend multiple orders
      • Private channel
        • Account channel
        • Order channel
        • Algo orders channel
        • Advance algo orders channel
      • Public channel
        • Instruments channel
        • Tickers channel
        • Candlesticks channel
        • Trades channel
        • Order book channel
        • Status channel
    • Error Code
      • REST
        • Public
        • Spot
        • Funding
        • Account
      • WebSocket
        • Public

    Overview

    Welcome to our V5 API documentation. Okcoin provides REST and WebSocket APIs to suit your trading needs.
    The V5 API is only applicable to the Unified account.

    V5 API Key Creation

    Please refer to my api page regarding V5 API Key creation.

    Production Trading Services

    The Production Trading URL:

    • REST: https://www.okcoin.com/
    • Public WebSocket: wss://real.okcoin.com:8443/ws/v5/public
    • Private WebSocket: wss://real.okcoin.com:8443/ws/v5/private

    Transaction timeouts

    Orders may not be processed in time due to network delay or busy Okcoin servers. You can configure the expiry time of the request using expTime if you want the order request to be discarded after a specific time.

    If expTime is specified in the requests for Place (multiple) orders or Amend (multiple) orders, the request will not be processed if the current system time of the server is after the expTime.

    You should synchronize with our system time. Use Get system time to obtain the current system time.

    REST

    Set the following parameters in the request header

    Parameter Type Required Description
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085

    The following endpoints are supported:

    • Place order
    • Place multiple orders
    • Amend order
    • Amend multiple orders

    Request Example

    curl -X 'POST' \
      'https://www.okcoin.com/api/v5/trade/order' \
      -H 'accept: application/json' \
      -H 'Content-Type: application/json' \
      -H 'OK-ACCESS-KEY: *****' \
      -H 'OK-ACCESS-SIGN: *****'' \
      -H 'OK-ACCESS-TIMESTAMP: *****'' \
      -H 'OK-ACCESS-PASSPHRASE: *****'' \
      -H 'expTime: 1597026383085' \   // request effective deadline
      -d '{
      "instId": "BTC-USDT",
      "tdMode": "cash",
      "side": "buy",
      "ordType": "limit",
      "px": "1000",
      "sz": "0.01"
    }'
    

    WebSocket

    The following parameters are set in the request

    Parameter Type Required Description
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085

    The following endpoints are supported:

    • Place order
    • Place multiple orders
    • Amend order
    • Amend multiple orders

    Request Example

    {
        "id": "1512",
        "op": "order",
        "expTime":"1597026383085",  // request effective deadline
        "args": [{
            "side": "buy",
            "instId": "BTC-USDT",
            "tdMode": "isolated",
            "ordType": "market",
            "sz": "100"
        }]
    }
    

    REST API

    Authentication

    Generating an APIKey

    Create an APIKey on the website before signing any requests. After creating an APIKey, keep the following information safe:

    • APIKey
    • SecretKey
    • Passphrase

    The system returns randomly-generated APIKeys and SecretKeys. You will need to provide the Passphrase to access the API. We store the salted hash of your Passphrase for authentication. We cannot recover the Passphrase if you have lost it. You will need to create a new set of APIKey.

    Each APIKey can be linked with up to 20 IP addresses. API keys with trading and withdrawal permissions that are not bound to IPs will expire after 14 days of inactivity.

    Making Requests

    All private REST requests must contain the following headers:

    • OK-ACCESS-KEY The APIKey as a String.

    • OK-ACCESS-SIGN The Base64-encoded signature (see Signing Messages subsection for details).

    • OK-ACCESS-TIMESTAMP The UTC timestamp of your request .e.g : 2020-12-08T09:08:57.715Z

    • OK-ACCESS-PASSPHRASE The passphrase you specified when creating the APIKey.

    Request bodies should have content type application/json and be in valid JSON format.

    Signature

    Signing Messages

    The OK-ACCESS-SIGN header is generated as follows:

    • Create a prehash string of timestamp + method + requestPath + body (where + represents String concatenation).
    • Prepare the SecretKey.
    • Sign the prehash string with the SecretKey using the HMAC SHA256.
    • Encode the signature in the Base64 format.

    Example: sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp + 'GET' + '/api/v5/account/balance?ccy=BTC', SecretKey))

    The timestamp value is the same as the OK-ACCESS-TIMESTAMP header with millisecond ISO format, e.g. 2020-12-08T09:08:57.715Z.

    The request method should be in UPPERCASE: e.g. GET and POST.

    The requestPath is the path of requesting an endpoint.

    Example: /api/v5/account/balance

    The body refers to the String of the request body. It can be omitted if there is no request body (frequently the case for GET requests).

    Example: {"instId":"BTC-USDT","lever":"5","mgnMode":"isolated"}

    `GET` request parameters are counted as requestpath, not body

    The SecretKey is generated when you create an APIKey.

    Example: 22582BD0CFF14C41EDBF1AB98506286D

    Trade

    All Trade API endpoints require authentication.

    Place order

    You can place an order only if you have sufficient funds.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/order

    Request Example

     place order for SPOT
     POST /api/v5/trade/order
     body
     {
        "instId":"BTC-USD",
        "tdMode":"cash",
        "clOrdId":"b15",
        "side":"buy",
        "ordType":"limit",
        "px":"2.15",
        "sz":"2"
    }
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    tdMode String Yes Trade mode
    Margin mode cross isolated
    Non-Margin mode cash
    clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    tag String No Order tag
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
    side String Yes Order side, buy sell
    ordType String Yes Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    sz String Yes Quantity to buy or sell
    px String Conditional Order price. Only applicable to limit,post_only,fok,ioc order.
    tgtCcy String No Whether the target currency uses the quote or base currency.
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    banAmend Boolean No Whether to disallow the system from amending the size of the SPOT Market Order.
    Valid options: true or false. The default value is false.
    If true, system will not amend and reject the market order if user does not have sufficient funds.
    Only applicable to SPOT Market Orders

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "312269865356374016",
          "tag": "",
          "sCode": "0",
          "sMsg": ""
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.
    clOrdId
    clOrdId is a user-defined unique ID used to identify the order. It will be included in the response parameters if you have specified during order submission, and can be used as a request parameter to the endpoints to query, cancel and amend orders.
    clOrdId must be unique among the clOrdIds of all pending orders.
    ordType
    Order type. When creating a new order, you must specify the order type. The order type you specify will affect: 1) what order parameters are required, and 2) how the matching system executes your order. The following are valid order types:
    limit: Limit order, which requires specified sz and px.
    market: Market order. For SPOT, market order will be filled with market price (by swiping opposite order book).
    post_only: Post-only order, which the order can only provide liquidity to the market and be a maker. If the order would have executed on placement, it will be canceled instead.
    fok: Fill or kill order. If the order cannot be fully filled, the order will be canceled. The order would not be partially filled.
    ioc: Immediate or cancel order. Immediately execute the transaction at the order price, cancel the remaining unfilled quantity of the order, and the order quantity will not be displayed in the order book.
    sz
    Quantity to buy or sell.
    For SPOT Buy and Sell Limit Orders, it refers to the quantity in base currency.
    For SPOT Buy Market Orders, it refers to the quantity in quote currency.
    For SPOT Sell Market Orders, it refers to the quantity in base currency.
    tgtCcy
    This parameter is used to specify the order quantity in the order request is denominated in the quantity of base or quote currency. This is applicable to SPOT Market Orders only.
    Base currency:base_ccy
    Quote currency:quote_ccy
    If you use the Base Currency quantity for buy market orders or the Quote Currency for sell market orders, please note:
    1. If the quantity you enter is greater than what you can buy or sell, the system will execute the order according to your maximum buyable or sellable quantity. If you want to trade according to the specified quantity, you should use Limit orders.
    2. When the market price is too volatile, the locked balance may not be sufficient to buy the Base Currency quantity or sell to receive the Quote Currency that you specified. We will change the quantity of the order to execute the order based on best effort principle based on your account balance. In addition, we will try to over lock a fraction of your balance to avoid changing the order quantity.
    2.1 Example of base currency buy market order:
    Taking the market order to buy 10 LTCs as an example, and the user can buy 11 LTC. At this time, if 10 < 11, the order is accepted. When the LTC-USDT market price is 200, and the locked balance of the user is 3,000 USDT, as 200*10 < 3,000, the market order of 10 LTC is fully executed; If the market is too volatile and the LTC-USDT market price becomes 400, 400*10 > 3,000, the user's locked balance is not sufficient to buy using the specified amount of base currency, the user's maximum locked balance of 3,000 USDT will be used to settle the trade. Final transaction quantity becomes 3,000/400 = 7.5 LTC.
    2.2 Example of quote currency sell market order:
    Taking the market order to sell 1,000 USDT as an example, and the user can sell 1,200 USDT, 1,000 < 1,200, the order is accepted. When the LTC-USDT market price is 200, and the locked balance of the user is 6 LTC, as 1,000/200 < 6, the market order of 1,000 USDT is fully executed; If the market is too volatile and the LTC-USDT market price becomes 100, 100*6 < 1,000, the user's locked balance is not sufficient to sell using the specified amount of quote currency, the user's maximum locked balance of 6 LTC will be used to settle the trade. Final transaction quantity becomes 6 * 100 = 600 USDT.

    Place multiple orders

    Place orders in batches. Maximum 20 orders can be placed per request. Request parameters should be passed in the form of an array.

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Place order`.

    HTTP Request

    POST /api/v5/trade/batch-orders

    Request Example

     batch place order for SPOT
     POST /api/v5/trade/batch-orders
     body
     [
        {
            "instId":"BTC-USD",
            "tdMode":"cash",
            "clOrdId":"b15",
            "side":"buy",
            "ordType":"limit",
            "px":"2.15",
            "sz":"2"
        },
        {
            "instId":"BTC-USD",
            "tdMode":"cash",
            "clOrdId":"b15",
            "side":"buy",
            "ordType":"limit",
            "px":"2.15",
            "sz":"2"
        }
    ]
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    tdMode String Yes Trade mode
    Non-Margin mode cash
    clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    tag String No Order tag
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
    side String Yes Order side buy sell
    ordType String Yes Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    sz String Yes Quantity to buy or sell
    px String Conditional Order price. Only applicable to limit,post_only,fok,ioc order.
    tgtCcy String No Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    banAmend Boolean No Whether to disallow the system from amending the size of the SPOT Market Order.
    Valid options: true or false. The default value is false.
    If true, system will not amend and reject the market order if user does not have sufficient funds.
    Only applicable to SPOT Market Orders

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "clOrdId":"oktswap6",
                "ordId":"12345689",
                "tag":"",
                "sCode":"0",
                "sMsg":""
            },
            {
                "clOrdId":"oktswap7",
                "ordId":"12344",
                "tag":"",
                "sCode":"0",
                "sMsg":""
            },
         .......
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.

    Cancel order

    Cancel an incomplete order.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/cancel-order

    Request Example

    POST /api/v5/trade/cancel-order
    body
    {
        "ordId":"2510789768709120",
        "instId":"BTC-USD"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    ordId String Conditional Order ID
    Either ordId or clOrdId is required. If both are passed, ordId will be used.
    clOrdId String Conditional Client Order ID as assigned by the client

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "clOrdId":"oktswap6",
                "ordId":"12345689",
                "sCode":"0",
                "sMsg":""
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.
    Cancel order returns with sCode equal to 0. It is not strictly considered that the order has been canceled. It only means that your cancelation request has been accepted by the system server. The result of the cancelation is subject to the state pushed by the order channel or the get order state.

    Cancel multiple orders

    Cancel incomplete orders in batches. Maximum 20 orders can be canceled per request. Request parameters should be passed in the form of an array.

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Cancel order`.

    HTTP Request

    POST /api/v5/trade/cancel-batch-orders

    Request Example

    POST /api/v5/trade/cancel-batch-orders
    body
    [
        {
            "instId":"BTC-USD",
            "ordId":"12312"
        },
        {
            "instId":"BTC-USD",
            "ordId":"1212"
        }
    ]
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    ordId String Conditional Order ID
    Either ordId or clOrdId is required. If both are passed, ordId will be used.
    clOrdId String Conditional Client Order ID as assigned by the client

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "clOrdId":"oktswap6",
                "ordId":"12345689",
                "sCode":"0",
                "sMsg":""
            },
            {
                "clOrdId":"oktswap7",
                "ordId":"12344",
                "sCode":"0",
                "sMsg":""
            },
         .......
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.

    Amend order

    Amend an incomplete order.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/amend-order

    Request Example

    POST /api/v5/trade/amend-order
    body
    {
        "ordId":"2510789768709120",
        "newSz":"2",
        "instId":"BTC-USD"
    }
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID
    cxlOnFail Boolean No Whether the order needs to be automatically canceled when the order amendment fails
    Valid options: false or true, the default is false.
    ordId String Conditional Order ID
    Either ordId or clOrdId is required. If both are passed, ordId will be used.
    clOrdId String Conditional Client Order ID as assigned by the client
    reqId String No Client Request ID as assigned by the client for order amendment
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    The response will include the corresponding reqId to help you identify the request if you provide it in the request.
    newSz String Conditional New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
    newPx String Conditional New price after amendment.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
             "clOrdId":"",
             "ordId":"12344",
             "reqId":"b12344",
             "sCode":"0",
             "sMsg":""
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    reqId String Client Request ID as assigned by the client for order amendment.
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.
    newSz
    If the new quantity of the order is less than or equal to the filled quantity when you are amending a partially-filled order, the order status will be changed to filled.
    The amend order returns sCode equal to 0. It is not strictly considered that the order has been amend. It only means that your amend order request has been accepted by the system server. The result of the amend is subject to the status pushed by the order channel or the order status query

    Amend multiple orders

    Amend incomplete orders in batches. Maximum 20 orders can be amended per request. Request parameters should be passed in the form of an array.

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Amend order`.

    HTTP Request

    POST /api/v5/trade/amend-batch-orders

    Request Example

    POST /api/v5/trade/amend-batch-orders
    body
    [
        {
            "ordId":"2510789768709120",
            "newSz":"2",
            "instId":"BTC-USD"
        },
        {
            "ordId":"2510789768709121",
            "newSz":"2",
            "instId":"BTC-USD"
        }
    ]
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID
    cxlOnFail Boolean No Whether the order needs to be automatically canceled when the order amendment fails
    false true, the default is false.
    ordId String Conditional Order ID
    Either ordId or clOrdIdis required, if both are passed, ordId will be used.
    clOrdId String Conditional Client Order ID as assigned by the client
    reqId String No Client Request ID as assigned by the client for order amendment
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    The response will include the corresponding reqId to help you identify the request if you provide it in the request.
    newSz String Conditional New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
    newPx String Conditional New price after amendment.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "clOrdId":"oktswap6",
                "ordId":"12345689",
                "reqId":"b12344",
                "sCode":"0",
                "sMsg":""
            },
            {
                "clOrdId":"oktswap7",
                "ordId":"12344",
                "reqId":"b12344",
                "sCode":"0",
                "sMsg":""
            },
         .......
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    reqId String Client Request ID as assigned by the client for order amendment.
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.
    newSz
    If the new quantity of the order is less than or equal to the filled quantity when you are amending a partially-filled order, the order status will be changed to filled.

    Get order details

    Retrieve order details.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    GET /api/v5/trade/order

    Request Example

    GET /api/v5/trade/order?ordId=2510789768709120&instId=BTC-USD
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    ordId String Conditional Order ID
    Either ordId or clOrdId is required, if both are passed, ordId will be used
    clOrdId String Conditional Client Order ID as assigned by the client

    Response Example

    {
        "code": "0",
        "data": [
            {
                "accFillSz": "1.6342",
                "avgPx": "0.9995",
                "cTime": "1672814726198",
                "category": "normal",
                "ccy": "",
                "clOrdId": "",
                "fee": "-0.00245007435",
                "feeCcy": "USD",
                "fillPx": "0.9995",
                "fillSz": "1.6342",
                "fillTime": "1672814726201",
                "instId": "USDT-USD",
                "instType": "SPOT",
                "lever": "",
                "ordId": "530758662663180288",
                "ordType": "market",
                "pnl": "0",
                "posSide": "net",
                "px": "",
                "rebate": "0",
                "rebateCcy": "USDT",
                "reduceOnly": "false",
                "side": "sell",
                "slOrdPx": "",
                "slTriggerPx": "",
                "slTriggerPxType": "",
                "source": "",
                "state": "filled",
                "sz": "1.6342",
                "tag": "",
                "tdMode": "cash",
                "tgtCcy": "base_ccy",
                "tpOrdPx": "",
                "tpTriggerPx": "",
                "tpTriggerPxType": "",
                "tradeId": "3225651",
                "uTime": "1672814726203"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    SPOT
    instId String Instrument ID
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    px String Price
    sz String Quantity to buy or sell
    pnl String Profit and loss. Not enabled. Please disregard.
    ordType String Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    accFillSz String Accumulated fill quantity
    fillPx String Last filled price. If none is filled, it will return 0.
    tradeId String Last traded ID
    fillSz String Last filled quantity
    fillTime String Last filled time
    avgPx String Average filled price. If none is filled, it will return 0.
    state String State
    canceled
    live
    partially_filled
    filled
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price.
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price.
    slTriggerPx String Stop-loss trigger price.
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price.
    feeCcy String Fee currency
    fee String Fee and rebate
    It is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
    rebateCcy String Rebate currency
    source String Order source
    13:The generated limit order after the strategy order is triggered
    rebate String Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
    category String Category
    normal
    uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    cTime String Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get order List

    Retrieve all incomplete orders under the current account.

    Rate Limit: 60 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/orders-pending

    Request Example

    GET /api/v5/trade/orders-pending?ordType=post_only,fok,ioc&instType=SPOT
    
    

    Request Parameters

    Parameter Type Required Description
    instType String No Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    ordType String No Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    state String No State
    live
    partially_filled
    after String No Pagination of data to return records earlier than the requested ordId
    before String No Pagination of data to return records newer than the requested ordId
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "accFillSz": "0",
                "avgPx": "",
                "cTime": "1618235248028",
                "category": "normal",
                "ccy": "",
                "clOrdId": "",
                "fee": "0",
                "feeCcy": "BTC",
                "fillPx": "",
                "fillSz": "0",
                "fillTime": "",
                "instId": "BTC-USDT",
                "instType": "SPOT",
                "lever": "5.6",
                "ordId": "301835739059335168",
                "ordType": "limit",
                "pnl": "0",
                "posSide": "net",
                "px": "59200",
                "rebate": "0",
                "rebateCcy": "USDT",
                "side": "buy",
                "slOrdPx": "",
                "slTriggerPx": "",
                "slTriggerPxType": "last",
                "state": "live",
                "sz": "1",
                "tag": "",
                "tgtCcy": "",
                "tdMode": "cross",
                "source":"",
                "tpOrdPx": "",
                "tpTriggerPx": "",
                "tpTriggerPxType": "last",
                "tradeId": "",
                "uTime": "1618235248028"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    px String Price
    sz String Quantity to buy or sell
    pnl String Profit and loss. Not enabled. Please disregard.
    ordType String Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    accFillSz String Accumulated fill quantity
    fillPx String Last filled price
    tradeId String Last trade ID
    fillSz String Last filled quantity
    fillTime String Last filled time
    avgPx String Average filled price. If none is filled, it will return 0.
    state String State
    live
    partially_filled
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price.
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price.
    slTriggerPx String Stop-loss trigger price.
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price.
    feeCcy String Fee currency
    fee String Fee and rebate
    For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
    rebateCcy String Rebate currency
    source String Order source
    13:The generated limit order after the strategy order is triggered
    rebate String Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
    category String Category
    normal
    uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    cTime String Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get order history (last 7 days)

    Retrieve the completed order data for the last 7 days, and the incomplete orders that have been canceled are only reserved for 2 hours.

    Rate Limit: 40 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/orders-history

    Request Example

    GET /api/v5/trade/orders-history?ordType=post_only,fok,ioc&instType=SPOT
    
    

    Request Parameters

    Parameter Type Required Description
    instType String yes Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    ordType String No Order type
    market: market order
    limit: limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    state String No State
    canceled
    filled
    after String No Pagination of data to return records earlier than the requested ordId
    before String No Pagination of data to return records newer than the requested ordId
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "instType": "SPOT",
          "instId": "BTC-USD",
          "ccy": "",
          "ordId": "312269865356374016",
          "clOrdId": "b1",
          "tag": "",
          "px": "999",
          "sz": "3",
          "ordType": "limit",
          "side": "buy",
          "posSide": "net",
          "tdMode": "cash",
          "accFillSz": "0",
          "fillPx": "0",
          "tradeId": "0",
          "fillSz": "0",
          "fillTime": "0",
          "state": "filled",
          "avgPx": "0",
          "lever": "",
          "tpTriggerPx": "",
          "tpTriggerPxType": "last",
          "tpOrdPx": "",
          "slTriggerPx": "",
          "slTriggerPxType": "last",
          "slOrdPx": "",
          "feeCcy": "",
          "fee": "",
          "rebateCcy": "",
          "source":"",
          "rebate": "",
          "tgtCcy":"",
          "pnl": "",
          "category": "",
          "uTime": "1597026383085",
          "cTime": "1597026383085"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    px String Price
    sz String Quantity to buy or sell
    ordType String Order type
    market: market order
    limit: limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    accFillSz String Accumulated fill quantity
    fillPx String Last filled price. If none is filled, it will return 0.
    tradeId String Last trade ID
    fillSz String Last filled quantity
    fillTime String Last filled time
    avgPx String Average filled price. If none is filled, it will return 0.
    state String State
    canceled
    filled
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price.
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price.
    slTriggerPx String Stop-loss trigger price.
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price.
    feeCcy String Fee currency
    fee String Fee and rebate
    For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
    rebateCcy String Rebate currency
    source String Order source
    13:The generated limit order after the strategy order is triggered
    rebate String Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
    pnl String Profit and loss. Not enabled. Please disregard.
    category String Category
    normal
    uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    cTime String Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get order history (last 3 months)

    Retrieve the completed order data of the last 3 months.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/orders-history-archive

    Request Example

    GET /api/v5/trade/orders-history-archive?ordType=post_only,fok,ioc&instType=SPOT
    
    

    Request Parameters

    Parameter Type Required Description
    instType String yes Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    ordType String No Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    state String No State
    canceled
    filled
    after String No Pagination of data to return records earlier than the requested ordId
    before String No Pagination of data to return records newer than the requested ordId
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
        "code": "0",
        "data": [
            {
                "accFillSz": "1.6342",
                "avgPx": "0.9995",
                "cTime": "1672814726198",
                "category": "normal",
                "ccy": "",
                "clOrdId": "",
                "fee": "-0.00245007435",
                "feeCcy": "USD",
                "fillPx": "0.9995",
                "fillSz": "1.6342",
                "fillTime": "1672814726201",
                "instId": "USDT-USD",
                "instType": "SPOT",
                "lever": "",
                "ordId": "530758662663180288",
                "ordType": "market",
                "pnl": "0",
                "posSide": "",
                "px": "",
                "rebate": "0",
                "rebateCcy": "USDT",
                "reduceOnly": "false",
                "side": "sell",
                "slOrdPx": "",
                "slTriggerPx": "",
                "slTriggerPxType": "",
                "source": "",
                "state": "filled",
                "sz": "1.6342",
                "tag": "",
                "tdMode": "cash",
                "tgtCcy": "base_ccy",
                "tpOrdPx": "",
                "tpTriggerPx": "",
                "tpTriggerPxType": "",
                "tradeId": "3225651",
                "uTime": "1672814726859"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    tag String Order tag
    px String Price
    sz String Quantity to buy or sell
    ordType String Order type
    market: Market order
    limit: Limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    accFillSz String Accumulated fill quantity
    fillPx String Last filled price. If none is filled, it will return 0.
    tradeId String Last trade ID
    fillSz String Last filled quantity
    fillTime String Last filled time
    avgPx String Average filled price. If none is filled, it will returns 0.
    state String State
    canceled
    filled
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price.
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price.
    slTriggerPx String Stop-loss trigger price.
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price.
    feeCcy String Fee currency
    fee String Fee and rebate
    For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
    source String Order source
    13:The generated limit order after the strategy order is triggered
    rebateCcy String Rebate currency
    rebate String Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
    pnl String Profit and loss. Not enabled. Please disregard.
    category String Category
    normal
    uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    cTime String Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
    This interface does not contain the order data of the `Canceled orders without any fills` type, which can be obtained through the `Get Order History (last 7 days)` interface.

    Get transaction details (last 3 days)

    Retrieve recently-filled transaction details in the last 3 day.

    Rate Limit: 60 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/fills

    Request Example

    GET /api/v5/trade/fills
    
    

    Request Parameters

    Parameter Type Required Description
    instType String No Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    ordId String No Order ID
    after String No Pagination of data to return records earlier than the requested billId
    before String No Pagination of data to return records newer than the requested billId
    begin String No Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    end String No Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "instType": "SPOT",
          "instId": "BTC-USD",
          "tradeId": "123",
          "ordId": "312269865356374016",
          "clOrdId": "b16",
          "billId": "1111",
          "tag": "",
          "fillPx": "999",
          "fillSz": "3",
          "side": "buy",
          "posSide": "net",
          "execType": "M",
          "feeCcy": "",
          "fee": "",
          "ts": "1597026383085"
        },
        {
          "instType": "SPOT",
          "instId": "BTC-USD",
          "tradeId": "123",
          "ordId": "312269865356374016",
          "clOrdId": "b16",
          "billId": "1111",
          "tag": "",
          "fillPx": "999",
          "fillSz": "3",
          "side": "buy",
          "posSide": "net",
          "execType": "M",
          "feeCcy": "",
          "fee": "",
          "ts": "1597026383085"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    tradeId String Last trade ID
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    billId String Bill ID
    tag String Order tag
    fillPx String Last filled price
    fillSz String Last filled quantity
    side String Order side, buy sell
    posSide String Position side. Not enabled. Please disregard.
    execType String Liquidity taker or maker, T: taker M: maker
    feeCcy String Fee currency
    fee String Fee
    ts String Data generation time, Unix timestamp format in milliseconds, e.g. 1597026383085.

    Get transaction details (last 3 months)

    Retrieve recently-filled transaction details in the last 3 months.

    Rate Limit: 10 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/fills-history

    Request Example

    GET /api/v5/trade/fills-history
    
    

    Request Parameters

    Parameter Type Required Description
    instType String YES Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    ordId String No Order ID
    after String No Pagination of data to return records earlier than the requested billId
    before String No Pagination of data to return records newer than the requested billId
    begin String No Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    end String No Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "instType": "SPOT",
          "instId": "BTC-USD",
          "tradeId": "123",
          "ordId": "312269865356374016",
          "clOrdId": "b16",
          "billId": "1111",
          "tag": "",
          "fillPx": "999",
          "fillSz": "3",
          "side": "buy",
          "posSide": "net",
          "execType": "M",
          "feeCcy": "",
          "fee": "",
          "ts": "1597026383085"
        },
        {
          "instType": "SPOT",
          "instId": "BTC-USD",
          "tradeId": "123",
          "ordId": "312269865356374016",
          "clOrdId": "b16",
          "billId": "1111",
          "tag": "",
          "fillPx": "999",
          "fillSz": "3",
          "side": "buy",
          "posSide": "net",
          "execType": "M",
          "feeCcy": "",
          "fee": "",
          "ts": "1597026383085"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    tradeId String Last trade ID
    ordId String Order ID
    clOrdId String Client Order ID as assigned by the client
    billId String Bill ID
    tag String Order tag
    fillPx String Last filled price
    fillSz String Last filled quantity
    side String Order side, buy sell
    posSide String Position side. Not enabled. Please disregard.
    execType String Liquidity taker or maker, T: taker M: maker
    feeCcy String Fee currency
    fee String Fee
    ts String Data generation time, Unix timestamp format in milliseconds, e.g. 1597026383085.

    Place algo order

    The algo order includes trigger order, oco order, conditional order,iceberg order, twap order and trailing order.

    Rate Limit: 20 requests per 2 seconds

    Derivatives rate limit rule: UserID + (instrumentType + underlying)

    Spot & Margin rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/order-algo

    Request Example

    POST /api/v5/trade/order-algo
    body
    {
        "instId":"BTC-USDT",
        "tdMode":"cash",
        "side":"buy",
        "ordType":"conditional",
        "sz":"2",
        "tpTriggerPx":"15",
        "tpOrdPx":"18"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    tdMode String Yes Trade mode
    Non-Margin mode cash
    side String Yes Order side, buy sell
    ordType String Yes Order type
    conditional: One-way stop order
    oco: One-cancels-the-other order
    trigger: Trigger order
    move_order_stop: Trailing order
    iceberg: Iceberg order
    twap: TWAP order
    sz String Yes Quantity to buy or sell
    tag String No Order tag
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
    tgtCcy String No Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT traded with Market buy conditional order
    Default is quote_ccy for buy, base_ccy for sell
    clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

    Stop Order

    Parameter Type Required Description
    tpTriggerPx String No Take-profit trigger price
    If you fill in this parameter, you should fill in the take-profit order price as well.
    tpTriggerPxType String No Take-profit trigger price type

    last: last price
    The Default is last
    tpOrdPx String No Take-profit order price
    If you fill in this parameter, you should fill in the take-profit trigger price as well.
    If the price is -1, take-profit will be executed at the market price.
    slTriggerPx String No Stop-loss trigger price
    If you fill in this parameter, you should fill in the stop-loss order price.
    slTriggerPxType String No Stop-loss trigger price type

    last: last price
    The Default is last
    slOrdPx String No Stop-loss order price
    If you fill in this parameter, you should fill in the stop-loss trigger price.
    If the price is -1, stop-loss will be executed at the market price.
    Stop Order
    When placing net stop order (ordType=conditional) and both take-profit and stop-loss parameters are sent, only stop-loss logic will be performed and take-profit logic will be ignored.

    Trigger Order

    Parameter Type Required Description
    triggerPx String Yes Trigger price
    orderPx String Yes Order Price
    If the price is -1, the order will be executed at the market price.
    triggerPxType String No Trigger price type

    last: last price
    The Default is last

    Trailing Stop Order

    Parameter Type Required Description
    callbackRatio String Conditional Callback price ratio , e.g. 0.01

    Either callbackRatio or callbackSpread is allowed to be passed.
    callbackSpread String Conditional Callback price variance
    activePx String No Active price

    Iceberg Order

    Parameter Type Required Description
    pxVar String Conditional Price ratio
    Either pxVar or pxSpread is allowed to be passed.
    pxSpread String Conditional Price variance
    szLimit String Yes Average amount
    pxLimit String Yes Price Limit

    TWAP Order

    Parameter Type Required Description
    pxVar String Conditional Price ratio
    Either pxVar or pxSpread is allowed to be passed.
    pxSpread String Conditional Price variance
    szLimit String Yes Average amount
    pxLimit String Yes Price Limit
    timeInterval String Yes Time interval

    Learn more about Iceberg Order & TWAP Order

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "algoId": "12345689",
          "clOrdId": "",
          "sCode": "0",
          "sMsg": ""
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    algoId String Algo ID
    clOrdId String Client Order ID as assigned by the client
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.

    Cancel algo order

    Cancel unfilled algo orders (not including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array.

    Rate Limit: 20 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/cancel-algos

    Request Example

    POST /api/v5/trade/cancel-algos
    body
    [
        {
            "algoId":"198273485",
            "instId":"BTC-USD"
        },
        {
            "algoId":"198273485",
            "instId":"BTC-USD"
        }
    ]
    

    Request Parameters

    Parameter Type Required Description
    algoId String Yes Algo ID
    instId String Yes Instrument ID, e.g. BTC-USD

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "algoId":"1234",
                "sCode":"0",
                "sMsg":""
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    algoId String Order ID
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.

    Cancel advance algo order

    Cancel unfilled algo orders (including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array.

    Rate Limit: 20 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    HTTP Request

    POST /api/v5/trade/cancel-advance-algos

    Request Example

    POST /api/v5/trade/cancel-advance-algos
    body
    [
        {
            "algoId":"198273485",
            "instId":"BTC-USD"
        },
        {
            "algoId":"198273485",
            "instId":"BTC-USD"
        }
    ]
    

    Request Parameters

    Parameter Type Required Description
    algoId String Yes Algo ID
    instId String Yes Instrument ID, e.g. BTC-USD

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "algoId":"1234",
                "sCode":"0",
                "sMsg":""
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    algoId String Order ID
    sCode String The code of the event execution result, 0 means success.
    sMsg String Rejection message if the request is unsuccessful.

    Get algo order list

    Retrieve a list of untriggered Algo orders under the current account.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/orders-algo-pending

    Request Example

    GET /api/v5/trade/orders-algo-pending?ordType=conditional
    
    

    Request Parameters

    Parameter Type Required Description
    ordType String Yes Order type
    conditional: One-way stop order
    oco: One-cancels-the-other order
    trigger: Trigger order
    move_order_stop: Trailing order
    iceberg: Iceberg order
    twap: TWAP order
    algoId String No Algo ID
    clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    instType String No Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    after String No Pagination of data to return records earlier than the requested algoId.
    before String No Pagination of data to return records newer than the requested algoId.
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
        "code": "0",
        "data": [
            {
                "activePx": "",
                "actualPx": "",
                "actualSide": "",
                "actualSz": "0",
                "algoId": "492453578716610560",
                "cTime": "1663682082511",
                "callbackRatio": "",
                "callbackSpread": "",
                "ccy": "",
                "clOrdId": "hahawang",
                "instId": "BTC-USD",
                "instType": "SPOT",
                "lever": "",
                "moveTriggerPx": "",
                "ordId": "0",
                "ordPx": "",
                "ordType": "conditional",
                "posSide": "net",
                "pxLimit": "",
                "pxSpread": "",
                "pxVar": "",
                "side": "buy",
                "slOrdPx": "-1",
                "slTriggerPx": "22000",
                "slTriggerPxType": "last",
                "state": "live",
                "sz": "10",
                "szLimit": "",
                "tag": "",
                "tdMode": "cash",
                "tgtCcy": "",
                "timeInterval": "",
                "tpOrdPx": "",
                "tpTriggerPx": "",
                "tpTriggerPxType": "",
                "triggerPx": "",
                "triggerPxType": "",
                "triggerTime": ""
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    algoId String Algo ID
    clOrdId String Client Order ID as assigned by the client
    sz String Quantity to buy or sell
    ordType String Order type
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT traded with Market order
    state String State,live pause partially_effective
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price
    slTriggerPx String Stop-loss trigger price
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price
    triggerPx String Trigger price
    triggerPxType String Trigger price type.
    last: last price
    ordPx String Order price
    actualSz String Actual order quantity
    tag String Order tag
    actualPx String Actual order price
    actualSide String Actual trigger side
    tp: take profit sl: stop loss
    triggerTime String Trigger time, Unix timestamp format in milliseconds, e.g. 1597026383085
    pxVar String Price ratio
    Only applicable to iceberg order or twap order
    pxSpread String Price variance
    Only applicable to iceberg order or twap order
    szLimit String Average amount
    Only applicable to iceberg order or twap order
    pxLimit String Price Limit
    Only applicable to iceberg order or twap order
    timeInterval String Time interval
    Only applicable to twap order
    callbackRatio String Callback price ratio
    Only applicable to move_order_stop order
    callbackSpread String Callback price variance
    Only applicable to move_order_stop order
    activePx String Active price
    Only applicable to move_order_stop order
    moveTriggerPx String Trigger price
    Only applicable to move_order_stop order
    cTime String Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get algo order history

    Retrieve a list of all algo orders under the current account in the last 3 months.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/trade/orders-algo-history

    Request Example

    GET /api/v5/trade/orders-algo-history?state=effective&ordType=conditional
    

    Request Parameters

    Parameter Type Required Description
    ordType String Yes Order type
    conditional: One-way stop order
    oco: One-cancels-the-other order
    trigger: Trigger order
    move_order_stop: Trailing order
    iceberg: Iceberg order
    twap: TWAP order
    state String Conditional State
    effective
    canceled
    order_failed
    Either state or algoId is requied
    algoId String Conditional Algo ID
    Either state or algoId is required.
    instType String No Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USD
    after String No Pagination of data to return records earlier than the requested algoId
    before String No Pagination of data to return records new than the requested algoId
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "instType":"SPOT",
                "instId":"BTC-USD",
                "ordId":"123445",
                "ccy":"",
                "clOrdId":"",
                "algoId":"1234",
                "sz":"999",
                "ordType":"oco",
                "side":"buy",
                "posSide":"net",
                "tdMode":"cash",
                "tgtCcy": "",
                "state":"effective",
                "lever":"",
                "tpTriggerPx":"",
                "tpTriggerPxType":"",
                "tpOrdPx":"",
                "slTriggerPx":"",
                "slTriggerPxType":"",
                "triggerPx":"99",
                "triggerPxType":"last",
                "ordPx":"12",
                "actualSz":"",
                "actualPx":"",
                "actualSide":"",
                "pxVar":"",
                "pxSpread":"",
                "pxLimit":"",
                "szLimit":"",
                "tag": "adadadadad",
                "timeInterval":"",
                "callbackRatio":"",
                "callbackSpread":"",
                "activePx":"",
                "moveTriggerPx":"",
                "triggerTime":"1597026383085",
                "cTime":"1597026383000"
            },
            {
                "instType":"SPOT",
                "instId":"BTC-USD",
                "ordId":"123445",
                "ccy":"",
                "clOrdId":"",
                "algoId":"1234",
                "sz":"999",
                "ordType":"oco",
                "side":"buy",
                "posSide":"net",
                "tdMode":"cash",
                "tgtCcy": "",
                "state":"effective",
                "lever":"",
                "tpTriggerPx":"",
                "tpTriggerPxType":"",
                "tpOrdPx":"",
                "slTriggerPx":"",
                "slTriggerPxType":"",
                "triggerPx":"99",
                "triggerPxType":"last",
                "ordPx":"12",
                "actualSz":"",
                "actualPx":"",
                "actualSide":"",
                "pxVar":"",
                "pxSpread":"",
                "pxLimit":"",
                "szLimit":"",
                "tag": "adadadadad",
                "timeInterval":"",
                "callbackRatio":"",
                "callbackSpread":"",
                "activePx":"",
                "moveTriggerPx":"",
                "triggerTime":"1597026383085",
                "cTime":"1597026383000"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    ccy String Margin currency. Not enabled. Please disregard.
    ordId String Order ID
    algoId String Algo ID
    clOrdId String Client Order ID as assigned by the client
    sz String Quantity to buy or sell
    ordType String Order type
    side String Order side
    posSide String Position side. Not enabled. Please disregard.
    tdMode String Trade mode
    tgtCcy String Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    state String State
    effective
    canceled
    order_failed
    lever String Leverage. Not enabled. Please disregard.
    tpTriggerPx String Take-profit trigger price.
    tpTriggerPxType String Take-profit trigger price type.
    last: last price
    tpOrdPx String Take-profit order price.
    slTriggerPx String Stop-loss trigger price.
    slTriggerPxType String Stop-loss trigger price type.
    last: last price
    slOrdPx String Stop-loss order price.
    triggerPx String trigger price.
    triggerPxType String trigger price type.
    last: last price
    ordPx String Order price
    actualSz String Actual order quantity
    actualPx String Actual order price
    tag String Order tag
    actualSide String Actual trigger side, tp: take profit sl: stop loss
    triggerTime String Trigger time, Unix timestamp format in milliseconds, e.g. 1597026383085
    pxVar String Price ratio
    Only applicable to iceberg order or twap order
    pxSpread String Price variance
    Only applicable to iceberg order or twap order
    szLimit String Average amount
    Only applicable to iceberg order or twap order
    pxLimit String Price Limit
    Only applicable to iceberg order or twap order
    timeInterval String Time interval
    Only applicable to twap order
    callbackRatio String Callback price ratio
    Only applicable to move_order_stop order
    callbackSpread String Callback price variance
    Only applicable to move_order_stop order
    activePx String Active price
    Only applicable to move_order_stop order
    moveTriggerPx String Trigger price
    Only applicable to move_order_stop order
    cTime String Creation time Unix timestamp format in milliseconds, e.g. 1597026383085

    Funding

    The API endpoints of Funding require authentication.

    Get currencies

    Retrieve a list of all currencies.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/currencies

    Request Example

    GET /api/v5/asset/currencies
    
    

    Request Parameters

    Parameters Types Required Description
    ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "canDep": true,
                "canInternal": false,
                "canWd": true,
                "ccy": "EUR",
                "chain": "EUR-fiat",
                "depQuotaFixed": "",
                "depQuoteDailyLayer2": "",
                "logoLink": "https://static.okcoin.com/cdn/assets/imgs/218/3CE0A0023386E9EA.png",
                "mainNet": true,
                "maxFee": "0",
                "maxWd": "1586886",
                "minDep": "0.00000001",
                "minDepArrivalConfirm": "0",
                "minFee": "0",
                "minWd": "0",
                "minWdUnlockConfirm": "0",
                "name": "Euro",
                "needTag": false,
                "usedDepQuotaFixed": "",
                "usedWdQuota": "0",
                "wdQuota": "1000000",
                "wdTickSz": "4"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency, e.g. BTC
    name String Chinese name of currency
    logoLink String Logo link of currency
    chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
    canDep Boolean Availability to deposit from chain.
    false: not available true: available
    canWd Boolean Availability to withdraw to chain.
    false: not available true: available
    canInternal Boolean Availability to internal transfer.
    false: not available true: available
    minDep String Minimum deposit amount of the currency in a single transaction
    minWd String Minimum withdrawal amount of the currency in a single transaction
    maxWd String Maximum amount of currency withdrawal in a single transaction
    wdTickSz String Withdrawal precision, indicating the number of digits after the decimal point
    wdQuota String Withdrawal limit in the past 24 hours, unit in USD
    usedWdQuota String Amount of currency withdrawal used in the past 24 hours, unit in USD
    minFee String Minimum withdrawal fee
    maxFee String Maximum withdrawal fee
    mainNet Boolean If current chain is main net then return true, otherwise return false
    needTag Boolean Whether tag/memo information is required for withdrawal
    minDepArrivalConfirm String Minimum number of blockchain confirmations to acknowledge fund deposit. Account is credited after that but the deposit cannot be withdrawn
    minWdUnlockConfirm String Minimum number of blockchain confirmations required for withdrawal of a deposit
    depQuotaFixed String Fixed deposit limit, unit in BTC
    Return empty string if there is no deposit limit
    usedDepQuotaFixed String Used amount of fixed deposit quota, unit in BTC
    Return empty string if there is no deposit limit

    Get balance

    Retrieve the funding account balances of all the assets and the amount that is available or on hold.

    Only asset information of a currency with a balance greater than 0 will be returned.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/balances

    Request Example

    GET /api/v5/asset/balances
    
    

    Request Parameters

    Parameters Types Required Description
    ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [{
                "availBal": "37.11827078",
                "bal": "37.11827078",
                "ccy": "ETH",
                "frozenBal": "0"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency
    bal String Balance
    frozenBal String Frozen balance
    availBal String Available balance

    Get account asset valuation

    View account asset valuation

    Rate Limit: 1 request 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/asset-valuation

    Request Example

    GET /api/v5/asset/asset-valuation
    

    Request Parameters

    Parameters Types Required Description
    ccy String No Asset valuation calculation unit
    BTC
    USD, CNY, JP, KRW, RUB, EUR
    VND, IDR, INR, PHP, THB, TRY
    AUD, SGD, ARS, SAR, AED, IQD
    The default is the valuation in BTC.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "details": {
                    "classic": "124.6",
                    "earn": "1122.73",
                    "funding": "0.09",
                    "trading": "2544.28"
                },
                "totalBal": "3790.09",
                "ts": "1637566660769"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    totalBal String Valuation of total account assets
    ts String Unix timestamp format in milliseconds, e.g.1597026383085
    details Array Asset valuation details for each account
    > funding String Funding account
    > trading String Unified account
    > classic String Classic account
    > earn String Earn account

    Funds transfer

    Only API keys with Trade privilege can call this endpoint.

    This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts.

    Failure of the request does not mean the transfer has failed. Recommend to call "Get funds transfer state" to confirm the status.

    Rate Limit: 1 request per second

    Rate limit rule: UserID + Currency

    HTTP Request

    POST /api/v5/asset/transfer

    Request Example

    Transfer 1.5 USD from funding account to Trading account when current account is master-account
    POST /api/v5/asset/transfer
    body
    {
        "ccy":"USD",
        "amt":"1.5",
        "from":"6",
        "to":"18"
    }
    
    Transfer 1.5 USD from funding account to subAccount when current account is master-account
    POST /api/v5/asset/transfer
    body
    {
        "ccy":"USD",
        "type":"1",
        "amt":"1.5",
        "from":"6",
        "to":"6",
        "subAcct":"mini"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String Yes Currency, e.g. USD
    amt String Yes Amount to be transferred
    from String Yes The remitting account
    1: Classic account 6: Funding account, 18: Unified account
    to String Yes The beneficiary account
    1: Classic account 6: Funding account, 18: Unified account
    subAcct String Conditional Name of the sub-account
    When type is 1 or 2, sub-account is required.
    type String No Transfer type
    0: transfer within account
    1: master account to sub-account (Only applicable to APIKey from master account)
    2: sub-account to master account (Only applicable to APIKey from master account)
    3: sub-account to master account (Only applicable to APIKey from sub-account)
    The default is 0.
    clientId String No Client-supplied ID
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "transId": "754147",
          "ccy": "USD",
          "clientId": "",
          "from": "6",
          "amt": "0.1",
          "to": "18"
        }
      ]
    }
    

    Response Parameters

    Response Example

    Parameter Type Description
    transId String Transfer ID
    clientId String Client-supplied ID
    ccy String Currency
    from String The remitting account
    amt String Transfer amount
    to String The beneficiary account

    Get funds transfer state

    Retrieve the transfer state data of the last 2 weeks.

    Rate Limit: 1 request per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/transfer-state

    Request Example

    GET /api/v5/asset/transfer-state?transId=1&type=1
    

    Request Parameters

    Parameter Type Required Description
    transId String Conditional Transfer ID
    Either transId or clientId is required. If both are passed, transId will be used.
    clientId String Conditional Client-supplied ID
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    type String No Transfer type
    0: transfer within account
    1: master account to sub-account (Only applicable to APIKey from master account)
    2: sub-account to master account (Only applicable to APIKey from master account)
    3: sub-account to master account (Only applicable to APIKey from sub-account)
    The default is 0

    Response Example

    {
        "code": "0",
        "data": [
            {
                "amt": "1.5",
                "ccy": "USDT",
                "clientId": "",
                "from": "18",
                "instId": "", //deprecated
                "state": "success",
                "subAcct": "test",
                "to": "6",
                "toInstId": "", //deprecated
                "transId": "1",
                "type": "1"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    transId String Transfer ID
    clientId String Client-supplied ID
    ccy String Currency, e.g. USDT
    amt String Amount to be transferred
    type String Transfer type
    0: transfer within account
    1: master account to sub-account (Only applicable to APIKey from master account)
    2: sub-account to master account (Only applicable to APIKey from master account)
    3: sub-account to master account (Only applicable to APIKey from sub-account)
    from String The remitting account
    6: Funding account 18: Unified account
    to String The beneficiary account
    6: Funding account 18: Unified account
    subAcct String Name of the sub-account
    instId String deprecated
    toInstId String deprecated
    state String Transfer state
    success, pending, failed

    Asset bills details

    Query the billing record. You can get the latest 1 month historical data.

    Rate Limit: 6 Requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/bills

    Request Example

    GET /api/v5/asset/bills
    
    GET /api/v5/asset/bills?type=1
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String No Currency
    type String No Bill type
    1: Deposit
    2: Withdrawal
    13: Canceled withdrawal
    20: Transfer to sub account
    21: Transfer from sub account
    22: Transfer out from sub to master account
    23: Transfer in from master to sub account
    37: Transfer to spot
    38: Transfer from spot
    clientId String No Client-supplied ID for transfer or withdrawal
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085
    before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [{
            "billId": "12344",
            "ccy": "BTC",
            "clientId": "",
            "balChg": "2",
            "bal": "12",
            "type": "1",
            "ts": "1597026383085"
        }]
    }
    

    Response Parameters

    Parameter Type Description
    billId String Bill ID
    ccy String Account balance currency
    clientId String Client-supplied ID for transfer or withdrawal
    balChg String Change in balance at the account level
    bal String Balance at the account level
    type String Bill type
    ts String Creation time, Unix timestamp format in milliseconds, e.g.1597026383085

    Lightning deposits

    Users can create up to 10,000 different invoices within 24 hours.

    Rate Limit: 2 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/deposit-lightning

    Request Example

    GET /api/v5/asset/deposit-lightning?ccy=BTC&amt=0.01
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String Yes Token symbol. Currently only BTC is supported.
    amt String Yes Deposit amount between 0.000001 - 0.1
    to String No Receiving account
    6: Funding account
    18: Unified account
    If empty, will default to funding account.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "cTime": "1631171307612",
                "invoice": "lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hzzdszuv6yv6yw5svctl8kc8uv6y77szv5kma2kuculj86tk3yys9qyyssqd8urqgcensh9l4zwlwr3lxlcdqrlflvvlwldutm6ljx486h7lylqmd06kky6scas7warx69sregzrx20ffmsr4sp865x3wasrjd8ttgqrlx3tr"
            }
        ],
        "msg": ""
    }
    

    Response Example

    Parameter Type Description
    invoice String Invoice text
    cTime String Invoice creation time
    This API function service is only open to some users. If you need this function service, please send an email to `[email protected]` to apply

    Get deposit address

    Retrieve the deposit addresses of currencies, including previously-used addresses.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/deposit-address

    Request Example

    GET /api/v5/asset/deposit-address?ccy=BTC
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String Yes Currency, e.g. BTC

    Response Example

    {
        "code": "0",
        "data": [
            {
                "chain": "BTC-Bitcoin",
                "ctAddr": "",
                "ccy": "BTC",
                "to": "6",
                "addr": "39XNxK1Ryqgg3Bsyn6HzoqV4Xji25pNkv6",
                "selected": true
            },
            {
                "chain": "BTC-OKC",
                "ctAddr": "",
                "ccy": "BTC",
                "to": "6",
                "addr": "0x66d0edc2e63b6b992381ee668fbcb01f20ae0428",
                "selected": true
            },
            {
                "chain": "BTC-ERC20",
                "ctAddr": "5807cf",
                "ccy": "BTC",
                "to": "6",
                "addr": "0x66d0edc2e63b6b992381ee668fbcb01f20ae0428",
                "selected": true
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    addr String Deposit address
    tag String Deposit tag (This will not be returned if the currency does not require a tag for deposit)
    memo String Deposit memo (This will not be returned if the currency does not require a payment_id for deposit)
    pmtId String Deposit payment ID (This will not be returned if the currency does not require a payment_id for deposit)
    addrEx Object Deposit address attachment (This will not be returned if the currency does not require this)
    e.g. TONCOIN attached tag name is comment, the return will be {'comment':'123456'}
    ccy String Currency, e.g. BTC
    chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
    to String The beneficiary account
    6: Funding account 18: Trading account
    selected Boolean Return true if the current deposit address is selected by the website page
    ctAddr String Last 6 digits of contract address

    Get deposit history

    Retrieve the deposit records according to the currency, deposit status, and time range in reverse chronological order. The 100 most recent records are returned by default.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/deposit-history

    Request Example

    
    GET /api/v5/asset/deposit-history
    
    Query deposit history from 2022-06-01 to 2022-07-01
    GET /api/v5/asset/deposit-history?ccy=BTC&after=1654041600000&before=1656633600000
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String No Currency, e.g. BTC
    depId String No Deposit ID
    txId String No Hash record of the deposit
    type String No Deposit Type
    3: internal transfer
    4: deposit from chain
    state String No Status of deposit
    0: waiting for confirmation
    1: deposit credited
    2: deposit successful
    8: pending due to temporary deposit suspension on this crypto currency
    12: account or deposit is frozen
    13: sub-account deposit interception
    after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1654041600000
    before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1656633600000
    limit string No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "actualDepBlkConfirm": "17",
          "amt": "135.705808",
          "ccy": "USDT",
          "chain": "USDT-TRC20",
          "depId": "34579090",
          "from": "",
          "state": "2",
          "to": "TN4hxxxxxxxxxxxizqs",
          "ts": "1655251200000",
          "txId": "16f36383292f451xxxxxxxxxxxxxxx584f3391642d988f97"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency
    chain String Chain name
    amt String Deposit amount
    from String Only the internal Okcoin account is returned, not the address on the blockchain.
    to String Deposit address
    txId String Hash record of the deposit
    ts String Time that the deposit is credited, Unix timestamp format in milliseconds, e.g. 1655251200000
    state String Status of deposit
    0: waiting for confirmation
    1: deposit credited
    2: deposit successful
    8: pending due to temporary deposit suspension on this crypto currency
    12: account or deposit is frozen
    13: sub-account deposit interception
    depId String Deposit ID
    actualDepBlkConfirm String Actual amount of blockchain confirm in a single deposit
    Waiting for confirmation is that the required number of blockchain confirmations has not been reached.
    Deposit credited is that there is sufficient number of blockchain confirmations for the currency to be credited to the account, but it cannot be withdrawn yet.
    Deposit successful means the crypto has been credited to the account and it can be withdrawn.

    Withdrawal

    Withdrawal of tokens. Sub-account does not support withdrawal.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/asset/withdrawal

    Request Example

    POST /api/v5/asset/withdrawal
    body
    {
        "amt":"1",
        "fee":"0.0005",
        "dest":"4",
        "ccy":"BTC",
        "chain":"BTC-Bitcoin",
        "toAddr":"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String Yes Currency, e.g. USD
    amt String Yes Withdrawal amount
    dest String Yes Withdrawal method
    3: internal
    4: on chain
    toAddr String Yes If your dest is 4,toAddr should be a trusted crypto currency address. Some crypto currency addresses are formatted as 'address:tag', e.g. 'ARDOR-7JF3-8F2E-QUWZ-CAN7F:123456'
    If your dest is 3,toAddr should be a recipient address which can be email, phone or login account name.
    fee String Yes Transaction fee
    chain String Conditional Chain name
    There are multiple chains under some currencies, such as USDT has USDT-ERC20, USDT-TRC20, and USDT-Omni.
    If the parameter is not filled in, the default will be the main chain.
    clientId String No Client-supplied ID
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    About tag: Some token deposits require a deposit address and a tag (e.g. Memo/Payment ID), which is a string that guarantees the uniqueness of your deposit address. Follow the deposit procedure carefully, or you may risk losing your assets.

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [{
            "amt": "0.1",
            "wdId": "67485",
            "ccy": "BTC",
            "clientId": "",
            "chain": "BTC-Bitcoin"
        }]
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency
    chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
    amt String Withdrawal amount
    wdId String Withdrawal ID
    clientId String Client-supplied ID
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

    Lightning withdrawals

    The maximum withdrawal amount is 0.1 BTC per request, and 1 BTC in 24 hours. The minimum withdrawal amount is approximately 0.000001 BTC. Sub-account does not support withdrawal.

    Rate Limit: 2 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/asset/withdrawal-lightning

    Request Example

    POST /api/v5/asset/withdrawal-lightning
    body
    {
        "ccy":"BTC",
        "invoice":"lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hz"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String Yes Token symbol. Currently only BTC is supported.
    invoice String Yes Invoice text
    memo String No Lightning withdrawal memo

    Response Example

    {
            "code": "0",
            "msg": "",
            "data": [{
                    "wdId": "121212",
                    "cTime": "1597026383085"
            }]
    }
    

    Response Parameters

    Parameter Type Description
    wdId String Withdrawal ID
    cTime String Withdrawal ID creation time
    This API function service is only open to some users. If you need this function service, please send an email to `[email protected]` to apply

    Cancel withdrawal

    You can cancel normal withdrawal requests, but you cannot cancel withdrawal requests on Lightning.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/asset/cancel-withdrawal

    Request Example

    POST /api/v5/asset/cancel-withdrawal
    body {
       "wdId":"1123456"
    }
    
    

    Request Parameters

    Parameter Type Required Description
    wdId String Yes Withdrawal ID

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "wdId": "1123456"   
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    wdId String Withdrawal ID
    If the code is equal to 0, it cannot be strictly considered that the withdrawal has been revoked. It only means that your request is accepted by the server. The actual result is subject to the status in the withdrawal history.

    Get withdrawal history

    Retrieve the withdrawal records according to the currency, withdrawal status, and time range in reverse chronological order. The 100 most recent records are returned by default.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/asset/withdrawal-history

    Request Example

    
    GET /api/v5/asset/withdrawal-history
    
    Query withdrawal history from 2022-06-01 to 2022-07-01
    GET /api/v5/asset/withdrawal-history?ccy=BTC&after=1654041600000&before=1656633600000
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String No Currency, e.g. BTC
    wdId String No Withdrawal ID
    clientId String No Client-supplied ID
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    txId String No Hash record of the deposit
    type String No Withdrawal type
    3: internal transfer
    4: withdrawal to chain
    state String No Status of withdrawal
    -3: pending cancel -2: canceled -1: failed
    0: pending 1:sending 2: sent
    3: awaiting email verification
    4: awaiting manual verification
    5: awaiting identity verification
    after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1654041600000
    before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1656633600000
    limit String No Number of results per request. The maximum is 100; The default is 100

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "chain": "ETH-Ethereum",
          "fee": "0.007",
          "ccy": "ETH",
          "clientId": "",
          "amt": "0.029809",
          "txId": "0x35c******b360a174d",
          "from": "156****359",
          "to": "0xa30d1fab********7CF18C7B6C579",
          "state": "2",
          "ts": "1655251200000",
          "wdId": "15447421"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency
    chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
    amt String Token amount
    ts String Time the withdrawal request was submitted, Unix timestamp format in milliseconds, e.g. 1655251200000.
    from String Remitting address
    User account ID will be shown for Okcoin addresses.
    to String Receiving address
    tag String Some currencies require a tag for withdrawals. This is not returned if not required.
    pmtId String Some currencies require a payment ID for withdrawals. This is not returned if not required.
    memo String Some currencies require this parameter for withdrawals. This is not returned if not required.
    addrEx Object Withdrawal address attachment (This will not be returned if the currency does not require this) e.g. TONCOIN attached tag name is comment, the return will be {'comment':'123456'}
    txId String Hash record of the withdrawal.
    This parameter will returned "" for internal transfers.
    fee String Withdrawal fee
    state String Status of withdrawal
    -3: pending cancel -2: canceled -1: failed
    0: pending 1:sending 2: sent
    3: awaiting email verification
    4: awaiting manual verification
    5: awaiting identity verification
    wdId String Withdrawal ID
    clientId String Client-supplied ID

    Account

    The API endpoints of Account require authentication.

    Get balance

    Retrieve a list of assets (with non-zero balance), remaining balance, and available amount in the trading account.

    Rate Limit: 10 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Requests

    GET /api/v5/account/balance

    Request Example

    Get the balance of all assets in the account
    GET /api/v5/account/balance
    
    Get the balance of BTC and ETH assets in the account
    GET /api/v5/account/balance?ccy=BTC,ETH
    
    
    Request Parameters
    Parameters Types Required Description
    ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "adjEq": "",
                "details": [
                    {
                        "availBal": "1.63427",
                        "availEq": "",
                        "cashBal": "1.63427",
                        "ccy": "USD",
                        "crossLiab": "",
                        "disEq": "0",
                        "eq": "1.63427",
                        "eqUsd": "1.63427",
                        "fixedBal": "0",
                        "frozenBal": "0",
                        "interest": "",
                        "isoEq": "",
                        "isoLiab": "",
                        "isoUpl": "",
                        "liab": "",
                        "maxLoan": "",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "spotInUseAmt": "",
                        "stgyEq": "0",
                        "twap": "0",
                        "uTime": "1672814264380",
                        "upl": "",
                        "uplLiab": ""
                    }
                ],
                "imr": "",
                "isoEq": "",
                "mgnRatio": "",
                "mmr": "",
                "notionalUsd": "",
                "ordFroz": "",
                "totalEq": "1.63427",
                "uTime": "1672814275772"
            }
        ],
        "msg": ""
    }
    
    Response Parameters
    Parameters Types Description
    uTime String Update time of account information, millisecond format of Unix timestamp, e.g. 1597026383085
    totalEq String Total equity in USD
    isoEq String Isolated margin equity in USD. Not enabled. Please disregard.
    adjEq String Adjusted / Effective equity in USD . Not enabled. Please disregard.
    ordFroz String Cross margin frozen for pending orders in USD. Not enabled. Please disregard.
    imr String Frozen equity for open positions and pending orders in USD. Not enabled. Please disregard.
    mmr String Maintenance margin requirement in USD. Not enabled. Please disregard.
    mgnRatio String Margin ratio in USD. Not enabled. Please disregard.
    notionalUsd String Notional value of positions in USD. Not enabled. Please disregard.
    details Array Detailed asset information in all currencies
    > ccy String Currency
    > eq String Equity of the currency
    > cashBal String Cash balance
    > uTime String Update time of currency balance information, Unix timestamp format in milliseconds, e.g. 1597026383085
    > isoEq String Isolated margin equity of the currency. Not enabled. Please disregard.
    > availEq String Available equity of the currency . Not enabled. Please disregard.
    > disEq String Discount equity of the currency in USD.
    > availBal String Available balance of the currency
    > frozenBal String Frozen balance of the currency
    > ordFrozen String Margin frozen for open orders
    > liab String Liabilities of the currency. Not enabled. Please disregard.
    > upl String Unrealized profit and loss of the currency. Not enabled. Please disregard.
    > uplLiab String Liabilities due to Unrealized loss of the currency. Not enabled. Please disregard.
    > crossLiab String Cross liabilities of the currency. Not enabled. Please disregard.
    > isoLiab String Isolated liabilities of the currency. Not enabled. Please disregard.
    > mgnRatio String Margin ratio of the currency. Not enabled. Please disregard.
    > interest String Interest of the currency. Not enabled. Please disregard.
    > twap String Risk indicator of auto liability repayment. Not enabled. Please disregard.
    > maxLoan String Max loan of the currency. Not enabled. Please disregard.
    > eqUsd String Equity in USD of the currency
    > notionalLever String Leverage of the currency. Not enabled. Please disregard.
    > stgyEq String Strategy equity
    > isoUpl String Isolated unrealized profit and loss of the currency. Not enabled. Please disregard.
    > spotInUseAmt String Spot in use amount. Not enabled. Please disregard.
    "" will be returned for inapplicable fields under the current account level.
    Information on crypto with a balance less than 1e-8 won't be included in "details".

    Distribution of applicable fields are as follows:

    Parameters Simple
    uTime Yes
    totalEq Yes
    isoEq
    adjEq
    ordFroz
    imr
    mmr
    mgnRatio
    notionalUsd
    details
    > ccy Yes
    > eq Yes
    > cashBal Yes
    > uTime Yes
    > isoEq
    > availEq
    > disEq Yes
    > availBal Yes
    > frozenBal Yes
    > ordFrozen Yes
    > liab
    > upl
    > uplLiab
    > crossLiab
    > isoLiab
    > mgnRatio
    > interest
    > twap
    > maxLoan
    > eqUsd Yes
    > notionalLever
    > stgyEq Yes
    > isoUpl

    Get bills details (last 7 days)

    Retrieve the bills of the account. The bill refers to all transaction records that result in changing the balance of an account. Pagination is supported, and the response is sorted with the most recent first. This endpoint can retrieve data from the last 7 days.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/bills

    Request Example

    GET /api/v5/account/bills
    

    Request Parameters

    Parameter Type Required Description
    instType String No Instrument type
    SPOT
    ccy String No Bill currency
    type String No Bill type
    1: Transfer 2: Trade
    subType String No Bill subtype
    1: Buy 2: Sell 11: Transfer in 12: Transfer out
    after String No Pagination of data to return records earlier than the requested bill ID.
    before String No Pagination of data to return records newer than the requested bill ID.
    begin String No Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    end String No Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "bal": "1.63093282565",
                "balChg": "1.63093282565",
                "billId": "530758662684151809",
                "ccy": "USD",
                "execType": "T",
                "fee": "-0.00245007435",
                "from": "",
                "instId": "USDT-USD",
                "instType": "SPOT",
                "mgnMode": "cash",
                "notes": "",
                "ordId": "530758662663180288",
                "pnl": "0",
                "posBal": "0",
                "posBalChg": "0",
                "subType": "1",
                "sz": "1.6333829",
                "to": "",
                "ts": "1672814726203",
                "type": "2"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    billId String Bill ID
    type String Bill type
    subType String Bill subtype
    ts String Creation time, Unix timestamp format in milliseconds, e.g.1597026383085
    balChg String Change in balance amount at the account level
    posBalChg String Change in balance amount at the position level. Not enabled. Please disregard.
    bal String Balance at the account level
    posBal String Balance at the position level. Not enabled. Please disregard.
    sz String Quantity
    ccy String Account balance currency
    pnl String Profit and loss. Not enabled. Please disregard.
    fee String Fee
    Negative number represents the user transaction fee charged by the platform.
    Positive number represents rebate.
    mgnMode String Margin mode. Not enabled. Please disregard.
    instId String Instrument ID, e.g. BTC-USD
    ordId String Order ID
    When bill type is not trade, the field returns ""
    execType String Liquidity taker or maker, T:taker M:maker
    from String The remitting account
    6: FUNDING 18: Trading account
    Only applicable to transfer. When bill type is not transfer, the field returns "".
    to String The beneficiary account
    6: FUNDING 18: Trading account
    Only applicable to transfer. When bill type is not transfer, the field returns "".
    notes String Notes
    Only applicable to transfer. When bill type is not transfer, the field returns "".

    Get bills details (last 3 months)

    Retrieve the account’s bills. The bill refers to all transaction records that result in changing the balance of an account. Pagination is supported, and the response is sorted with most recent first. This endpoint can retrieve data from the last 3 months.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/bills-archive

    Request Example

    GET /api/v5/account/bills-archive
    

    Request Parameters

    Parameter Type Required Description
    instType String No Instrument type
    SPOT
    ccy String No Bill currency
    type String No Bill type
    1: Transfer 2: Trade
    subType String No Bill subtype
    1: Buy 2: Sell 11: Transfer in 12: Transfer out
    after String No Pagination of data to return records earlier than the requested bill ID.
    before String No Pagination of data to return records newer than the requested bill ID.
    begin String No Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    end String No Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "bal": "1.63093282565",
                "balChg": "1.63093282565",
                "billId": "530758662684151809",
                "ccy": "USD",
                "execType": "T",
                "fee": "-0.00245007435",
                "from": "",
                "instId": "USDT-USD",
                "instType": "SPOT",
                "mgnMode": "cash",
                "notes": "",
                "ordId": "530758662663180288",
                "pnl": "0",
                "posBal": "0",
                "posBalChg": "0",
                "subType": "1",
                "sz": "1.6333829",
                "to": "",
                "ts": "1672814726203",
                "type": "2"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    billId String Bill ID
    type String Bill type
    subType String Bill subtype
    ts String Creation time, Unix timestamp format in milliseconds, e.g.1597026383085
    balChg String Change in balance amount at the account level
    posBalChg String Change in balance amount at the position level. Not enabled. Please disregard.
    bal String Balance at the account level
    posBal String Balance at the position level. Not enabled. Please disregard.
    sz String Quantity
    ccy String Account balance currency
    pnl String Profit and loss. Not enabled. Please disregard.
    fee String Fee
    Negative number represents the user transaction fee charged by the platform.
    Positive number represents rebate.
    mgnMode String Margin mode. Not enabled. Please disregard.
    instId String Instrument ID, e.g. BTC-USD
    ordId String Order ID
    When bill type is not trade, the field returns ""
    execType String Liquidity taker or maker, T:taker M:maker
    from String The remitting account
    6: FUNDING 18: Trading account
    Only applicable to transfer. When bill type is not transfer, the field returns "".
    to String The beneficiary account
    6: FUNDING 18: Trading account
    Only applicable to transfer. When bill type is not transfer, the field returns "".
    notes String Notes
    Only applicable to transfer. When bill type is not transfer, the field returns "".

    Get account configuration

    Retrieve current account configuration.

    Rate Limit: 5 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/config

    Request Example

    GET /api/v5/account/config
    
    

    Request Parameters

    none

    Response Example

    {
        "code": "0",
        "data": [
            {
                "acctLv": "1",
                "autoLoan": false,
                "ctIsoMode": "automatic",
                "greeksType": "PA",
                "level": "Lv1",
                "levelTmp": "",
                "mgnIsoMode": "automatic",
                "posMode": "net_mode",
                "spotOffsetType": "",
                "uid": "1300041872592896"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    uid String Account ID
    acctLv String Account level
    1: Simple
    posMode String Position mode. Not enabled. Please disregard.
    autoLoan Boolean Whether to borrow coins automatically. Not enabled. Please disregard.
    greeksType String Current display type of Greeks. Not enabled. Please disregard.
    level String The user level of the current real trading volume on the platform, e.g Lv1
    levelTmp String Temporary experience user level of special users. Not enabled. Please disregard.
    ctIsoMode String Contract isolated margin trading settings. Not enabled. Please disregard.
    mgnIsoMode String Margin isolated margin trading settings. Not enabled. Please disregard.
    spotOffsetType String Risk offset type. Not enabled. Please disregard.

    The following table is the relation between the level value and tier displayed on the website

    level value Tier displayed on the website
    Lv1~Lv5 P0
    VIP1 P1
    VIP2 P2
    VIP3 P3
    VIP4 P4
    VIP5 P5
    VIP6 P6
    VIP7 P7
    VIP8 P8
    VIP9 P9
    VIP10 P10

    Get maximum buy/sell amount or open amount

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/max-size

    Request Example

    GET /api/v5/account/max-size?instId=BTC-USD&tdMode=cash
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Single instrument or multiple instruments (no more than 5) separated with comma, e.g. BTC-USD
    tdMode String Yes Trade mode cash
    px String No Price
    When the price is not specified, it will be calculated according to the last traded price.
    The parameter will be ignored when multiple instruments are specified.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "ccy": "",
                "instId": "BTC-USD",
                "maxBuy": "0.0000965776484683",
                "maxSell": "0"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instId String Instrument ID
    ccy String Currency used for margin. Not enabled. Please disregard.
    maxBuy String SPOT: The maximum quantity in base currency that you can buy
    maxSell String SPOT: The maximum quantity in quote currency that you can sell

    Get maximum available tradable amount

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/max-avail-size

    Request Example

    GET /api/v5/account/max-avail-size?instId=BTC-USD&tdMode=cash
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Single instrument or multiple instruments (no more than 5) separated with comma, e.g. BTC-USDT,ETH-USDT
    tdMode String Yes Trade mode cash

    Response Example

    {
        "code": "0",
        "data": [
            {
                "availBuy": "1.63093282565",
                "availSell": "0",
                "instId": "BTC-USD"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instId String Instrument ID
    availBuy String Amount available to buy
    availSell String Amount available to sell
    In the case of SPOT, availBuy is in the quote currency, and availSell is in the base currency.

    Get fee rates

    Rate Limit: 5 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/trade-fee

    Request Example

    GET /api/v5/account/trade-fee?instType=SPOT
    

    Request Parameters

    Parameter Type Required Description
    instType String Yes Instrument type
    SPOT
    instId String No Instrument ID, e.g. BTC-USDT

    Response Example

    {
        "code": "0",
        "data": [
            {
                "category": "1",
                "delivery": "",
                "exercise": "",
                "instType": "SPOT",
                "level": "Lv1",
                "maker": "-0.001",
                "makerU": "",
                "makerUSDC": "-0.001",
                "taker": "-0.0015",
                "takerU": "",
                "takerUSDC": "-0.0015",
                "ts": "1672825392244"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    level String Fee rate Level
    taker String Taker fee rate
    maker String Maker fee rate
    takerU String Taker fee rate of USDT-margined contracts. Not enabled. Please disregard.
    makerU String Maker fee rate of USDT-margined contracts. Not enabled. Please disregard.
    delivery String Delivery fee rate. Not enabled. Please disregard.
    exercise String Fee rate for exercising the option. Not enabled. Please disregard.
    instType String Instrument type
    takerUSDC String Taker fee rate for the USDC trading pairs. Not enabled. Please disregard.
    makerUSDC String Maker fee rate for the USDC trading pairs. Not enabled. Please disregard.
    ts String Data return time, Unix timestamp format in milliseconds, e.g. 1597026383085
    category String Currency category. Note: this parameter is already deprecated
    Remarks:
    The value of maker/taker: positive number, which means the rate of rebate; negative number, which means the rate of commission.

    The following table is the relation between the level value and tier displayed on the website

    level value Tier displayed on the website
    Lv1~Lv5 P0
    VIP1 P1
    VIP2 P2
    VIP3 P3
    VIP4 P4
    VIP5 P5
    VIP6 P6
    VIP7 P7
    VIP8 P8
    VIP9 P9
    VIP10 P10

    Get maximum withdrawals

    Retrieve the maximum transferable amount from trading account to funding account. If no currency is specified, the transferable amount of all owned currencies will be returned.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/account/max-withdrawal

    Request Example

    GET /api/v5/account/max-withdrawal
    
    

    Request Parameters

    Parameter Type Required Description
    ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

    Response Example

    {
        "code": "0",
        "data": [
            {
                "ccy": "USD",
                "maxWd": "1.63093282565",
                "maxWdEx": "",
                "spotOffsetMaxWd": "",
                "spotOffsetMaxWdEx": ""
            },
            {
                "ccy": "USDT",
                "maxWd": "0.00007",
                "maxWdEx": "",
                "spotOffsetMaxWd": "",
                "spotOffsetMaxWdEx": ""
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    ccy String Currency
    maxWd String Max withdrawal
    maxWdEx String Max withdrawal (including borrowed assets under Multi-currency margin). Not enabled. Please disregard.
    spotOffsetMaxWd String Max withdrawal under Spot-Derivatives risk offset mode (excluding borrowed assets under Portfolio margin). Not enabled. Please disregard.
    spotOffsetMaxWdEx String Max withdrawal under Spot-Derivatives risk offset mode (including borrowed assets under Portfolio margin). Not enabled. Please disregard.

    OTC-Desk RFQ

    Available Pairs

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/otc/rfq/instruments

    Request Example

    GET /api/v5/otc/rfq/instruments
    
    

    Request Parameters

    None

    Response Example

    {
        "code": "0",
        "data": [
            {
                "instruments": [
                    {
                        "baseCcy": "BTC",
                        "baseCcyIcon": "https://static.coinall.ltd/cdn/oksupport/asset/currency/icon/btc.png",
                        "baseSingleMin": "0.257",
                        "instId": "BTC-USD",
                        "quoteCcy": "USD",
                        "quoteCcyIcon": "https://static.coinall.ltd/cdn/assets/imgs/218/7775D0B35AA6AF73.png",
                        "quoteSingleMin": "10000"
                    }
                ],
                "ts": "1623727445510"
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameters Parameters types Description
    ts String Data update time Unix timestamp in milliseconds, such as: 1597026383085
    instruments Array List of token pairs for trading
    >instId String Trading pair
    >baseCcy String Base currency, such as BTC in BTC-USD, BTC in BTC-USDT
    >baseSingleMin String Minimium tradable amount for base currency
    >baseCcyIcon String Icon link for base currency
    >quoteCcy String Quote currency, such as USD in BTC-USD, USDT in BTC-USDT
    >quoteSingleMin String Minimium tradable amount for quote currency
    >quoteCcyIcon String Icon link for quote currency

    Request Quote

    Query current market quotation information

    Rate Limit: 3 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/otc/rfq/quote

    Request Example

    POST /api/v5/otc/rfq/quote
    body
    {
        "baseCcy": "BTC",
        "quoteCcy": "USD",
        "side": "sell",
        "rfqSz": "1000",
        "rfqSzCcy": "USD"
    }
    
    

    Request Parameters

    Parameters Parameters types Required Description
    baseCcy String Yes Base currency, such as BTC in BTC-USD
    quoteCcy String Yes Quote currency, such as USD in BTC-USD
    side String Yes Side buy:buy sell:sell Buy & sell: two_way
    From the perspective of a customer, it describes the transaction side of baseCcy
    rfqSz String Yes Amount
    rfqSzCcy String Yes Token
    clQReqId String No Client-defined quote request ID, order id, with only length limitation
    clQReqTs String No Client rfq sending time, Unix timestamp in milliseconds.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         {
            "quoteTs":"1597026383085",
            "ttlMs":"1000",
            "clQReqId":"6666",
            "quoteId":"123133",
            "baseCcy":"BTC",
            "quoteCcy":"USDT",
            "side":"buy",
            "origRfqSz":"0.55",
            "rfqSz":"0.5",
            "rfqSzCcy":"BTC",
            "bidPx":"10790",
            "bidBaseSz":"0.5",
            "bidQuoteSz":"5395",
            "askPx":"10800",
            "askBaseSz":"54000",
            "askQuoteSz":"5"
        }
      ]
    }
    
    

    Response Parameters

    Parameters Parameters types Description
    quoteTs String Time of quote generation, Unix timestamp in milliseconds
    ttlMs String Time to expiry for the quote in milliseconds
    clQReqId String Client-defined quote request ID
    quoteId String Quote ID, as the input in a transaction request
    baseCcy String Base currency, such as BTC in BTC-USDT
    quoteCcy String Quote currency, such as USDT in BTC-USDT
    side String Side buy:buy sell:sell Buy & sell: two_way
    origRfqSz String Original amount
    rfqSz String Amount can be quoted
    rfqSzCcy String Token can be quoted
    bidPx String Bid price
    bidBaseSz String The amount of baseCcy that a customer may need to pay. This field is only valid when the quotation request is Sell or TwoWay
    bidQuoteSz String The amount of quoteCcy that a customer may obtain. This field is only valid when the quotation request is Sell or TwoWay
    askPx String Ask price
    askBaseSz String The amount of baseCcy that a customer may obtain. This field is only valid when the quotation request is Buy or TwoWay
    askQuoteSz String The amount of quoteCcy that a customer may need to pay. This field is only valid when the quotation request is Buy or TwoWay

    Place Order

    Rate Limit: 3 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/otc/rfq/trade

    Request Example

    POST /api/v5/otc/rfq/trade
    body
    {
        "clTReqId": "5111",
        "quoteId": "12638308",
        "baseCcy": "BTC",
        "quoteCcy": "USD",
        "side": "buy",
        "Sz": "2",
        "szCcy": "BTC"
    }
    

    Request Parameters

    Parameters Parameters types Required Description
    clTReqId String Yes Client-defined trade request ID
    clTReqTs String No Client rfq sending time, Unix timestamp in milliseconds
    quoteId String Yes Quotation number returned by quotation query.
    baseCcy String Yes Base currency, such as BTC in BTC-USD
    quoteCcy String Yes Quote currency, such as USD in BTC-USD
    side String Yes Side buy:buy sell:sell
    sz String Yes Amount
    szCcy String Yes Token

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         {
            "ts":"1597026383085",
            "tradeId":"159",
            "quoteId":"126383085",
            "clTReqId":"5111",
            "state":"live",
            "instId":"BTC-USDT",
            "baseCcy":"BTC",
            "quoteCcy":"USDT",
            "side":"buy",
            "px":"0.55",
            "filledBaseSz":"",
            "filledTermSz":"1"
        }
      ]
    }
    

    Response Parameters

    Parameters Parameters types Description
    ts String Unix timestamp in milliseconds
    tradeId String Transaction ID
    quoteId String Quotation ID returned by quotation query
    clTReqId String User-defined ID
    state String Order status,
    PendingNew: the transaction has been created
    FullyFilled: the order is completely filled
    Rejected: the transaction is rejected
    instId String Trading pair
    baseCcy String Base currency, such as BTC in BTC-USDT
    quoteCcy String Quote currency, such as USDT in BTC-USDT
    side String Side buy:buy sell:sell
    px String Price
    filledBaseSz String Size of order
    filledQuoteSz String Size of order

    Order Details

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/otc/rfq/trade

    Request Example

    GET/api/v5/otc/rfq/trade?tradeId=134
    
    

    Request Parameters

    Parameters Parameters types Required Description
    clTReqId String Optional Client-defined trade request ID
    tradeId String Optional Order ID. One of clTReqId and tradeId must be filled in. If the user passes both values, only the tradeId parameter will be checked.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         {
            "ts":"1597026383085",
            "tradeId":"159",
            "quoteId":"126383085",
            "clTReqId":"5111",
            "state":"FullyFilled",
            "instId":"BTC-USDT",
            "baseCcy":"BTC",
            "quoteCcy":"USDT",
            "side":"buy",
            "px":"0.55",
            "filledBaseSz":"",
            "filledTermSz":"1"
        }
      ]
    }
    

    Response Parameters

    Parameters Parameters types Description
    ts String Unix timestamp in milliseconds
    tradeId String Transaction ID
    quoteId String Quotation ID returned by quotation query
    clTReqId String User-defined ID
    state String Order status,
    PendingNew: the transaction has been created
    FullyFilled: the order is completely filled
    Rejected: the transaction is rejected
    instId String Trading pair
    baseCcy String Base currency, such as BTC in BTC-USDT
    quoteCcy String Quote currency, such as USDT in BTC-USDT
    side String Side buy:buy sell:sell
    px String Trading price
    filledBaseSz String Size of order
    filledQuoteSz String Size of order

    Order History

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/otc/rfq/history

    Request Example

    GET /api/v5/otc/rfq/history
    
    

    Request Parameters

    Parameters Parameters types Required Description
    begin String No Start of trading time, Unix timestamp in milliseconds
    end String No End of trading time, Unix timestamp in milliseconds.
    pageSz String No Returned quantity per page, default 100
    pageIdx String No Which page does it currently belong to, the default value is 0

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "ts":"1597026383085",
                "pageIdx":"1",
                "totalPageCnt":"160",
                "totalRecordCnt":"1590",
                "trades":[
                    {
                        "ts":"1597026383085",
                        "tradeTs":"1597026383085",
                        "tradeId":"13085",
                        "clTReqId":"",
                        "instId":"BTC-USDT",
                        "side":"buy",
                        "px":"3085",
                        "baseCcy":"BTC",
                        "baseSz":"85",
                        "quoteCcy":"USD",
                        "quoteSz":"38"
                    },
                     {
                        "ts":"1597026383085",
                        "tradeTs":"1597026383085",
                        "tradeId":"13085",
                        "clTReqId":"",
                        "instId":"BTC-USDT",
                        "side":"buy",
                        "px":"3085",
                        "baseCcy":"BTC",
                        "baseSz":"85",
                        "quoteCcy":"USD",
                        "quoteSz":"38"
                    }
                ]
            }
        ]
    }
    

    Response Parameters

    Parameters Parameters types Description
    ts String Unix timestamp in milliseconds
    pageIdx String Which page does it currently belong to, the default value is 0
    totalPageCnt String Pages in total
    totalRecordCnt String Items in total
    trades Array Transaction history list
    >ts String Record generation time, Unix timestamp in milliseconds
    >tradeTs String Transaction ID
    >tradeId String Client-defined ID
    >clTReqId String Amount can be quoted
    >instId String Trading pair
    >side String Side buy: buy sell: sell
    >px String Price
    >baseCcy String Base currency, such as BTC in BTC-USDT
    >baseSz String Amount of base currency
    >quoteCcy String Quote currency, such as USDT in BTC-USDT
    >quoteSz String Amount of quote currency

    Fiat

    Start with a whitelisted Prime Trust or Silvergate account linked to an open Okcoin account.

    Deposit

    Use GET and POST endpoints to make deposits with PrimeX and SEN to OKCoin accounts.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/fiat/deposit

    Request Example

    POST /api/v5/fiat/deposit
    body {
        "chanId": "3",
        "bankAcctNum": "hahawang",
        "amt": "10"
    }
    

    Request Parameters

    Parameter Type Required Description
    chanId String Yes Channel ID.
    9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK; 24:ACH
    amt String Yes Amount to deposit
    bankAcctNum String Yes The number of the account linked to the channel. Use GET v5/fiat/channel to get the number, or input it manually.
    to String No Amount to deposit. Recharge to the account: funding:Funding Account

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "depId": "1123456",   
          "cTime": "1637566660769"   
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    depId String The order number of the transaction
    cTime String When the request was created

    Cancel deposit

    You can cancel a pending deposit request.

    Rate Limit: 100 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/fiat/cancel-deposit

    Request Example

    POST /api/v5/fiat/cancel-deposit
    body {
        "depId": "02007131856581300"
    }
    

    Request Parameters

    Parameter Type Required Description
    depId String Yes The order number of the transaction to be canceled

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "depId": "1123456" 
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    depId String The order number of the transaction

    Get deposit history

    Deposit history query requests can be filtered by the different elements, such as channels, deposit status, and currencies. Paging is also available during query and is stored in reverse order based on the transaction time, with the latest one at the top.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET api/v5/fiat/deposit-history

    Request Example

    GET api/v5/fiat/deposit-history?after=1515&chanId=3&status=0
    

    Request Parameters

    Parameter Type Required Description
    chanId String No Channel ID used in the transaction.
    9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK; 24:ACH
    ccy String No What currency the deposit was made in. USD EUR SGD
    state String No Deposit state.
    -2:User canceled the order;-1:Deposit attempt has failed; 0:Deposit request submitted; 1:Deposit request is pending; 2:Deposit has been credited
    depId String No Deposit ID used in the transaction
    after String No If requesting the page content (previous data) prior to this ID, the value given will be the billId of the corresponding interface.
    before String No If requesting the page content (updated data) followed by this ID, the value given will be the billId of the corresponding interfac
    limit String No The maximum number of result sets returned by paginations is 100, if not filled in, 100 will be returned by default.

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "depId": "02007131618204007",
          "chanId": "3",
          "billId": "1513",
          "bankAcctName": "qiang wang",
          "bankAcctNum": "hahawang",
          "amt": "10",
          "state": "0",
          "ccy": "USD",
          "cTime": "1637566660769",
          "uTime": "1637566660770"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    depId String Deposit ID used in the transaction
    chanId String Channel ID used in the transaction
    billId String Ledger ID for pagination
    bankAcctName String The account name used in the transaction
    bankAcctNum String The account number used in the transaction
    amt String Amount deposited
    state String Deposit state.
    -2:User canceled the order;-1:Deposit attempt has failed; 0:Deposit request submitted; 1:Deposit request is pending; 2:Deposit has been credited
    ccy String What currency the deposit was made in - USD, EUR, SGD
    cTime String When the request was created, e.g.1637566660769
    uTime String When the request was last updated, e.g.1637566660770

    Withdrawal

    Use GET and POST endpoints to make deposits with PrimeX and SEN to OKCoin accounts.

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/fiat/withdrawal

    Request Example

    POST /api/v5/fiat/withdrawal
    body {
        "chanId": "3",
        "bankAcctNum": "hahawang",
        "amt": "10"
    }
    

    Request Parameters

    Parameter Type Required Description
    chanId String Yes Channel ID.
    9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK
    amt String Yes Amount to withdraw
    bankAcctNum String Yes The number of the account linked to the channel. Use GET v5/fiat/channel to get the number, or input it manually.

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "depId": "1123456",   
          "fee": "0",   
          "cTime": "1637566660769"   
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    wdId String The order number of the transaction
    cTime String When the request was created, e.g.1637566660769
    fee String Cost of making the withdrawal

    Cancel withdrawal

    You can cancel a pending withdrawal request.

    Rate Limit: 100 requests per 2 seconds

    Rate limit rule: UserID

    HTTP Request

    POST /api/v5/fiat/cancel-withdrawal

    Request Example

    POST /api/v5/fiat/cancel-withdrawal
    body {
        "wdId": "12007131909122084"
    }
    

    Request Parameters

    Parameter Type Required Description
    wdId String Yes The order number of the transaction

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "wdId": "12007131909122084"   
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    wdId String The order number of the transaction

    Get withdrawal history

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/fiat/withdrawal-history

    Request Example

    GET /api/v5/fiat/withdrawal-history?before=360&chanId=3
    

    Request Parameters

    Parameter Type Required Description
    chanId String No Channel ID used in the transaction.
    9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK
    ccy String No What currency the withdrawal was made in. USD EUR SGD
    state String No Withdrawal state.
    -2:User canceled the order;-1:Withdrawal attempt has failed; 0:Withdrawal request submitted; 1:Withdrawal request is pending; 2:Withdrawal has been credited
    wdId String No Withdrawal request ID. Same as the ID on the withdrawal history page.
    after String No If requesting the page content (previous data) prior to this ID, the value given will be the billId of the corresponding interface.
    before String No If requesting the page content (updated data) followed by this ID, the value given will be the billId of the corresponding interfac
    limit String No The maximum number of result sets returned by paginations is 100, if not filled in, 100 will be returned by default.

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "wdId": "02007131618204007",
          "chanId": "3",
          "billId": "1513",
          "bankAcctName": "qiang wang",
          "bankAcctNum": "hahawang",
          "amt": "10",
          "fee": "0",
          "state": "0",
          "ccy": "USD",
          "cTime": "1637566660769",
          "uTime": "1637566660770"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    wdId String The order number of the transaction
    chanId String Channel ID used in the transaction
    billId String Ledger ID for pagination
    bankAcctName String The account name used in the transaction
    bankAcctNum String The account number used in the transaction
    amt String Amount withdrawed
    fee String Cost of making the withdrawal
    state String Withdrawal state.
    -2:User canceled the order;-1:Withdrawal attempt has failed; 0:Withdrawal request submitted; 1:Withdrawal request is pending; 2:Withdrawal has been credited
    ccy String What currency the withdrawal was made in - USD, EUR, SGD
    cTime String When the request was created, e.g.1637566660769
    uTime String When the request was last updated, e.g.1637566660770

    Get channel info

    Rate Limit: 6 requests per second

    Rate limit rule: UserID

    HTTP Request

    GET /api/v5/fiat/channel

    Request Example

    GET /api/v5/fiat/channel
    

    Request Parameters

    Parameter Type Required Description
    chanId String No Channel ID used in the transaction.
    9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK; 24:ACH

    Response Example

    {
      "code": "0",
      "msg": "",
      "data": [
        {
          "chanId": "3",
          "ccy": "USD",
          "depQuota": "999999999",
          "minDep": "1",
          "wdQuota": "4000000",
          "minWd": "1",
          "usedWdQuota": "0",
          "validWdQuota": "4000000",
          "bankAcctInfo": [
            {
                "bankAcctName": "CASHBACK DEBIT",
                "bankAcctNum": "CASHBACK DEBIT-1234",
                "instName": "Discover",
                "maskAcctNum": "1234"
            }
          ]
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    chanId String Channel ID
    ccy String Currency type(Selectable fields:USD, EUR, SGD)
    depQuota String Daily(in the past 24 hours) max deposit unit
    minDep String Minimum deposit unit per transaction
    wdQuota String Daily(in the past 24 hours) withdrawal limit
    minWd String Minimum withdraw amount per transaction
    usedWdQuota String Amount that’s been withdrawn against the daily limit(in the past 24 hours)
    validWdQuota String Amount that can be withdrawn in 1 day(in the past 24 hours)
    bankAcctInfo String Linked bank accounts list. One payment channel can be linked to multiple bank accounts.
    > bankAcctName String bank account name
    > bankAcctNum String bank account number
    > instName String Institution name
    > maskAcctNum String mask account number

    SubAccount

    The API endpoints of SubAccount require authentication.

    View sub-account list

    Applies to master accounts only

    Rate limit:2 requests per 2 seconds

    Rate limit rule: UserID

    HTTP request

    GET /api/v5/users/subaccount/list

    Request sample

    GET /api/v5/users/subaccount/list
    
    

    Request parameters

    Parameter Type Required Description
    enable String No Sub-account status, true: Normal ; false: Frozen
    subAcct String No Sub-account name
    after String No If you query the data prior to the requested creation time ID, the value will be a Unix timestamp in millisecond format.
    before String No If you query the data after the requested creation time ID, the value will be a Unix timestamp in millisecond format.
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Returned results

    {
        "code":"0",
        "msg":"",
        "data":[
                       {
                          "enable":true,
                          "subAcct":"test-1",
                          "type":"1",
                          "label":"trade futures",
                          "mobile":"1818181",
                          "gAuth":true,
                          "canTransOut": true,
                          "ts":"1597026383085"
                       },
                       {
                          "enable":false,
                          "type":"1",
                          "subAcct":"test-2",
                          "label":"trade spot",
                          "mobile":"1818199",
                          "gAuth":true,
                          "canTransOut": false,
                          "ts":"1597026383082"
                       }
    
        ]
    }
    

    Response parameters

    Parameter name Type Description
    type String Sub-account type 1:Standard sub-account 2:Custody trading sub-account
    enable Boolean Sub-account status true: Normal ; false:Frozen
    subAcct String Sub-account name
    label String Sub-account note
    mobile String Mobile number that linked with the sub-account.
    gAuth Boolean If the sub-account switches on the Google Authenticator for login authentication. true: On ; false: Off
    canTransOut Boolean Whether the sub-account has the right to transfer out.
    false: cannot transfer out
    true: can transfer
    . Not enabled. Please disregard.
    ts String Sub-account creation time, Unix timestamp in millisecond format. e.g. 1597026383085

    Query the APIKey of a sub-account

    Applies to master accounts only

    Rate limit:1 request per second

    Rate limit rule: UserID

    HTTP request

    GET /api/v5/users/subaccount/apikey

    Request sample

    Get /api/v5/users/subaccount/apikey?subAcct=panpanBroker2
    

    Request parameters

    Parameter Type Required Description
    subAcct String Yes Sub-account name
    apiKey String No API public key

    Returned results

        "code":"0",
        "msg":"",
        "data":[
            {
                "label":"v5",
                "apiKey":"arg13sdfgs",
                "perm":"read_only,trade",
                "ip":"1.1.1.1,2.2.2.2",
                "ts":"1597026383085"
            },
            {
                "label":"v5.1",
                "apiKey":"arg13sdfgs",
                "perm":"read_only",
                "ip":"1.1.1.1,2.2.2.2",
                "ts":"1597026383085"
            }
        ]
    }
    

    Response parameters

    Parameter name Type Description
    label String APIKey note
    apiKey String API public key
    perm String APIKey access read_only:Read only ;trade :Trade
    ip String IP address that linked with APIKey
    ts String Creation time

    Get sub-account trading balance

    Query detailed balance info of Trading Account of a sub-account via the master account (applies to master accounts only)

    Rate limit:2 requests per 2 seconds

    Rate limit rule: UserID

    HTTP request

    GET /api/v5/account/subaccount/balances

    Request sample

    GET /api/v5/account/subaccount/balances?subAcct=test1
    
    

    Request parameters

    Parameter Type Required Description
    subAcct String Yes Sub-account name

    Returned result

    {
        "code": "0",
        "data": [
            {
                "adjEq": "10679688.0460531643092577",
                "details": [
                    {
                        "availBal": "",
                        "availEq": "9930359.9998",
                        "cashBal": "9930359.9998",
                        "ccy": "USDT",
                        "crossLiab": "0",
                        "disEq": "9439737.0772999514",
                        "eq": "9930359.9998",
                        "eqUsd": "9933041.196999946",
                        "frozenBal": "0",
                        "interest": "0",
                        "isoEq": "0",
                        "isoLiab": "0",
                        "liab": "0",
                        "maxLoan": "10000",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "twap": "0",
                        "uTime": "1620722938250",
                        "upl": "0",
                        "uplLiab": "0"
                    },
                    {
                        "availBal": "",
                        "availEq": "33.6799714158199414",
                        "cashBal": "33.2009985",
                        "ccy": "BTC",
                        "crossLiab": "0",
                        "disEq": "1239950.9687532129092577",
                        "eq": "33.771820625136023",
                        "eqUsd": "1239950.9687532129092577",
                        "frozenBal": "0.0918492093160816",
                        "interest": "0",
                        "isoEq": "0",
                        "isoLiab": "0",
                        "liab": "0",
                        "maxLoan": "1453.92289531493594",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "twap": "0",
                        "uTime": "1620722938250",
                        "upl": "0.570822125136023",
                        "uplLiab": "0"
                    }
                ],
                "imr": "3372.2942371050594217",
                "isoEq": "0",
                "mgnRatio": "70375.35408747017",
                "mmr": "134.8917694842024",
                "notionalUsd": "33722.9423710505978888",
                "ordFroz": "0",
                "totalEq": "11172992.1657531589092577",
                "uTime": "1623392334718"
            }
        ],
        "msg": ""
    }
    

    Response parameters

    Parameters Types Description
    uTime String The latest time to get account information, millisecond format of Unix timestamp, e.g. 1597026383085
    totalEq String Total equity in USD
    isoEq String Isolated margin equity in USD. Not enabled. Please disregard.
    adjEq String Adjusted / Effective equity in USD. Not enabled. Please disregard.
    ordFroz String Margin frozen for pending cross orders in USD. Not enabled. Please disregard.
    imr String Frozen equity for open positions and pending orders in USD. Not enabled. Please disregard.
    mmr String Maintenance margin requirement in USD. Not enabled. Please disregard.
    mgnRatio String Margin ratio in USD. Not enabled. Please disregard.
    notionalUsd String Notional value of positions in USD. Not enabled. Please disregard.
    details Array Detailed asset information in all currencies
    > ccy String Currency
    > eq String Equity of the currency
    > cashBal String Cash Balance
    > uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    > isoEq String Isolated margin equity of the currency. Not enabled. Please disregard.
    > availEq String Available equity of the currency. Not enabled. Please disregard.
    > disEq String Discount equity of the currency in USD
    > availBal String Available balance of the currency
    > frozenBal String Frozen balance of the currency
    > ordFrozen String Margin frozen for open orders
    > liab String Liabilities of the currency. Not enabled. Please disregard.
    > upl String Unrealized profit and loss of the currency. Not enabled. Please disregard.
    > uplLiab String Liabilities due to Unrealized loss of the currency. Not enabled. Please disregard.
    > crossLiab String Cross Liabilities of the currency. Not enabled. Please disregard.
    > isoLiab String Isolated Liabilities of the currency. Not enabled. Please disregard.
    > mgnRatio String Margin ratio of the currency. Not enabled. Please disregard.
    > interest String Interest of the currency. Not enabled. Please disregard.
    > twap String System's forced repayment(TWAP) indicator. Not enabled. Please disregard.
    > maxLoan String Max loan of the currency. Not enabled. Please disregard.
    > eqUsd String Equity usd of the currency
    > notionalLever String Leverage of the currency. Not enabled. Please disregard.
    "" will be returned for inapplicable fields with the current account level.

    Get sub-account funding balance

    Query detailed balance info of Funding Account of a sub-account via the master account (applies to master accounts only)

    Rate limit:2 requests per 2 seconds

    Rate limit rule: UserID

    HTTP request

    GET /api/v5/asset/subaccount/balances

    Request sample

    GET/api/v5/asset/subaccount/balances?subAcct=test1
    
    

    Request parameters

    Parameter Type Required Description
    subAcct String Yes Sub-account name
    ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

    Returned result

    {
        "code": "0",
        "msg": "",
        "data": [{
                "availBal": "37.11827078",
                "bal": "37.11827078",
                "ccy": "ETH",
                "frozenBal": "0"
            }
        ]
    }
    

    Response parameters

    Parameter Type Description
    ccy String Currency
    bal String Balance
    frozenBal String Frozen balance
    availBal String Available balance

    History of sub-account transfer

    Applies to master accounts only.
    Retrieve the transfer data for the last 3 months.

    Rate limit:6 requests per second

    Rate limit rule: UserID

    HTTP request

    GET /api/v5/asset/subaccount/bills

    Request sample

    GET /api/v5/asset/subaccount/bills
    

    Request parameters

    Parameter Type Required Description
    ccy String No Currency, such as BTC
    type String No 0: Transfers from master account to sub-account ;1 : Transfers from sub-account to master account.
    subAcct String No Sub-account name
    after String No If you query the data prior to the requested bill ID, the value will be a Unix timestamp in millisecond format.
    before String No If you query the data after the requested bill ID, the value will be a Unix timestamp in millisecond format.
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Returned results

    {
        "code": "0",
        "msg": "",
        "data": [{
                    "billId": "12344",
                    "type":"1",
                    "ccy": "BTC",
                    "amt":"2",
                    "subAcct":"test-1",
                    "ts":"1597026383085"
        }]
    }
    

    Response parameters

    Parameter name Type Description
    billId String Bill ID
    ccy String Account balance currency
    amt String Transfer amount
    type String Bill type
    subAcct String Sub-account name
    ts String Sub-account creation time with Unix timestamp in millisecond format,1597026383085 e.g., 1597026383085

    Master accounts manage the transfers between sub-accounts

    Applies to master accounts only

    Rate limit:1 request per second

    Rate limit rule: UserID

    HTTP request

    POST /api/v5/asset/subaccount/transfer

    Request sample

    POST /api/v5/asset/subaccount/transfer
    body
    {
        "ccy":"USD",
        "amt":"1.5",
        "from":"6",
        "to":"6",
        "fromSubAccount":"test-1",
        "toSubAccount":"test-2"
    }
    

    Request parameters

    Parameter Type Required Description
    ccy String Yes Currency
    amt String Yes Transfer amount
    from String Yes 6:Funding Account 18:Trading account
    to String Yes 6:Funding Account 18:Trading account
    fromSubAccount String Yes Sub-account name of the account that transfers funds out.
    toSubAccount String Yes Sub-account name of the account that transfers funds in.

    Returned results

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "transId":"12345",
            }
        ]
    }
    

    Response parameters

    Parameter name Type Description
    transId String Transfer ID

    Market data

    The API endpoints of Market Data do not require authentication.

    Get tickers

    Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/tickers

    Request Example

    GET /api/v5/market/tickers?instType=SPOT
    
    

    Request Parameters

    Parameter Type Required Description
    instType String Yes Instrument type
    SPOT

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "instType": "SPOT",
                "instId": "BTC-USD",
                "last": "16848.15",
                "lastSz": "0.0005",
                "askPx": "16849.01",
                "askSz": "0.0401",
                "bidPx": "16848.15",
                "bidSz": "0.017",
                "open24h": "16761.08",
                "high24h": "16943.44",
                "low24h": "16629.04",
                "volCcy24h": "2993092.015",
                "vol24h": "178.2431",
                "ts": "1672841403093",
                "sodUtc0": "16688.74",
                "sodUtc8": "16700.35"
            },
            {
                "instType": "SPOT",
                "instId": "ETH-USD",
                "last": "1252.02",
                "lastSz": "0.1727",
                "askPx": "1251.95",
                "askSz": "0.2296",
                "bidPx": "1251.81",
                "bidSz": "0.1699",
                "open24h": "1217.86",
                "high24h": "1260",
                "low24h": "1206.08",
                "volCcy24h": "4766566.0992",
                "vol24h": "3860.2722",
                "ts": "1672841403094",
                "sodUtc0": "1214.45",
                "sodUtc8": "1211.18"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    last String Last traded price
    lastSz String Last traded size
    askPx String Best ask price
    askSz String Best ask size
    bidPx String Best bid price
    bidSz String Best bid size
    open24h String Open price in the past 24 hours
    high24h String Highest price in the past 24 hours
    low24h String Lowest price in the past 24 hours
    volCcy24h String 24h trading volume, with a unit of currency.
    The value is the quantity in quote currency.
    vol24h String 24h trading volume, with a unit of contract.
    The value is the quantity in base currency.
    sodUtc0 String Open price in the UTC 0
    sodUtc8 String Open price in the UTC 8
    ts String Ticker data generation time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get ticker

    Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/ticker

    Request Example

    GET /api/v5/market/ticker?instId=BTC-USD
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "instType": "SPOT",
                "instId": "BTC-USD",
                "last": "16838.49",
                "lastSz": "0.237",
                "askPx": "16836.62",
                "askSz": "0.0431",
                "bidPx": "16835.97",
                "bidSz": "0.2",
                "open24h": "16764.37",
                "high24h": "16943.44",
                "low24h": "16629.04",
                "volCcy24h": "2991370.9916",
                "vol24h": "178.1375",
                "ts": "1672841618814",
                "sodUtc0": "16688.74",
                "sodUtc8": "16700.35"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID
    last String Last traded price
    lastSz String Last traded size
    askPx String Best ask price
    askSz String Best ask size
    bidPx String Best bid price
    bidSz String Best bid size
    open24h String Open price in the past 24 hours
    high24h String Highest price in the past 24 hours
    low24h String Lowest price in the past 24 hours
    volCcy24h String 24h trading volume, with a unit of currency.
    The value is the quantity in quote currency.
    vol24h String 24h trading volume, with a unit of contract.
    The value is the quantity in base currency.
    sodUtc0 String Open price in the UTC 0
    sodUtc8 String Open price in the UTC 8
    ts String Ticker data generation time, Unix timestamp format in milliseconds, e.g. 1597026383085.

    Get order book

    Retrieve order book of the instrument.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/books

    Request Example

    GET /api/v5/market/books?instId=BTC-USD
    
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    sz String No Order book depth per side. Maximum 400, e.g. 400 bids + 400 asks
    Default returns to 1 depth data

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "asks": [
                    [
                        "41006.8",
                        "0.60038921",
                        "0",
                        "1"
                    ]
                ],
                "bids": [
                    [
                        "41006.3",
                        "0.30178218",
                        "0",
                        "2"
                    ]
                ],
                "ts": "1629966436396"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    asks Array Order book on sell side
    bids Array Order book on buy side
    ts String Order book generation time
    An example of the array of asks and bids values: ["411.8", "10", "0", "4"]
    - "411.8" is the depth price
    - "10" is the quantity at the price (quantity in base currency for Spot)
    - "0" is part of a deprecated feature and it is always "0"
    - "4" is the number of orders at the price.

    Get candlesticks

    Retrieve the candlestick charts. This endpoint can retrieve the latest 1,440 data entries. Charts are returned in groups based on the requested bar.

    Rate Limit: 40 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/candles

    Request Example

    GET /api/v5/market/candles?instId=BTC-USD
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    bar String No Bar size, the default is 1m
    e.g. [1m/3m/5m/15m/30m/1H/2H/4H]
    Hong Kong time opening price k-line:[6H/12H/1D/2D/3D/1W/1M/3M]
    UTC time opening price k-line:[/6Hutc/12Hutc/1Dutc/2Dutc/3Dutc/1Wutc/1Mutc/3Mutc]
    after String No Pagination of data to return records earlier than the requested ts
    before String No Pagination of data to return records newer than the requested ts
    limit String No Number of results per request. The maximum is 300. The default is 100.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         [
            "1597026383085",
            "3.721",
            "3.743",
            "3.677",
            "3.708",
            "8422410",
            "22698348.04828491",
            "12698348.04828491",
            "0"
        ],
        [
            "1597026383085",
            "3.731",
            "3.799",
            "3.494",
            "3.72",
            "24912403",
            "67632347.24399722",
            "37632347.24399722",
            "1"
        ]
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ts String Opening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085
    o String Open price
    h String highest price
    l String Lowest price
    c String Close price
    vol String Trading volume, the value is the quantity in base currency.
    volCcy String Trading volume, the value is the quantity in quote currency.
    volCcyQuote String Trading volume, the value is the quantity in quote currency. Not enabled. Please disregard.
    confirm String The state of candlesticks.
    0 represents that it is uncompleted, 1 represents that it is completed.

    The first candlestick data may be incomplete, and should not be polled repeatedly.

    The data returned will be arranged in an array like this: [ts,o,h,l,c,vol,volCcy,volCcyQuote,confirm].

    Get candlesticks history

    Retrieve history candlestick charts from recent years.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/history-candles

    Request Example

    GET /api/v5/market/history-candles?instId=BTC-USD
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    after String No Pagination of data to return records earlier than the requested ts
    before String No Pagination of data to return records newer than the requested ts
    bar String No Bar size, the default is 1m
    e.g. [1m/3m/5m/15m/30m/1H/2H/4H]
    Hong Kong time opening price k-line:[6H/12H/1D/2D/3D/1W/1M/3M]
    UTC time opening price k-line:[6Hutc/12Hutc/1Dutc/2Dutc/3Dutc/1Wutc/1Mutc/3Mutc]
    limit String No Number of results per request. The maximum is 100. The default is 100.

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         [
            "1597026383085",
            "3.721",
            "3.743",
            "3.677",
            "3.708",
            "8422410",
            "22698348.04828491",
            "12698348.04828491",
            "1"
        ],
        [
            "1597026383085",
            "3.731",
            "3.799",
            "3.494",
            "3.72",
            "24912403",
            "67632347.24399722",
            "37632347.24399722",
            "1"
        ]
        ]
    }
    

    Response Parameters

    Parameter Type Description
    ts String Opening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085
    o String Open price
    h String Highest price
    l String Lowest price
    c String Close price
    vol String Trading volume, the value is the quantity in base currency.
    volCcy String Trading volume, the value is the quantity in quote currency.
    volCcyQuote String Trading volume, the value is the quantity in quote currency. Not enabled. Please disregard.
    confirm String The state of candlesticks.
    0 represents that it is uncompleted, 1 represents that it is completed.

    The data returned will be arranged in an array like this: [ts,o,h,l,c,vol,volCcy,volCcyQuote,confirm].

    Get trades

    Retrieve the recent transactions of an instrument.

    Rate Limit: 100 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/trades

    Request Example

    GET /api/v5/market/trades?instId=BTC-USD
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    limit String No Number of results per request. The maximum is 500; The default is 100

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "instId": "BTC-USD",
                "side": "sell",
                "sz": "0.00001",
                "px": "29963.2",
                "tradeId": "242720720",
                "ts": "1654161646974"
            },
            {
                "instId": "BTC-USD",
                "side": "sell",
                "sz": "0.00001",
                "px": "29964.1",
                "tradeId": "242720719",
                "ts": "1654161641568"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instId String Instrument ID
    tradeId String Trade ID
    px String Trade price
    sz String Trade quantity
    side String Trade side
    buy
    sell
    ts String Trade time, Unix timestamp format in milliseconds, e.g. 1597026383085.
    Up to 500 most recent historical public transaction data can be retrieved.

    Get trades history

    Retrieve the recent transactions of an instrument from the last 3 months with pagination.

    Rate Limit: 10 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/history-trades

    Request Example

    GET /api/v5/market/history-trades?instId=BTC-USD
    

    Request Parameters

    Parameter Type Required Description
    instId String Yes Instrument ID, e.g. BTC-USD
    type String No Pagination Type
    1: tradeId 2: timestamp
    The default is 1
    after String No Pagination of data to return records earlier than the requested tradeId or ts.
    before String No Pagination of data to return records newer than the requested tradeId.
    Do not support timestamp for pagination
    limit String No Number of results per request. The maximum and default both are 100

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [
            {
                "instId": "BTC-USD",
                "side": "sell",
                "sz": "0.00001",
                "px": "29963.2",
                "tradeId": "242720720",
                "ts": "1654161646974"
            },
            {
                "instId": "BTC-USD",
                "side": "sell",
                "sz": "0.00001",
                "px": "29964.1",
                "tradeId": "242720719",
                "ts": "1654161641568"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    instId String Instrument ID
    tradeId String Trade ID
    px String Trade price
    sz String Trade quantity
    side String Trade side
    buy
    sell
    ts String Trade time, Unix timestamp format in milliseconds, e.g. 1597026383085.

    Get 24H total volume

    The 24-hour trading volume is calculated on a rolling basis, using USD as the pricing unit.

    Rate Limit: 2 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/platform-24-volume

    Request Example

    GET /api/v5/market/platform-24-volume
    
    

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
         {
             "volCny": "230900886396766",
             "volUsd": "34462818865189",
             "ts": "1657856040389"
         }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    volUsd String 24-hour total trading volume on the platform in "USD"
    volCny String 24-hour total trading volume on the platform in "CNY"
    ts String Data return time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Get oracle

    Get the crypto price of signing using Open Oracle smart contract.

    Rate Limit: 1 request per 5 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/open-oracle

    Request Example

    GET /api/v5/market/open-oracle
    

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
            {
                "messages":[
                    "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000616d3b1400000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000e70528b800000000000000000000000000000000000000000000000000000000000000006707269636573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034254430000000000000000000000000000000000000000000000000000000000"
                ],
                "prices":{
                    "BTC":"62014"
                },
                "signatures":[
                    "0xf18330e59eaf42373c2c40f1f9e24113ba21d4ed734dd3ed3bc1d12290fa74ba5623fca1113c5d245a1202dc065e333615b90f810f12132ce4a1ecacb8c6b24a000000000000000000000000000000000000000000000000000000000000001b"
                ],
                "timestamp":"1634548500"
            }
        ]
    }
    

    Response Parameters

    Parameter Type Description
    messages String ABI-encoded values [kind, timestamp, key, value], where kind equals 'prices', timestamp is the time when price was obtained, key is the asset ticker (e.g. btc) and value is the asset price.
    prices String Readable asset prices
    signatures String Ethereum-compatible ECDSA signatures for each message
    timestamp String Time of latest datapoint, Unix timestamp, e.g. 1597026387
    Okcoin Oracle public key is 85615b076615317c80f14cbad6501eec031cd51c

    Get exchange rate

    This interface provides the average exchange rate data for 2 weeks

    Rate Limit: 1 request per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/market/exchange-rate

    Request Example

    GET /api/v5/market/exchange-rate
    

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [ {
                "usdCny": "6.44"
    }]
    }
    

    Response Parameters

    Parameter Type Description
    usdCny String Exchange rate

    Public data

    The API endpoints of Public Data do not require authentication.

    Get instruments

    Retrieve a list of instruments with open contracts.

    Rate Limit: 20 requests per 2 seconds

    Rate limit rule: IP + instrumentType

    HTTP Request

    GET /api/v5/public/instruments

    Request Example

    GET /api/v5/public/instruments?instType=SPOT
    

    Request Parameters

    Parameter Type Required Description
    instType String Yes Instrument type
    SPOT
    instId String No Instrument ID

    Response Example

    {
        "code": "0",
        "data": [
            {
                "alias": "",
                "baseCcy": "BTC",
                "category": "1",
                "ctMult": "",
                "ctType": "",
                "ctVal": "",
                "ctValCcy": "",
                "expTime": "",
                "instFamily": "",
                "instId": "BTC-USD",
                "instType": "SPOT",
                "lever": "",
                "listTime": "1671521075000",
                "lotSz": "0.0001",
                "maxIcebergSz": "99999999999999",
                "maxLmtSz": "99999999999999",
                "maxMktSz": "1000000",
                "maxStopSz": "1000000",
                "maxTriggerSz": "99999999999999",
                "maxTwapSz": "99999999999999",
                "minSz": "0.0001",
                "optType": "",
                "quoteCcy": "USD",
                "settleCcy": "",
                "state": "live",
                "stk": "",
                "tickSz": "0.01",
                "uly": ""
            }
        ],
        "msg": ""
    }
    

    Response Parameters

    Parameter Type Description
    instType String Instrument type
    instId String Instrument ID, e.g. BTC-USD
    uly String Underlying. Not enabled. Please disregard.
    instFamily String Instrument family. Not enabled. Please disregard.
    category String Fee schedule. Not enabled. Please disregard.
    baseCcy String Base currency, e.g. BTC inBTC-USD
    quoteCcy String Quote currency, e.g. USD in BTC-USD
    settleCcy String Settlement and margin currency. Not enabled. Please disregard.
    ctVal String Contract value. Not enabled. Please disregard.
    ctMult String Contract multiplier. Not enabled. Please disregard.
    ctValCcy String Contract value currency. Not enabled. Please disregard.
    optType String Option type. Not enabled. Please disregard.
    stk String Strike price. Not enabled. Please disregard.
    listTime String Listing time, Unix timestamp format in milliseconds, e.g. 1597026383085
    expTime String Expiry time, Unix timestamp format in milliseconds, e.g. 1597026383085. Not enabled. Please disregard.
    lever String Max Leverage. Not enabled. Please disregard.
    tickSz String Tick size, e.g. 0.0001
    lotSz String Lot size, e.g. BTC-USD: 1
    minSz String Minimum order size
    ctType String Contract type
    linear: linear contract
    inverse: inverse contract. Not enabled. Please disregard.
    alias String Alias. Not enabled. Please disregard.
    state String Instrument status
    live
    suspend
    preopen
    maxLmtSz String The maximum order quantity of the spot limit order
    maxMktSz String The maximum order quantity of the spot market order
    maxTwapSz String The maximum order quantity of the spot twap order
    maxIcebergSz String The maximum order quantity of the spot iceBerg order
    maxTriggerSz String The maximum order quantity of the spot trigger order
    maxStopSz String The maximum order quantity of the spot stop order
    When a new instrument is going to be listed, the instrument data of the new instrument will be available with status preopen. When a product is going to be delisted, the instrument will not be available

    Get system time

    Retrieve API server time.

    Rate Limit: 10 requests per 2 seconds

    Rate limit rule: IP

    HTTP Request

    GET /api/v5/public/time

    Request Example

    GET /api/v5/public/time
    

    Response Example

    {
        "code":"0",
        "msg":"",
        "data":[
        {
            "ts":"1597026383085"
        }
      ]
    }
    

    Response Parameters

    Parameter Type Description
    ts String System time, Unix timestamp format in milliseconds, e.g. 1597026383085

    Status

    Get event status of system upgrade

    Rate Limit: 1 request per 5 seconds

    HTTP Requests

    GET /api/v5/system/status

    Request Example

    GET /api/v5/system/status
    
    GET /api/v5/system/status?state=canceled
    
    

    Request Parameters

    Parameters Types Required Description
    state String No System maintenance status,scheduled: waiting; ongoing: processing; pre_open: pre_open; completed: completed ;canceled: canceled.
    Generally, pre_open last about 10 minutes. There will be pre_open when the time of upgrade is too long.
    If this parameter is not filled, the data with status scheduled, ongoing and pre_open will be returned by default

    Response Example

    {
        "code": "0",
        "msg": "",
        "data": [{
            "title": "Spot System Upgrade",
            "state": "scheduled",
            "begin": "1620723600000",
            "end": "1620724200000",
            "href": "",
            "serviceType": "1",
            "system": "classic",
            "scheDesc": ""       
        }]
    }
    

    Response Parameters

    Parameters Types Description
    title String The title of system maintenance instructions
    state String System maintenance status
    begin String Begin time of system maintenance, Unix timestamp format in milliseconds, e.g. 1617788463867
    end String Time of resuming trading totally. Unix timestamp format in milliseconds, e.g. 1617788463867.
    It is expected end time before completed, changed to actual end time after completed.
    preOpenBegin String The time of pre_open. Canceling orders, placing Post Only orders, and transferring funds to trading accounts are back after preOpenBegin.
    href String Hyperlink for system maintenance details, if there is no return value, the default value will be empty. e.g. “”
    serviceType String Service type, 0:WebSocket ; 1:Classic account 5:Unified account; 99: Others (e.g. Suspend partial instruments)
    system String System, classic: Classic account unified: Unified account
    scheDesc String Rescheduled description, e.g. Rescheduled from 2021-01-26T16:30:00.000Z to 2021-01-28T16:30:00.000Z

    WebSocket API

    Overview

    WebSocket is a new HTML5 protocol that achieves full-duplex data transmission between the client and server, allowing data to be transferred effectively in both directions. A connection between the client and server can be established with just one handshake. The server will then be able to push data to the client according to preset rules. Its advantages include:

    • The WebSocket request header size for data transmission between client and server is only 2 bytes.
    • Either the client or server can initiate data transmission.
    • There's no need to repeatedly create and delete TCP connections, saving resources on bandwidth and server.
    We recommend developers use WebSocket API to retrieve market data and order book depth.

    Connect

    Connection instructions:

    Connection limit: 1 request per second

    When subscribing to a public channel, use the address of the public service. When subscribing to a private channel, use the address of the private service

    Subscription limit: 240 times per hour

    If there’s a network problem, the system will automatically disable the connection.

    The connection will break automatically if the subscription is not established or data has not been pushed for more than 30 seconds.

    To keep the connection stable:

    1. Set a timer of N seconds whenever a response message is received, where N is less than 30.

    2. If the timer is triggered, which means that no new message is received within N seconds, send the String 'ping'.

    3. Expect a 'pong' as a response. If the response message is not received within N seconds, please raise an error or reconnect.

    Login

    Rate Limit: 1 request per second Applicable to single-account login
    Rate Limit: 1 request per 15 seconds Applicable to multi-account batch login

    Request Example

    {
      "op": "login",
      "args": [
        {
          "apiKey": "985d5b66-57ce-40fb-b714-afc0b9787083",
          "passphrase": "123456",
          "timestamp": "1538054050",
          "sign": "7L+zFQ+CEgGu5rzCj4+BdV2/uUHGqddA9pI6ztsRRPs="
        },
        {
          "apiKey"    : "86126n98-57ce-40fb-b714-afc0b9787083",
          "passphrase" :"123456",
          "timestamp" :"1538054050",
          "sign" :"7L+zFQ+CEgGu5rzCj4+BdV2/uUHGqddA9pI6ztsRRPs=" 
         }
      ]
    }
    

    Request parameters

    Parameter Type Required Description
    op String Yes Operation, login
    args Array Yes List of account to login, the maximum is 100
    > apiKey String Yes APIKey
    > passphrase String Yes APIKey password
    > timestamp String Yes Unix Epoch time, the unit is seconds
    > sign String Yes Signature string

    Successful Response Example

    {
      "event": "login",
      "code": "0",
      "msg": ""
    }
    

    Failure Response Example

    {
      "event": "error",
      "code": "60009",
      "msg": "Login failed."
    }
    

    Response Example When Partially Successful

    {
        "event": "login",
        "code": "60022",
        "msg": "Bulk login partially succeeded",
        "data":[
            {"apiKey": "86126n98-57ce-40fb-b714-afc0b9787083"}
        ]
    }
    

    Response parameters

    Parameter Type Required Description
    event String Yes Operation, login error
    code String No Error code
    msg String No Error message
    data Object No List returned after login failure
    > apiKey String Yes APIKey returned after login failure
    Users who log in with multiple accounts can only subscribe to WebSocket channels and cannot trade via WebSocket

    api_key: Unique identification for invoking API. Requires user to apply one manually.

    passphrase: APIKey password

    timestamp: the Unix Epoch time, the unit is seconds

    sign: signature string, the signature algorithm is as follows:

    First concatenate timestamp, method, requestPath, strings, then use HMAC SHA256 method to encrypt the concatenated string with SecretKey, and then perform Base64 encoding.

    secretKey: The security key generated when the user applies for APIKey, e.g. : 22582BD0CFF14C41EDBF1AB98506286D

    Example of timestamp: const timestamp = '' + Date.now() / 1,000

    Among sign example: sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp +'GET'+'/users/self/verify', secretKey))

    method: always 'GET'.

    requestPath : always '/users/self/verify'

    The request will expire 30 seconds after the timestamp. If your server time differs from the API server time, we recommended using the REST API to query the API server time and then set the timestamp.

    Subscribe

    Subscription Instructions

    Request format description

    {
      "op": "subscribe",
      "args": ["<SubscriptionTopic>"]
    }
    

    WebSocket channels are divided into two categories: public and private channels.

    Public channels -- No authentication is required, include tickers channel, K-Line channel, limit price channel, order book channel, and mark price channel etc.

    Private channels -- including account channel, order channel, and position channel, etc -- require log in.

    Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 4,096 bytes.

    Request Example

    {
        "op":"subscribe",
        "args":[
            {
                "channel":"tickers",
                "instId":"BTC-USD"
            },
            {
                "channel":"candle1m",
                "instId":"BTC-USD"
            }
        ]
    }
    

    Request parameters

    Parameter Type Required Description
    op String Yes Operation, subscribe
    args Array Yes List of subscribed channels
    > channel String Yes Channel name
    > instType String No Instrument type
    SPOT
    > uly String No Underlying
    > instId String No Instrument ID

    Response Example

    {
      "event": "subscribe",
      "arg": {
        "channel": "tickers",
        "instId": "BTC-USD"
      }
    }
    

    Return parameters

    Parameter Type Required Description
    event String Yes Event, subscribe error
    arg Object No Subscribed channel
    > channel String Yes Channel name
    > instType String No Instrument type
    SPOT
    > uly String No Underlying
    > instId String No Instrument ID
    code String No Error code
    msg String No Error message

    Unsubscribe

    Unsubscribe from one or more channels.

    Request format description

    {
      "op": "unsubscribe",
      "args": ["< SubscriptionTopic> "]
    }
    

    Request Example

    {
      "op": "unsubscribe",
      "args": [
        {
          "channel": "tickers",
          "instId": "BTC-USD"
        },
        {
          "channel": "candle1m",
          "instId": "BTC-USD"
        }
      ]
    }
    

    Request parameters

    Parameter Type Required Description
    op String Yes Operation, unsubscribe
    args Array Yes List of channels to unsubscribe from
    > channel String Yes Channel name
    > instType String No Instrument type
    SPOT
    > uly String No Underlying
    > instId String No Instrument ID

    Response Example

    {
      "event": "unsubscribe",
      "arg": {
        "channel": "tickers",
        "instId": "BTC-USD"
      }
    }
    

    Response parameters

    Parameter Type Required Description
    event String Yes Event, unsubscribe error
    arg Object No Unsubscribed channel
    > channel String Yes Channel name
    > instType String No Instrument type
    SPOT
    > uly String No Underlying
    > instId String No Instrument ID
    code String No Error code
    msg String No Error message

    Trade

    The WebSocket Trade APIs require authentication.

    Place order

    You can place an order only if you have sufficient funds.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Rate limit is shared with the `Place order` REST API endpoints

    Request Example

    {
        "id": "1512",
        "op": "order",
        "args": [{
            "side": "buy",
            "instId": "BTC-USDT",
            "tdMode": "cash",
            "ordType": "market",
            "sz": "100"
        }]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. order
    args Array Yes Request parameters
    > instId String Yes Instrument ID,e.g. BTC-USD
    > tdMode String Yes Trade mode
    Non-Margin mode cash
    > clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    > tag String No Order tag
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
    > side String Yes Order side, buy sell
    > ordType String Yes Order type
    market: market order
    limit: limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    > sz String Yes Quantity to buy or sell.
    > px String Conditional Order price
    Only applicable to limit,post_only,fok,ioc order.
    > tgtCcy String No Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    > banAmend Boolean No Whether to disallow the system from amending the size of the SPOT Market Order.
    Valid options: true or false. The default value is false.
    If true, system will not amend and reject the market order if user does not have sufficient funds.
    Only applicable to SPOT Market Orders
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
    Successful Response Example
    {
      "id": "1512",
      "op": "order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "12345689",
          "tag": "",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Failure Response Example

    {
      "id": "1512",
      "op": "order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "",
          "tag": "",
          "sCode": "5XXXX",
          "sMsg": "not exist"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1512",
      "op": "order",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > tag String Order tag
    > sCode String Order status code, 0 means success
    > sMsg String Order status message
    clOrdId
    clOrdId is a user-defined unique ID used to identify the order. It will be included in the response parameters if you have specified during order submission, and can be used as a request parameter to the endpoints to query, cancel and amend orders.
    clOrdId must be unique among the clOrdIds of all pending orders.
    ordType
    Order type. When creating a new order, you must specify the order type. The order type you specify will affect: 1) what order parameters are required, and 2) how the matching system executes your order. The following are valid order types:
    limit: Limit order, which requires specified sz and px.
    market: Market order. For SPOT, market order will be filled with market price (by swiping opposite order book).
    post_only: Post-only order, which the order can only provide liquidity to the market and be a maker. If the order would have executed on placement, it will be canceled instead.
    fok: Fill or kill order. If the order cannot be fully filled, the order will be canceled. The order would not be partially filled.
    ioc: Immediate or cancel order. Immediately execute the transaction at the order price, cancel the remaining unfilled quantity of the order, and the order quantity will not be displayed in the order book.
    sz
    Quantity to buy or sell.
    For SPOT Buy and Sell Limit Orders, it refers to the quantity in base currency.
    For SPOT Buy Market Orders, it refers to the quantity in quote currency.
    For SPOT Sell Market Orders, it refers to the quantity in base currency.
    tgtCcy
    This parameter is used to specify the order quantity in the order request is denominated in the quantity of base or quote currency. This is applicable to SPOT Market Orders only.
    Base currency:base_ccy
    Quote currency:quote_ccy
    If you use the Base Currency quantity for buy market orders or the Quote Currency for sell market orders, please note:
    1. If the quantity you enter is greater than what you can buy or sell, the system will execute the order according to your maximum buyable or sellable quantity. If you want to trade according to the specified quantity, you should use Limit orders.
    2. When the market price is too volatile, the locked balance may not be sufficient to buy the Base Currency quantity or sell to receive the Quote Currency that you specified. We will change the quantity of the order to execute the order based on best effort principle based on your account balance. In addition, we will try to over lock a fraction of your balance to avoid changing the order quantity.
    2.1 Example of base currency buy market order:
    Taking the market order to buy 10 LTCs as an example, and the user can buy 11 LTC. At this time, if 10 < 11, the order is accepted. When the LTC-USDT market price is 200, and the locked balance of the user is 3,000 USDT, as 200*10 < 3,000, the market order of 10 LTC is fully executed; If the market is too volatile and the LTC-USDT market price becomes 400, 400*10 > 3,000, the user's locked balance is not sufficient to buy using the specified amount of base currency, the user's maximum locked balance of 3,000 USDT will be used to settle the trade. Final transaction quantity becomes 3,000/400 = 7.5 LTC.
    2.2 Example of quote currency sell market order:
    Taking the market order to sell 1,000 USDT as an example, and the user can sell 1,200 USDT, 1,000 < 1,200, the order is accepted. When the LTC-USDT market price is 200, and the locked balance of the user is 6 LTC, as 1,000/200 < 6, the market order of 1,000 USDT is fully executed; If the market is too volatile and the LTC-USDT market price becomes 100, 100*6 < 1,000, the user's locked balance is not sufficient to sell using the specified amount of quote currency, the user's maximum locked balance of 6 LTC will be used to settle the trade. Final transaction quantity becomes 6 * 100 = 600 USDT.

    Place multiple orders

    Place orders in a batch. Maximum 20 orders can be placed per request

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Place order`.
    Rate limit is shared with the `Place multiple orders` REST API endpoints

    Request Example

    {
      "id": "1513",
      "op": "batch-orders",
      "args": [
        {
            "instId":"BTC-USD",
            "tdMode":"cash",
            "clOrdId":"b15",
            "side":"buy",
            "ordType":"limit",
            "px":"2.15",
            "sz":"2"
        },
        {
            "instId":"BTC-USD",
            "tdMode":"cash",
            "clOrdId":"b15",
            "side":"buy",
            "ordType":"limit",
            "px":"2.15",
            "sz":"2"
        }
      ]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. batch-orders
    args Array Yes Request Parameters
    > instId String Yes Instrument ID, e.g. BTC-USDT
    > tdMode String Yes Trade mode
    Non-Margin mode cash
    > clOrdId String No Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    > tag String No Order tag
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
    > side String Yes Order side, buy sell
    > ordType String Yes Order type
    market: market order
    limit: limit order
    post_only: Post-only order
    fok: Fill-or-kill order
    ioc: Immediate-or-cancel order
    > sz String Yes Quantity to buy or sell.
    > px String Conditional Price
    Only applicable to limit,post_only,fok,ioc order.
    > tgtCcy String No Order quantity unit setting for sz
    base_ccy: Base currency ,quote_ccy: Quote currency
    Only applicable to SPOT Market Orders
    Default is quote_ccy for buy, base_ccy for sell
    > banAmend Boolean No Whether to disallow the system from amending the size of the SPOT Market Order.
    Valid options: true or false. The default value is false.
    If true, system will not amend and reject the market order if user does not have sufficient funds.
    Only applicable to SPOT Market Orders
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085

    Response Example When All Succeed

    {
      "id": "1513",
      "op": "batch-orders",
      "data": [
        {
          "clOrdId": "",
          "ordId": "12345689",
          "tag": "",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "",
          "ordId": "12344",
          "tag": "",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Response Example When Partially Successful

    {
      "id": "1513",
      "op": "batch-orders",
      "data": [
        {
          "clOrdId": "",
          "ordId": "12345689",
          "tag": "",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "",
          "ordId": "",
          "tag": "",
          "sCode": "5XXXX",
          "sMsg": "Insufficient margin"
        }
      ],
      "code": "2",
      "msg": ""
    }
    

    Response Example When All Failed

    {
      "id": "1513",
      "op": "batch-orders",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "",
          "tag": "",
          "sCode": "5XXXX",
          "sMsg": "Insufficient margin"
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "",
          "tag": "",
          "sCode": "5XXXX",
          "sMsg": "Insufficient margin"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1513",
      "op": "batch-orders",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > tag String Order tag
    > sCode String Order status code, 0 means success
    > sMsg String Order status message

    Cancel order

    Cancel an incomplete order

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Rate limit is shared with the `Cancel order` REST API endpoints

    Request Example

    {
      "id": "1514",
      "op": "cancel-order",
      "args": [
        {
          "instId": "BTC-USD",
          "ordId": "2510789768709120"
        }
      ]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. cancel-order
    args Array Yes Request Parameters
    > instId String Yes Instrument ID
    > ordId String Conditional Order ID
    Either ordId or clOrdId is required, if both are passed, ordId will be used
    > clOrdId String Conditional Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

    Successful Response Example

    {
      "id": "1514",
      "op": "cancel-order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "2510789768709120",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Failure Response Example

    {
      "id": "1514",
      "op": "cancel-order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "2510789768709120",
          "sCode": "5XXXX",
          "sMsg": "Order not exist"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1514",
      "op": "cancel-order",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > sCode String Order status code, 0 means success
    > sMsg String Order status message
    Cancel order returns with sCode equal to 0. It is not strictly considered that the order has been canceled. It only means that your cancellation request has been accepted by the system server. The result of the cancellation is subject to the state pushed by the order channel or the get order state.

    Cancel multiple orders

    Cancel incomplete orders in batches. Maximum 20 orders can be canceled per request.

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Cancel order`.
    Rate limit is shared with the `Cancel multiple orders` REST API endpoints

    Request Example

    {
      "id": "1515",
      "op": "batch-cancel-orders",
      "args": [
        {
          "instId": "BTC-USD",
          "ordId": "2517748157541376"
        },
        {
          "instId": "LTC-USD",
          "ordId": "2517748155771904"
        }
      ]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. batch-cancel-orders
    args Array Yes Request Parameters
    > instId String Yes Instrument ID
    > ordId String Conditional Order ID
    Either ordId or clOrdId is required, if both are passed, ordId will be used
    > clOrdId String Conditional Client Order ID as assigned by the client
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

    Response Example When All Succeed

    {
      "id": "1515",
      "op": "batch-cancel-orders",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "2517748157541376",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "2517748155771904",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Response Example When partially successfully

    {
      "id": "1515",
      "op": "batch-cancel-orders",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "2517748157541376",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "2517748155771904",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        }
      ],
      "code": "2",
      "msg": ""
    }
    

    Response Example When All Failed

    {
      "id": "1515",
      "op": "batch-cancel-orders",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "2517748157541376",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "2517748155771904",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1515",
      "op": "batch-cancel-orders",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > sCode String Order status code, 0 means success
    > sMsg String Order status message

    Amend order

    Amend an incomplete order.

    Rate Limit: 60 requests per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Rate limit is shared with the `Amend order` REST API endpoints

    Request Example

    {
      "id": "1512",
      "op": "amend-order",
      "args": [
        {
          "instId": "BTC-USD",
          "ordId": "2510789768709120",
          "newSz": "2"
        }
      ]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. amend-order
    args Array Yes Request Parameters
    > instId String Yes Instrument ID
    > cxlOnFail Boolean No Whether the order needs to be automatically canceled when the order amendment fails
    Valid options: false or true, the default is false.
    > ordId String Conditional Order ID
    Either ordId or clOrdId is required, if both are passed, ordId will be used.
    > clOrdId String Conditional Client Order ID as assigned by the client
    > reqId String No Client Request ID as assigned by the client for order amendment
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    > newSz String Conditional New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
    > newPx String Conditional New price after amendment.
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085

    Successful Response Example

    {
      "id": "1512",
      "op": "amend-order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "2510789768709120",
          "reqId": "b12344",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Failure Response Example

    {
      "id": "1512",
      "op": "amend-order",
      "data": [
        {
          "clOrdId": "",
          "ordId": "2510789768709120",
          "reqId": "b12344",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1512",
      "op": "amend-order",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > reqId String Client Request ID as assigned by the client for order amendment
    > sCode String Order status code, 0 means success
    > sMsg String Order status message
    newSz
    If the new quantity of the order is less than or equal to the filled quantity when you are amending a partially-filled order, the order status will be changed to filled.
    The amend order returns sCode equal to 0. It is not strictly considered that the order has been amend. It only means that your amend order request has been accepted by the system server. The result of the amend is subject to the status pushed by the order channel or the order status query

    Amend multiple orders

    Amend incomplete orders in batches. Maximum 20 orders can be amended per request.

    Rate Limit: 300 orders per 2 seconds

    Spot rate limit rule: UserID + instrumentID

    Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Amend order`.
    Rate limit is shared with the `Amend multiple orders` REST API endpoints

    Request Example

    {
      "id": "1513",
      "op": "batch-amend-orders",
      "args": [
        {
          "instId": "BTC-USD",
          "ordId": "12345689",
          "newSz": "2"
        },
        {
          "instId": "BTC-USD",
          "ordId": "12344",
          "newSz": "2"
        }
      ]
    }
    

    Request Parameters

    Parameter Type Required Description
    id String Yes Unique identifier of the message
    Provided by client. It will be returned in response message for identifying the corresponding request.
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    op String Yes Operation, e.g. batch-amend-orders
    args Array Yes Request Parameters
    > instId String Yes Instrument ID
    > cxlOnFail Boolean No Whether the order needs to be automatically canceled when the order amendment fails
    Valid options: false or true, the default is false.
    > ordId String Conditional Order ID
    Either ordId or clOrdId is required, if both are passed, ordId will be used.
    > clOrdId String Conditional Client Order ID as assigned by the client
    > reqId String No Client Request ID as assigned by the client for order amendment
    A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
    > newSz String Conditional New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
    > newPx String Conditional New price after amendment.
    expTime String No Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085

    Response Example When All Succeed

    {
      "id": "1513",
      "op": "batch-amend-orders",
      "data": [
        {
          "clOrdId": "oktswap6",
          "ordId": "12345689",
          "reqId": "b12344",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "12344",
          "reqId": "b12344",
          "sCode": "0",
          "sMsg": ""
        }
      ],
      "code": "0",
      "msg": ""
    }
    

    Response Example When All Failed

    {
      "id": "1513",
      "op": "batch-amend-orders",
      "data": [
        {
          "clOrdId": "",
          "ordId": "12345689",
          "reqId": "b12344",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "",
          "reqId": "b12344",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        }
      ],
      "code": "1",
      "msg": ""
    }
    

    Response Example When Partially Successful

    {
      "id": "1513",
      "op": "batch-amend-orders",
      "data": [
        {
          "clOrdId": "",
          "ordId": "12345689",
          "reqId": "b12344",
          "sCode": "0",
          "sMsg": ""
        },
        {
          "clOrdId": "oktswap7",
          "ordId": "",
          "reqId": "b12344",
          "sCode": "5XXXX",
          "sMsg": "order not exist"
        }
      ],
      "code": "2",
      "msg": ""
    }
    

    Response Example When Format Error

    {
      "id": "1513",
      "op": "batch-amend-orders",
      "data": [],
      "code": "60013",
      "msg": "Invalid args"
    }
    

    Response Parameters

    Parameter Type Description
    id String Unique identifier of the message
    op String Operation
    code String Error Code
    msg String Error message
    data Array Data
    > ordId String Order ID
    > clOrdId String Client Order ID as assigned by the client
    > reqId String Client Request ID as assigned by the client for order amendment
    If the user provides reqId in the request, the corresponding reqId will be returned
    > sCode String Order status code, 0 means success
    > sMsg String Order status message
    newSz
    If the new quantity of the order is less than or equal to the filled quantity when you are amending a partially-filled order, the order status will be changed to filled.

    Private channel

    Account channel

    Retrieve account information. Data will be pushed when triggered by events such as placing order, canceling order, transaction execution, etc. It will also be pushed in regular interval according to subscription granularity.

    Request Example : single

    {
      "op": "subscribe",
      "args": [
        {
          "channel": "account",
          "ccy": "BTC"
        }
      ]
    }
    

    Request Example

    {
      "op": "subscribe",
      "args": [
        {
          "channel": "account"
        }
      ]
    }
    

    Request parameters

    Parameter Type Required Description
    op String Yes Operation, subscribe unsubscribe
    args Array Yes List of subscribed channels
    > channel String Yes Channel name, account
    > ccy String No Currency

    Successful Response Example : single

    {
      "event": "subscribe",
      "arg": {
        "channel": "account",
        "ccy": "BTC"
      }
    }
    

    Successful Response Example

    {
      "event": "subscribe",
      "arg": {
        "channel": "account"
      }
    }
    

    Failure Response Example

    {
      "event": "error",
      "code": "60012",
      "msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"account\", \"ccy\" : \"BTC\"}]}"
    }
    

    Response parameters

    Parameter Type Required Description
    event String Yes Operation, subscribe unsubscribe error
    arg Object No Subscribed channel
    > channel String Yes Channel name, account
    > ccy String No Currency
    code String No Error code
    msg String No Error message

    Push Data Example: single

    {
        "arg": {
            "channel": "account",
            "uid": "1300041872592896"
        },
        "data": [
            {
                "adjEq": "",
                "details": [
                    {
                        "availBal": "1.63093282565",
                        "availEq": "",
                        "cashBal": "1.63093282565",
                        "ccy": "USD",
                        "coinUsdPrice": "1",
                        "crossLiab": "",
                        "disEq": "0",
                        "eq": "1.63093282565",
                        "eqUsd": "1.63093282565",
                        "fixedBal": "0",
                        "frozenBal": "0",
                        "interest": "",
                        "isoEq": "",
                        "isoLiab": "",
                        "isoUpl": "",
                        "liab": "",
                        "maxLoan": "",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "spotInUseAmt": "",
                        "stgyEq": "0",
                        "twap": "0",
                        "uTime": "1672814726203",
                        "upl": ""
                    }
                ],
                "imr": "",
                "isoEq": "",
                "mgnRatio": "",
                "mmr": "",
                "notionalUsd": "",
                "ordFroz": "",
                "totalEq": "1.63100282285",
                "uTime": "1672814733845"
            }
        ]
    }
    

    Push Data Example

    {
        "arg": {
            "channel": "account",
            "uid": "1300041872592896"
        },
        "data": [
            {
                "adjEq": "",
                "details": [
                    {
                        "availBal": "1.63093282565",
                        "availEq": "",
                        "cashBal": "1.63093282565",
                        "ccy": "USD",
                        "coinUsdPrice": "1",
                        "crossLiab": "",
                        "disEq": "0",
                        "eq": "1.63093282565",
                        "eqUsd": "1.63093282565",
                        "fixedBal": "0",
                        "frozenBal": "0",
                        "interest": "",
                        "isoEq": "",
                        "isoLiab": "",
                        "isoUpl": "",
                        "liab": "",
                        "maxLoan": "",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "spotInUseAmt": "",
                        "stgyEq": "0",
                        "twap": "0",
                        "uTime": "1672814726203",
                        "upl": ""
                    },
                    {
                        "availBal": "0.00007",
                        "availEq": "",
                        "cashBal": "0.00007",
                        "ccy": "USDT",
                        "coinUsdPrice": "0.99996",
                        "crossLiab": "",
                        "disEq": "0",
                        "eq": "0.00007",
                        "eqUsd": "0.0000699972",
                        "fixedBal": "0",
                        "frozenBal": "0",
                        "interest": "",
                        "isoEq": "",
                        "isoLiab": "",
                        "isoUpl": "",
                        "liab": "",
                        "maxLoan": "",
                        "mgnRatio": "",
                        "notionalLever": "",
                        "ordFrozen": "0",
                        "spotInUseAmt": "",
                        "stgyEq": "0",
                        "twap": "0",
                        "uTime": "1672814726203",
                        "upl": ""
                    }
                ],
                "imr": "",
                "isoEq": "",
                "mgnRatio": "",
                "mmr": "",
                "notionalUsd": "",
                "ordFroz": "",
                "totalEq": "1.63100282285",
                "uTime": "1672814733845"
            }
        ]
    }
    

    Push data parameters

    Parameters Types Description
    arg Object Successfully subscribed channel
    > channel String Channel name
    > uid String User Identifier
    data Array Subscribed data
    > uTime String The latest time to get account information, millisecond format of Unix timestamp, e.g. 1597026383085
    > totalEq String Total equity in USD
    > isoEq String Isolated margin equity in USD. Not enabled. Please disregard.
    > adjEq String Adjusted / Effective equity in USD. Not enabled. Please disregard.
    > ordFroz String Margin frozen for pending cross orders in USD. Not enabled. Please disregard.
    > imr String Frozen equity for open positions and pending orders in USD. Not enabled. Please disregard.
    > mmr String Maintenance margin requirement in USD . Not enabled. Please disregard.
    > mgnRatio String Margin ratio in USD . Not enabled. Please disregard.
    > notionalUsd String Notional value of positions in USD . Not enabled. Please disregard.
    > details Array Detailed asset information in all currencies
    >> ccy String Currency
    >> eq String Equity of the currency
    >> cashBal String Cash Balance
    >> uTime String Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
    >> isoEq String Isolated margin equity of the currency. Not enabled. Please disregard.
    >> availEq String Available equity of the currency. Not enabled. Please disregard.
    >> disEq String Discount equity of the currency in USD
    >> availBal String Available balance of the currency
    >> frozenBal String Frozen balance of the currency
    >> ordFrozen String Margin frozen for open orders
    >> liab String Liabilities of the currency. Not enabled. Please disregard.
    >> upl String Unrealized profit and loss of the currency. Not enabled. Please disregard.
    >> uplLiab String Liabilities due to Unrealized loss of the currency. Not enabled. Please disregard.
    >> crossLiab String Cross Liabilities of the currency. Not enabled. Please disregard.
    >> isoLiab String Isolated Liabilities of the currency. Not enabled. Please disregard.
    >> mgnRatio String Margin ratio of the currency. Not enabled. Please disregard.
    >> interest String Interest of the currency. Not enabled. Please disregard.
    >> twap String System is forced repayment(TWAP) indicator. Not enabled. Please disregard.
    >> maxLoan String Max loan of the currency. Not enabled. Please disregard.
    >> eqUsd String Equity usd of the currency
    >> notionalLever String Leverage of the currency. Not enabled. Please disregard.
    >> coinUsdPrice String Price index usd of the currency
    >> stgyEq String strategy equity
    >> isoUpl String Isolated unrealized profit and loss of the currency. Not enabled. Please disregard.
    >> spotInUseAmt String Spot in use amount. Not enabled. Please disregard.
    "" will be returned for inapplicable fields under the current account level.

    When multiple orders are being executed at the same time, the changes of account data will be aggregated into one as much as possible.

    Initial snapshot: Only currencies with non-zero balance will be pushed. Definition of non-zero balance: any value of eq, availEq, availBql parameters is not 0.

    Data pushed in regular interval: Only currencies with non-zero balance will be pushed. Definition of non-zero balance: any value of eq, availEq, availBql parameters is not 0.

    For example, when subscribing to account channel without specifying ccy and there are 5 currencies are with non-zero balance, all 5 currencies data will be pushed in initial snapshot and in regular interval. Subsequently when there is change in balance or equity of an token, only the incremental data of that currency will be pushed triggered by this change.

    Information on crypto with a balance less than 1e-8 won't be included in "details".

    Order channel

    Retrieve order information. Data will not be pushed when first subscribed. Data will only be pushed when triggered by events such as placing/canceling order.

    Request Example : single

    {
        "op": "subscribe",
        "args": [{
            "channel": "orders",
            "instType": "SPOT",
            "instId": "BTC-USD"
        }]
    }
    

    Request parameters

    Parameter Type Required Description
    op String Yes Operation, subscribe unsubscribe
    args Array Yes List of subscribed channels
    > channel String Yes Channel name, orders
    > instType String Yes Instrument type
    SPOT
    > instId String No Instrument ID

    Successful Response Example : single

    {
        "event": "subscribe",
        "arg": {
            "channel": "orders",
            "instType": "SPOT",
            "instId": "BTC-USD"
        }
    }
    

    Failure Response Example

    {
      "event": "error",
      "code": "60012",
      "msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"orders\", \"instType\" : \"SPOTT\"}]}"
    }
    

    Response parameters

    Parameter Type Required Description
    event String Yes Event, subscribe unsubscribe error
    arg Object No Subscribed channel
    > channel String Yes Channel name
    > instType String Yes Instrument type
    SPOT
    > instId String No Instrument ID
    code String No Error code
    msg String No Error message

    Push Data Example: single

    {
        "arg": {
            "channel": "orders",
            "instType": "SPOT",
            "instId": "ETH-USD",
            "uid": "1300041872592896"
        },
        "data": [
            {
                "accFillSz": "0",
                "amendResult": "",
                "avgPx": "0",
                "cTime": "1672898607313",
                "category": "normal",
                "ccy": "",
                "clOrdId": "",
                "code": "0",
                "execType": "",
                "fee": "0",
                "feeCcy": "ETH",
                "fillFee": "0",
                "fillFeeCcy": "",
                "fillNotionalUsd": "",
                [Page truncated to keep GeezerVison snappy.]

    You are visitor 01402792 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.