NAV

Introduction

Welcome

Welcome to the YAX Exchange API v1 reference documentation.

The YAX Exchange API v1 offers developers access to both REST and WebSocket APIs, accommodating various applications and functionalities. The majority of API calls are accessible through both mediums, featuring consistent request and response formats, which aids in a seamless transition and a diminished learning curve between the two platforms.

For each relevant API call, detailed information is provided on both the request and response parameters, all presented in a straightforward JSON format.

This documentation aims to provide developers with the necessary tools and knowledge to effectively integrate and interact with the YAX Exchange platform, enabling the creation of diverse and powerful applications.

API Key Set Up

You can set up your API key by logging into your account, navigating to the Profile page, and selecting the "API" tab. You will be prompted to enter your private key, configure the permissions for your API key, and set up the IP whitelist.

Contact Us

Should you encounter any issues with the APIs, we encourage you to submit a ticket by visiting YAX.HK.

Alternatively, you are welcome to reach out for assistance by sending an email to help@yax.hk. We are committed to addressing your concerns and ensuring a smooth user experience.

Change Logs

General Information

Rest API Root Endpoint

Production

https://api.yax.hk/

Sandbox

https://api-uat.yax.global/

Websocket Root Endpoint

Public

Production:

wss://api.yax.hk/stream/public

Testnet:

wss://uat-api.yax.global/stream/public

Private

Production:

wss://api.yax.hk/stream/private

Testnet:

wss://uat-api.yax.global/stream/private

Authentication

REST API

A signature can be generated using the following codes:

func (c *Client) Payload() string {
    return fmt.Sprintf("%s|%d", c.Ver, time.Now().Unix())
}
func (c *Client) GenSign(payload string) (sign string, err error) {
    block, _ := pem.Decode([]byte(c.PrivateKey))
    if block == nil {
       fmt.Println("pem.Decode err")
       return
    }
    var private interface{}
    private, err = x509.ParsePKCS8PrivateKey(block.Bytes)
    if err != nil {
       return
    }
    privateKey := private.(*rsa.PrivateKey)
    //h := crypto.Hash.New(crypto.SHA1)
    h := sha1.New()
    h.Write([]byte(payload))
    hashed := h.Sum(nil)
    signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA1, hashed)
    if err != nil {
       return
    }
    sign = base64.StdEncoding.EncodeToString(signature)
    return
}
// gen X-ApiClient-Auth method
func (c *Client) APIClientAuth() (string, error) {
    payload := c.Payload()
    sign, err := c.GenSign(payload)
    if err != nil {
       return "", err
    }
    return fmt.Sprintf("%s|%s", payload, sign), nil
}

You will need to include the following headers in your API calls for authentication, when you are calling private endpoints.

Key Value
Authorization Bearer MID:${api_key}
X-ApiClient-Auth ${ver}|${timestamp}|${signature}
Name Description
api_key assigned by YAX
ver use default value 0
timestamp unix time stamp in second. for example 1761204315
signature signature. Use SHA1 to hash "${ver}|${timestamp}" (for example "0|1761204315") with you private key of the RSA key pair you generated. Encode to base64

Websocket

Use the following code to authenticate during establishing a connection

{
    "op": "auth",
    "args": ["{{apiKey}}","{{apiToken}}"]
}

Where

Rate Limit

YAX imposes a rate limit on its APIs. Each customer has a default limit of 120 requests per minute, with a specific weight assigned to each endpoint. The weight represents the quota consumed by each API call. Endpoints that require more server resources have higher weights.

For example, if an endpoint has a weight of 2 and your total rate limit is 120 per minute, you can call that endpoint 60 times per minute.

If you exceed your rate limit, your request will be rejected by the server and an error code will be returned. Repeatedly exceeding the rate limit may result in your IP address being temporarily banned by the server. The duration of the IP ban will be indicated in the response header under the Retry-After field.

Market Data

get-candles

Request Sample

curl -X GET 'https://api-uat.yax.global/quote/v1/BTC.USDT/candles?resolution=300' \
  -H 'Accept: application/json'

The above command returns JSON structured like this:

{
    "data": [
        {
            "startTime": "1693554180000",
            "open": "26157.71000",
            "close": "26157.71000",
            "high": "26157.71000",
            "low": "26157.71000",
            "volume": "0.00000"
        }
    ],
    "symbol": "BTC.USDT",
    "resolution": 60,
    "timestamp": "1693554195091"
}

Get Candles

Get historic data for a symbol.

HTTP Request

GET /v1/{symbol}/candles

Weight: 1

Query Parameters

Name In Type Required Description
Resolution query integer true window length in seconds. Values must be one of {60, 300, 900, 3600, 21600, 86400}
start_time query number false none
end_time query number false none
body body object false none
symbol path string true name of the symbol

Responses

Status Meaning Description Schema
200 OK User Found Inline
201 Created Created Inline
400 Bad Request User Found Inline
404 Not Found User Not Found Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
data [object] false none none
startTime string true none start time of the window
open string true none mark price at startTime
close string true none mark price at the end of the window: startTime + resolution
high string true none highest mark price over the window
low string true none lowest mark price over the window
volume string true none volume traded in the window

get-orderbook

Request Sample

curl -X GET 'https://api-uat.yax.global/quote/v1/BTC.USDT/orderbook' \
  -H 'Accept: application/json'

The above command returns JSON structured like this:

{
    "asks": [
        [
            "26157.71",
            "0.00420"
        ],
        [
            "26170.79",
            "0.01567"
        ],
        [
            "26183.87",
            "0.02401"
        ]
    ],
    "bids": [
        [
            "26153.78",
            "0.00047"
        ],
        [
            "26140.70",
            "0.01408"
        ],
        [
            "26127.63",
            "0.02186"
        ]
    ],
    "timestamp": "1693554347618"
}

Get Orderbook

Get orderbook for a given symbol. The tuple is like ["price", "volume"]

HTTP Request

GET /v1/{symbol}/orderbook

Weight: 1

Parameters

Name In Type Required Description
depth query integer false max 5000. If limit > 5000, then the response will truncate to 5000.
grouping query number false none
symbol path string true symbol name

Responses

Status Meaning Description Schema
200 OK None Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» asks [array] false none none
» bids [array] false none none

get-ticker

Request Sample

curl -X GET 'https://api-uat.yax.global/quote/v1/BTC.USDT/ticker' \
  -H 'Accept: application/json'

The above command returns JSON structured like this:

{
    "ask": "26157.71",
    "bid": "26153.78",
    "last": "26157.71",
    "volume": "1.24",
    "highest24hours": "27533.37",
    "lowest24hours": "26140.70",
    "change24hours": "-1087.69",
    "changePercent24hours": "-3.99",
    "timestamp": "1693554328551"
}

Get Ticker

Get ticker data for a symbol

HTTP Request

GET /v1/{symbol}/ticker

Weight: 1

Parameters

Name In Type Required Description
symbol path string true symbol

Responses

Status Meaning Description Schema
200 OK OK Ticker
Unknown none Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» ask string false none best ask
» bid string false none best bid
» last string false none last traded price
» volume string false none 24 hours trading volume
» highest24hours string false none highest price in last 24 hours
» lowest24hours string false none lowest price in last 24 hours

get-trades

curl -X GET 'https://api-uat.yax.global/quote/v1/BTC.USDT/trades' \
  -H 'Accept: application/json'

The above command returns JSON structured like this:

{
    "data": [
        {
            "id": "1500546",
            "price": "27264.60",
            "volume": "0.00001",
            "time": "1693427168163",
            "side": "ask"
        },
        {
            "id": "1500545",
            "price": "27263.23",
            "volume": "0.00005",
            "time": "1693427166086",
            "side": "bid"
        }
    ],
    "timestamp": "1693556362614"
}

Get Trades

Gets a list of trades of a symbol for a given window or starting id. If start_time or end_time is not specified, return the latest 40 trades.

HTTP Request

GET /v1/{symbol}/trades

Weight: 1

Parameters

Name In Type Required Description
start_time query string false start time of the window
end_time query string false end time of the window, if not set, return the recent
id query number false none
symbol path string true none

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» data [Trade] false none none
»» id number true none none
»» price string true none none
»» volume string true none none
»» time string true none none
»» side string true none
Property Value
side ask
side bid

Order

get-orders

Request Sample

curl -X GET 'https://api-uat.yax.global/orders?segmentIndex=string' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": [
        {
            "id": "31988106419240960",
            "clientOrderId": "31988106419240960-2",
            "secType": "SPOT",
            "symbol": "BTC.USDT",
            "currency": "USDT",
            "side": "BUY",
            "timeInForce": "GTC",
            "postOnly": false,
            "totalQuantity": "0.00002",
            "filledQuantity": "0.00000",
            "totalQuoteQuantity": "0.0527778",
            "filledQuoteQuantity": "0.0000000",
            "type": "LMT",
            "price": "2638.89",
            "stopPrice": "0.00",
            "avgFillPrice": "0.00",
            "status": "Canceled",
            "replaceStatus": "NONE",
            "cancelStatus": "NONE",
            "realizedPnl": "0.00",
            "commissionAndFee": "0",
            "liquidation": false,
            "message": "Cancelled by manual",
            "statusUpdatedAt": "1692949105",
            "updatedAt": "1692949105",
            "createdAt": "1692949084",
            "canModify": false,
            "canCancel": false,
            "params": {
                "orderOpPartition": "0",
                "execRptPartition": "0"
            },
            "source": "web",
            "externalId": "1692949083724"
        }
    ],
    "timestamp": "1693557194514"
}

Query orders

HTTP Request

GET /orders

Weight: 1

Parameters

Name In Type Required Description
segmentIndex query string true Sub-account serial number
sinceDate query string false since created timestamp
toDate query string false to created timestamp
symbol query string false symbol
queryStatuses query array false query statuses
orderBy query string false order by
lastOrderId query string false The order id of the last query
limit query string false Query Quantity Limit

Enumerated Values

Parameter Value
queryStatuses ACTIVE
queryStatuses INACTIVE
queryStatuses FILLED
orderBy LATEST_STATUS_UPDATED
orderBy LATEST_CREATED
orderBy LATEST_ID

Responses

Status Meaning Description Schema
200 OK Query orders success Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» data [Order] false none none
»» Order Order false none none
»»» id string true none order id
»»» secType string true none security type
»»» symbol string true none symbol
»»» currency string true none currency
»»» side string true none Buying and selling direction
»»» postOnly boolean true none Is it a market order
»»» timeInForce string true none time in force
»»» totalQuantity number false none order base currency quantity
»»» filledQuantity number false none order base currency filled quantity
»»» totalQuoteQuantity number false none order quote currency quantity
»»» filledQuoteQuantity number false none order quote currency filled quantity
»»» type string true none order type
»»» price number false none order limit price
»»» stopPrice number false none stop price
»»» avgFillPrice number false none average filled price
»»» status string true none order statu
»»» replaceStatus string false none order replace status
»»» cancelStatus string false none cancel status
»»» commissionAndFee number false none commission and Fee
»»» liquidation boolean false none is it liquidation order
»»» message string false none Prompt message
»»» statusUpdatedAt integer true none order status update timestamp
»»» updatedAt integer true none order update timestamp
»»» createdAt integer true none order create timestamp
»»» canModify boolean true none Can the order be modified
»»» canCancel boolean true none Can the order be cancelled
»»» source string false none Order source
» timestamp string false none none

post-orders

Request Sample

curl --request POST \
  --url 'https://trade-aws1.test.exodushk.com/orders' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'\
  --data '{
  "segmentIndex": 0,
  "side": "BUY",
  "type": "LMT",
  "timeInForce": "GTC",
  "quantity": 0,
  "quoteQuantity": 0,
  "stopPrice": 0,
  "price": 0,
  "secType": "SPOT",
  "symbol": "string",
  "clientOrderId": "string",
  "externalId": "string",
  "postOnly": true
}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": {
        "id": "32067915935776768",
        "clientOrderId": "32067915935776768-0",
        "secType": "SPOT",
        "symbol": "BTC.USDT",
        "currency": "USDT",
        "side": "BUY",
        "timeInForce": "GTC",
        "postOnly": false,
        "totalQuantity": "0.00100",
        "filledQuantity": "0.00000",
        "totalQuoteQuantity": "26.1577100",
        "filledQuoteQuantity": "0.0000000",
        "type": "LMT",
        "price": "26157.71",
        "stopPrice": "0.00",
        "avgFillPrice": "0.00",
        "status": "PendingNew",
        "replaceStatus": "NONE",
        "cancelStatus": "NONE",
        "realizedPnl": "0.00",
        "commissionAndFee": "0",
        "liquidation": false,
        "message": "",
        "statusUpdatedAt": "1693557982",
        "updatedAt": "1693557982",
        "createdAt": "1693557982",
        "canModify": true,
        "canCancel": true,
        "source": "web",
        "externalId": "1693557982104"
    },
    "timestamp": "1693557982476"
}

Place Order

Gets a list of trades of a symbol for a given window or starting id. If start_time or end_time is not specified, return the latest 40 trades.

HTTP Request

POST /orders

Weight: 1

Parameters

Name In Type Required Description
body body object true Place order request
» segmentIndex body integer true Sub-account serial number
» side body string true Buying and selling direction
» type body string false order type, default value is "LMT"
» timeInForce body string false time in force, default value is "GTC"
» quantity body number true order base currency quantity
» stopPrice body number false stop price
» price body number false order limit price
» secType body string false order limit price
» symbol body string true symbol
» clientOrderId body string false client order id
» externalId body string false external Id for order deduplication, generated by the client, please make sure that each request has a unique externalId
» postOnly body boolean false Is it a market order

Enumerated Values

Parameter Value
» side BUY
» side SELL
» type LMT
» type MKT
» type STP
» type STP_LMT
» timeInForce GTC
» timeInForce IOC
» secType SPOT

Responses

Status Meaning Description Schema
200 OK Place order success

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg string false none none
» data Order true none none
»» id string true none order id
»» secType string true none security type
»» symbol string true none symbol
»» currency string true none currency
»» side string true none Buying and selling direction
»» postOnly boolean true none Is it a market order
»» timeInForce string true none time in force
»» totalQuantity number true none order base currency quantity
»» filledQuantity number true none order base currency filled quantity
»» totalQuoteQuantity number false none order quote currency quantity
»» filledQuoteQuantity number false none order quote currency filled quantity
»» type string true none order type
»» price number false none order limit price
»» stopPrice number false none stop price
»» avgFillPrice number false none average filled price
»» status string true none order status
»» replaceStatus string false none order replace status
»» cancelStatus string false none cancel status
»» commissionAndFee number false none commission and Fee
»» liquidation boolean false none is it liquidation order
»» message string false none Prompt message
»» statusUpdatedAt integer true none order status update timestamp
»» updatedAt integer true none order update timestamp
»» createdAt integer true none order create timestamp
»» canModify boolean true none Can the order be modified
»» canCancel boolean true none Can the order be cancelled
»» source string false none Order source
» timestamp string false none none

post-orders-cancel

Request Sample

curl -X POST 'https://api-uat.yax.global/orders/cancel' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}' \
  --data '{
  "segmentIndex": 0,
  "orderId": 2124343243534346
}

The above command returns JSON structured like this:

{
  "status": "ok",
  "msg": "ok",
  "timestamp": "1693557982476"
}

Cancel order

HTTP Request

POST /orders/cancel

Weight: 1

Parameters

Name In Type Required Description
body body object false Cancel order request
» segmentIndex body integer false Sub-account serial number
» orderId body integer false order id
» origClientOrderId body string false client origin order id
» clientOrderId body string false client order id

Responses

Status Meaning Description Schema
200 OK Submit cancel request success Inline

Response Schema Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» timestamp string false none none

post-orders-modify

Request Sample

curl -X POST 'https://api-uat.yax.global/orders/modify' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}' \
  --data '{
    "orderId": "32068130867773440",
    "segmentIndex": 0,
    "price": "26150.01",
    "quantity": "0.00200"
  }'

The above command returns JSON structured like this:

{
  "status": "string",
  "msg": "string",
  "timestamp": "string"
}

Modify an existing order

HTTP Request

POST /orders/modify

Weight: 1

Parameters

Name In Type Required Description
body body object true Modify order request
» segmentIndex body integer true Sub-account serial number
» orderId body integer false order id
» quantity body integer false order base currency quantity
» price body number false order limit price
» stopPrice body number false stop price
» origClientOrderId body string false client origin order id
» clientOrderId body string false client order id

Responses

Status Meaning Description Schema
200 OK submit modify request success Inline

Response Schema Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» timestamp string false none none

get-orders-{id}

Request Sample

curl -X GET 'https://api-uat.yax.global/orders/{id}' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "string",
  "msg": "string",
  "data": {
    "order": {
      "id": "string",
      "secType": "string",
      "symbol": "string",
      "currency": "string",
      "side": "string",
      "postOnly": true,
      "timeInForce": "string",
      "totalQuantity": 0,
      "filledQuantity": 0,
      "totalQuoteQuantity": 0,
      "filledQuoteQuantity": 0,
      "type": "string",
      "price": 0,
      "stopPrice": 0,
      "avgFillPrice": 0,
      "status": "string",
      "replaceStatus": "string",
      "cancelStatus": "string",
      "commissionAndFee": 0,
      "liquidation": true,
      "message": "string",
      "statusUpdatedAt": 0,
      "updatedAt": 0,
      "createdAt": 0,
      "canModify": true,
      "canCancel": true,
      "source": "string"
    },
    "trades": [
      {
        "id": "string",
        "symbol": "string",
        "orderId": "string",
        "side": "string",
        "quantity": "string",
        "price": "string",
        "quoteQuantity": "string",
        "commissionAndFee": 0,
        "commissionCurrency": 0,
        "transactedAt": 0,
        "maker": true
      }
    ]
  },
  "timestamp": "string"
}

Get order details

HTTP Request

GET /orders/{id}

Weight: 1

Parameters

Name In Type Required Description
id path string true none

Responses

Status Meaning Description Schema
200 OK Get order details success Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» data object false none none
»» order Order false none none
»»» id string true none order id
»»» secType string true none security type
»»» symbol string true none symbol
»»» currency string true none currency
»»» side string true none Buying and selling direction
»»» postOnly boolean true none Is it a market order
»»» timeInForce string true none time in force
»»» totalQuantity number false none order base currency quantity
»»» filledQuantity number false none order base currency filled quantity
»»» totalQuoteQuantity number false none order quote currency quantity
»»» filledQuoteQuantity number false none order quote currency filled quantity
»»» type string true none order type
»»» price number false none order limit price
»»» stopPrice number false none stop price
»»» avgFillPrice number false none average filled price
»»» status string true none order status
»»» replaceStatus string false none order replace status
»»» cancelStatus string false none cancel status
»»» commissionAndFee number false none commission and Fee
»»» liquidation boolean false none is it a liquidation order
»»» message string false none Prompt message
»»» statusUpdatedAt integer true none order status update timestamp
»»» updatedAt integer true none order update timestamp
»»» createdAt integer true none order create timestamp
»»» canModify boolean true none Can the order be modified
»»» canCancel boolean true none Can the order be cancelled
»»» source string false none Order source
»» trades [Trade] false none none
»»» Trade Trade false none none
»»»» id string true none trade id
»»»» symbol string true none symbol
»»»» orderId string true none order id
»»»» side string true none Buying and selling direction
»»»» quantity string true none order base currency quantity
»»»» price string true none average filled price
»»»» quoteQuantity string true none order quote currency filled quantity
»»»» commissionAndFee number true none commission and Fee
»»»» commissionCurrency number true none commission currency
»»»» transactedAt integer true none transaction time
»»»» maker boolean true none Is it a market maker order
» timestamp string false none none

Portfolio

get-portfolios

Request Sample

curl --request GET \
  --url 'https://trade-aws1.test.exodushk.com/portfolios?segmentIndexes=0,1' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": [
        {
            "segmentIndex": 0,
            "canMargin": true,
            "currency": "USD",
            "balance": "1001559327888857415.64",
            "equityWithLoan": "1001559327888875104.98",
            "excessEquity": "1001207462311119526.64",
            "availableEE": "1001207462311008680.14",
            "lockedEE": "110846.51",
            "balances": [
                {
                    "currency": "BTC",
                    "balance": "42.56095",
                    "availableEE": "36.17652",
                    "availableCash": "42.56095",
                    "borrow": "0",
                    "locked": "0.00029",
                    "accruedInterest": "0.00000",
                    "balanceBaseToAssignedCurrency": "1129544.46"
                }
            ]
        },
      {
            "segmentIndex": 1,
            "canMargin": true,
            "currency": "USD",
            "balance": "1001559327888857415.64",
            "equityWithLoan": "1001559327888875104.98",
            "excessEquity": "1001207462311119526.64",
            "availableEE": "1001207462311008680.14",
            "lockedEE": "110846.51",
            "balances": [
                {
                    "currency": "BTC",
                    "balance": "42.56095",
                    "availableEE": "36.17652",
                    "availableCash": "42.56095",
                    "borrow": "0",
                    "locked": "0.00029",
                    "accruedInterest": "0.00000",
                    "balanceBaseToAssignedCurrency": "1129544.46"
                }
            ]
        }

    ],
    "timestamp": "1693560616880"
}

Get segment portfolios

HTTP Request

GET /portfolios

Weight: 1

Parameters

Name In Type Required Description
segmentIndexes query array true Sub-account serial number(子账户序号)

Responses

Status Meaning Description Schema
200 OK Get segment portfolios success Inline

Response Schema

Status Code 200

Parameter Type Status Description
status string false none
msg string false none
data [object] false none
> currency string false Account Asset Calculation Currency Type
> balance integer false Balance
> equityWithLoan integer false Equity with Loan Value
> netLiquidation integer false Net Liquidation
> initMarginReq integer false Initial Margin Requirement
> initRiskRatio integer false Initial Margin Ratio
> maintainMarginReq integer false Maintenance Margin Requirement
> maintainRiskRatio integer false Maintenance Margin Ratio
> leverage integer false Leverage Ratio
> excessEquity integer false Excess Equity
> excessLiquidation integer false Excess Liquidation
> availableEE integer false Available Excess Equity
> lockedEE integer false Locked Equity
> balances [object] false Balance Details
> > currency string false Currency
> > balance integer false Balance
> > availableEE integer false Available Excess Equity
> > borrow integer false Borrowed Quantity
> > locked integer false Locked Asset
> > accruedInterest integer false Accrued Interest
> > balanceBaseToAssignedCurrency integer false Balance in Assigned Base Currency
> positions [object] false none
> > symbol string false Asset Symbol
> > expiry string false Expiry Date
> > strike string false Strike Price
> > right string false Option Right
> > multiplier string false Multiplier
> > latestPrice string false Current Market Price
> > secType string false Security Type
> > quantity string false Quantity
> > averageCost string false Average Cost
> > marketValue string false Market Value
> > unrealPnl string false Unrealized Profit/Loss
> > unrealPnlPercent string false Unrealized Profit/Loss Percentage
timestamp string false none

OTC Trades

get-orders

Request Sample

curl -X GET 'https://api-uat.yax.global/otc/order/query' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "ok",
  "msg": "ok",
  "data": {
    "pageNum": 1,
    "pageSize": 20,
    "itemCount": 12,
    "pageCount": 1,
    "items": [
      {
        "id": 5,
        "accountId": 99453841,
        "symbol": "USDT.USD",
        "totalQuantity": 123,
        "price": 123,
        "action": "BUY",
        "status": "REJECTED",
        "createDate": 1736234779000
      }
    ],
    "hideItemCount": false
  },
  "timestamp": 1736424287173
}

query orders of otc trades

HTTP Request

GET /otc/order/query

Weight: 1

Parameters

Name In Type Required Description
accountId query string true accountId
segmentIndex query string false Sub-account serial number default 1
createDateStart query string false time format: yyyy-MM-dd HH:mm:ss
createDateEnd query string false time format: yyyy-MM-dd HH:mm:ss
pageNum query integer false page number
pageSize query integer false size of each page
symbol query string false e.g. USDT.USD
action query string false BUY / SELL

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» data [Order] false none none
»» pageNum integer false none Current page number
»» pageSize integer false none Number of items per page
»» itemCount integer false none Total number of items
»» pageCount integer false none Total number of pages
»» items [Order] false none List of order items
»» hideItemCount boolean false none Whether item count is hidden
»»» Trade Trade false none none
»»» id integer true none trade id
»»» accountId integer true none account id
»»» symbol string true none trading symbol
»»» totalQuantity integer true none total quantity of the order
»»» price integer true none trade price
»»» action string true none BUY or SELL action
»»» status string true none Trade status
»»» createDate integer true none Trade creation timestamp
» timestamp integer false none Response timestamp

Trades

get-trades

Request Sample

curl -X GET 'https://api-uat.yax.global/trades' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "string",
  "msg": "string",
  "data": [
    {
      "id": "string",
      "symbol": "string",
      "orderId": "string",
      "side": "string",
      "quantity": "string",
      "price": "string",
      "quoteQuantity": "string",
      "commissionAndFee": "string",
      "commissionCurrency": "string",
      "transactedAt": 0,
      "maker": true
    }
  ],
  "timestamp": "string"
}

query trades

HTTP Request

GET /trades

Weight: 1

Parameters

Name In Type Required Description
orderId query string false trade id
segmentIndex query string false Sub-account serial number
sinceId query string false since trade id
toId query string false to trade id
limit query string false Query Quantity Limit
startTime query string false since created timestamp
endTime query string false to created timestamp

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string false none none
» msg string false none none
» data [Trade] false none none
»» Trade Trade false none none
»»» id string true none trade id
»»» symbol string true none symbol
»»» orderId string true none order id
»»» side string true none Buying and selling direction
»»» quantity string true none order base currency quantity
»»» price string true none average filled price
»»» quoteQuantity string true none order quote currency filled quantity
»»» commissionAndFee string true none commission and Fee
»»» commissionCurrency string true none commission currency
»»» transactedAt integer true none transaction time
»»» maker boolean true none Is it a market maker order
» timestamp string false none none

Withdrawal

query-withdrawal-balance(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/withdrawal/balance?
cryptoCode=USDT&segmentIndex=0&allowMargin=false'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": 10000.00,
    "errorData": null,
    "timestamp": 1663668852702
}

Query withdrawal balance of current account

HTTP Request

GET /treasury_funding/withdrawal/balance

Weight: 1

Parameters

Name In Type Required Description
segmentIndex query Integer false The segment index of the Sub-account which you want to withdraw balance from, default 0
cryptoCode query String true The code of the currency to be transferred. e.g, BTC
allowMargin query Boolean false Is allow margin, default false

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

commit-withdrawal(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/withdrawal/commit'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'\
  --data '{
      "externalId":"12345",
      "cryptoCode":"USDT",
      "segmentIndex":0,
      "amount":1200,
      "toNetwork":"Ethereum",
      "toAddress":"0x1234567890abcdef1234567890abcdef12345678",
      "feeLevel":"MEDIUM",
      "allowMargin":false
  }
  '

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": {
      "id": 8,
      "externalId": "12345",
      "status": "PENDING",
      "cryptoCode": "USDT",
      "amount": 1200,
      "fee": 0.1,
      "toNetwork": "Ethereum",
      "toAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "feeLevel": "MEDIUM",
      "allowMargin": false,
      "createdAt": "2022-09-23 11:11:11",
      "updatedAt": "2022-09-23 11:11:11"
    },
    "errorData": null,
    "timestamp": 1663668852702
}

Commit withdrawal

HTTP Request

POST /treasury_funding/withdrawal/commit

Weight: 1

Parameters

Name In Type Required Description
externalId body String true Withdrawal unique key
segmentIndex body Integer false The segment index of the Sub-account which you want to withdraw balance from, default 0
cryptoCode body String true The code of the currency to be transferred. e.g, BTC
allowMargin body Boolean false Is allow margin, default false
amount body BigDecimal true The amount of the currency to be transferred. e.g,100. There is a minimum limit for withdrawal amount, which can be checked on the official website
toNetwork body String true Withdrawal network
toAddress body String true Withdrawal address, you need to complete the whitelist registration through the web terminal
feeLevel body String false Fee level model, default MEDIUM, such as LOW, MEDIUM, HIGH

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

cancel-withdrawal-by-externalId(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/withdrawal/cancel/externalId/{externalId}'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

Cancel withdrawal

HTTP Request

POST /treasury_funding/withdrawal/cancel/externalId/{externalId}

Weight: 1

Parameters

Name In Type Required Description
externalId path Long true The externalId of withdrawal to be cancelled

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

list-withdrawal(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/withdrawal/list?toAddress=txcdacdsacaacda&cryptoCode=ETH'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "ok",
  "msg": "ok",
  "data": {
    "pageNum": 1,
    "pageSize": 10,
    "itemCount": 1,
    "pageCount": 1,
    "items": [
      {
        "id": 8,
        "externalId": "txg0001",
        "status": "PENDING",
        "cryptoCode": "USDT",
        "amount": 1200,
        "fee": 0.1,
        "toNetwork": "Ethereum",
        "toAddress": "0x1234567890abcdef1234567890abcdef12345678",
        "feeLevel": "MEDIUM",
        "allowMargin": false,
        "createdAt": "2022-09-23 11:11:11",
        "updatedAt": "2022-09-23 11:11:11"
      }
    ]
  },
  "errorData": null,
  "timestamp": 1663668852702
}

List withdrawal

HTTP Request

GET /treasury_funding/withdrawal/list

Weight: 1

Parameters

Name In Type Required Description
id query Long false Withdrawal ID
externalId query String false Withdrawal unique key
segmentIndex query Integer false The segment index of the Sub-account which you want to withdraw balance from
cryptoCode query String false The code of the currency to be transferred. e.g, BTC
cryptoNetwork query String false withdrawal network
toAddress query String false Withdrawal to address
feeLevel query String false Fee level model, default MEDIUM, such as LOW, MEDIUM, HIGH
status query List false withdrawal status, Requested,Canceling,Sending On Chain, Rejected, Failed, Cancelled, Complete
amountMin query BigDecimal false Minimum amount in range query
amountMax query BigDecimal false Maximum amount in range query
createDateStart query String false Start time for creation time query,like'2022-09-23 11:11:11'
createDateEnd query String false End time for creation time query,like'2022-09-23 11:11:11'
updateDateStart query String false Start time for Update time query,like'2022-09-23 11:11:11'
pageSize query Integer false Item count per page, default 20
pageCount query Integer false Page number, default 0

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

Deposit

query-deposit-address(treasury_funding)

Request Sample

curl -X GET 'https://api-uat.yax.global/treasury_funding/client/deposit/address/query/{cryptoNetwork}'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": {
      "accountId": "1",
      "accountName": "hhh",
      "cryptoNetwork": "Ethereum",
      "address": "XXXXXXXXXXXXXXXXXXXX",
      "walletId": "sdsdsdsd",
      "vaultId": "hhh:1:xxx",
      "serialNo": 1
    },
    "errorData": null,
    "timestamp": 1663668852702
}

Query deposit address of current account

HTTP Request

GET /treasury_funding/client/deposit/address/query/{cryptoNetwork}

Weight: 1

Parameters

Name In Type Required Description
cryptoNetwork path String true Network of deposit address

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

query-deposit-list(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/deposit/list?toAddress=txcdacdsacaacda&currencyCode=ETH'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "ok",
  "msg": "ok",
  "data": {
    "pageNum": 1,
    "pageSize": 10,
    "itemCount": 1,
    "pageCount": 1,
    "items": [
      {
        "id": 1,
        "transactionId":"123333adc",
        "txId": "dddddddddddd",
        "accountId": 111111,
        "accountName": "Exodus",
        "fromAddress": "dfadfadcdsacdsac",
        "toAddress": "scdascdscadscdscd",
        "cryptoId": 111,
        "cryptoCode": "USDT",
        "cryptoNetwork": "ETH",
        "amount": 100000.0000,
        "tagMemo": "",
        "status": 1,
        "message": "",
        "createAt": "2022-09-23 11:11:11",
        "updateAt": "2022-09-23 11:11:13"
      }
    ]
  },
  "errorData": null,
  "timestamp": 1663668852702
}

List deposit

HTTP Request

GET /treasury_funding/deposit/list

Weight: 1

Parameters

Name In Type Required Description
id query Long false Deposit ID
currencyCode query String false The code of the currency deposited. e.g, BTC
cryptoNetwork query String false Deposit network
fromAddress query String false Deposit from address
toAddress query String false Deposit to address
txHash query String false Transaction hash of deposit
status query List false Deposit status, New, Unmatched, Pending,Failed, Success
amountMin query BigDecimal false Minimum amount in range query
amountMax query BigDecimal false Maximum amount in range query
createDateStart query String false Start time for creation time query,like'2022-09-23 11:11:11'
createDateEnd query String false End time for creation time query,like'2022-09-23 11:11:11'
updateDateStart query String false Start time for Update time query,like'2022-09-23 11:11:11'
pageSize query Integer false Item count per page, default 20
pageCount query Integer false Page number, default 0

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

Account Transfer

create-sub-account-transfer(treasury_funding)

Request Sample

curl -X POST 'https://api-uat.yax.global/treasury_funding/account/transfer/create'\
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'
  --data '{
      "externalId":"12345",
      "cryptoCode":"USDT",
      "segmentIndex":0,
      "toSegmentIndex":1,
      "amount":1200,
  }
  '

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": {
      "id": 1,
      "externalId": "12345",
      "accountId": 1,
      "accountName": "17 09",
      "segmentIndex": 0,
      "toSegmentIndex": 0,
      "cryptoCode": "ETH",
      "amount": 1200,
      "fee": 0E-20,
      "status": "SUCCESS",
      "allowMargin": false,
      "deductionTime": "2022-09-20T10:14:11.000+0000",
      "auditAccountId": 0,
      "auditMessage": "",
      "tagMemo": null,
      "createdAt": "2022-09-20T10:14:11.000+0000",
      "updatedAt": "2022-09-20T10:14:12.000+0000"
    },
    "errorData": null,
    "timestamp": 1663668852702
}

Create account transfer between Sub-Accounts (segments)

HTTP Request

POST /treasury_funding/account/transfer/create

Weight: 1

Parameters

Name In Type Required Description
externalId body String true Unique key of account transfer
segmentIndex body Integer false The segment index of the Sub-account which you want to transfer from
toSegmentIndex body Integer false The segment index of the Sub-account which you want to transfer to
amount body BigDecimal true The amount of the transfer
cryptoCode body String true The code of the currency to be transferred. e.g, BTC
tagMemo body String false An optional remark on the transfer

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

get-sub-account-transfer-balance(treasury_funding)

Request Sample

curl -X GET 'https://api-uat.yax.global/treasury_funding/account/transfer/withdrawn?segmentIndex=0&cryptoCode=USDT' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
    "status": "ok",
    "msg": "ok",
    "data": 11111.0001,
    "errorData": null,
    "timestamp": 1663668852702
}

Query current balance of Sub-Account (segment)

HTTP Request

GET /treasury_funding/account/transfer/withdrawn

Parameters

Name In Type Required Description
segmentIndex query Integer true The segment index of the Sub-account which you want to withdraw balance from
cryptoCode query String true The code of the currency to be transferred. e.g, BTC

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

get-sub-account-transfer(treasury_funding)

Request Sample

curl -X GET 'https://api-uat.yax.global/treasury_funding/account/transfer/list?externalId=1' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer MID:${api_key}' \
  -H 'X-ApiClient-Auth: ${ver}|${timestamp}|${signature}'

The above command returns JSON structured like this:

{
  "status": "ok",
  "msg": "ok",
  "data": {
    "pageNum": 1,
    "pageSize": 20,
    "itemCount": 1,
    "pageCount": 1,
    "items": [
      {
        "id": 10,
        "externalId": "1",
        "accountId": 89453841,
        "accountName": "w3 w4",
        "segmentIndex": 0,
        "toAccountId": 89692184,
        "toAccountName": "ww ww",
        "toSegmentIndex": 0,
        "currencyCode": "USDT",
        "amount": 1200.000000000000000000,
        "allowMargin": false,
        "fee": 0E-18,
        "status": "UPDATING_LEDGER",
        "assetLockCheckTimes": 0,
        "type": "ACCOUNT_INTERNAL_TRANSFER",
        "operator": "",
        "operatorSource": "",
        "deductionTime": 1704764565000,
        "createdAt": 1704764565000,
        "updatedAt": 1704764569000
      }
    ]
  },
  "timestamp": 1704765386715
}

Query Sub-Account (segment)

HTTP Request

GET /treasury_funding/account/transfer/list

Weight: 1

Parameters

Name In Type Required Description
id query Integer false The id of sub-account transfer
externalId query String false The unique key of sub-account transfer
segmentIndex query Integer false The source segment index of sub-account transfer
toSegmentIndex query Integer false The destination segment index of sub-account transfer
cryptoCode query String false The currency code of sub-account transfer
status query String false The status of sub-account transfer
pageCount query Integer false The page number of the data, default 0
pageSize query Integer false The page size of the data, default 20

Responses

Status Meaning Description Schema
200 OK OK Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string true none none
» msg object false none none
» data object false none none
» errorData string false none none
» timestamp string true none none

Websocket Streaming

Websocket Hearbeats

To avoid network or program issues, we recommend that you send the ping heartbeat packet every 20 seconds to maintain the WebSocket connection.

Heartbeat Example

{
    "op": "ping"
}

Pong Example

{
    "op": "pong",
    "success": true,
    "ret_msg": "pong"
}

Subscirption

You are able to subscribe to one or more topics without disconnecting the currenct Websocket conenction, as shown in the sample code.

{
    "op":"unsubscribe",
    "args":[
        "orderbook:50:BTC.USDT",
        "orderbook:1:BTC.USDT",
        "publicTrade:BTC.USDT",
        "tickers:BTC.USDT"
    ]
}

Subscription Sample Subscribing level 1 orderbook

{
    "op": "subscribe",
    "args": ["orderbook:1:BTC.USDT"]
}

Subscribing multiple topics

{
    "op":"subscribe",
    "args":[
        "orderbook:50:BTC.USDT",
        "orderbook:1:BTC.USDT",
        "publicTrade:BTC.USDT",
        "tickers:BTC.USDT"
    ]
}

You can also unsubscribe to a certain topic without disconnecting the current websocket connection. See exmaple.

Request Example

{
    "op":"unsubscribe",
    "args":[
        "orderbook:50:BTC.USDT",
        "orderbook:1:BTC.USDT",
        "publicTrade:BTC.USDT",
        "tickers:BTC.USDT"
    ]
}

Response example

{
    "op": "subscribe",
    "success": true,
    "ret_msg": ""
}
{
    "op": "subscribe",
    "success": false,
    "ret_msg": "invalid topic: bad symbol 'BTC.USDT2'"
}

OrderBook

Subscribe to the orderbook stream. Supports different depths.

TIP * Once you have subscribed successfully, you will receive a snapshot. * The WebSocket will keep pushing snapshot messages intervally.

Topic: orderbook:{depth}:{symbol} e.g., orderbook.1.BTCUSDT

Push Frequency: 1000ms

Request Sample

{
    "op": "subscribe",
    "args": ["orderbook:1:BTC.USDT"]
}

Response Sample

{
    "topic": "orderbook:1:BTC.USDT",
    "type": "snapshot",
    "ts": 1684467619306,
    "data": {
        "symbol": "BTC.USDT",
        "bids": [
            {
                "price": "22372.93000",
                "quantity": "174.33328"
            }
        ],
        "asks": [
            {
                "price": "26725.59000",
                "quantity": "0.01123"
            }
        ],
        "updateId": 547793
    }
}

Response

Parameter Type Description
topic string Topic Name
type string Data Type: snapshot, delta (currently not supported)
ts number Timestamp of Data Generation (ms)
data Object Data Object
> symbol string Currency Pair Name
> bids array Bids. For snapshot, elements are sorted in descending order of price
>> price string Bid Price
>> quantity string Bid Quantity
> asks array Asks. For snapshot, elements are sorted in ascending order of price
>> price string Ask Price
>> quantity string Ask Quantity
> updateId integer Update ID. Is a sequence.

Diff OrderBook

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

TIP * The WebSocket will keep pushing delta messages every time the orderbook changes. If you receive a new snapshot message, you will have to reset your local orderbook.

Topic: difforderbook_1000:{symbol} e.g., difforderbook_1000:BTC.USDT

Push Frequency: 100ms

How to manage a local order book correctly 1. Open a websocket stream and subscribe diff order book 2. Buffer the events you receive from the stream. 3. Get a depth snapshot from REST API https://trade.yax.hk/quote/v1/BTC.USDT/difforderbook . 4. Drop any event where endId is <= updateId in the snapshot. 5. The first processed event should have firstId <= lastUpdateId+1 AND endId >= lastUpdateId+1. 6. While listening to the stream, each new event's firstId should be equal to the previous event's endId+1. 7. The data in each event is the absolute quantity for a price level. 8. If the quantity is 0, remove the price level. 9. Receiving an event that removes a price level that is not in your local order book can happen and is normal. Note: Due to depth snapshots having a limit on the number of price levels, a price level outside the initial snapshot that doesn't have a quantity change won't have an update in the Diff. Depth Stream. Consequently, those price levels will not be visible in the local order book even when applying all updates from the Diff. Depth Stream correctly and cause the local order book to have some slight differences with the real order book. However, for most use cases the depth limit of 5000 is enough to understand the market and trade effectively.

Request Sample

{
    "op": "subscribe",
    "args": ["difforderbook_1000:BTC.USDT"]
}

Response Sample

{
    "topic": "difforderbook_1000:BTC.USDT",
    "type": "snapshot",
    "ts": 1684467619306,
    "data": {
        "symbol": "BTC.USDT",
        "asks": [
            {
                "price": "26725.59000",
                "quantity": "0.02123"
            }
        ],
        "firstId": 547793,
        "endId": 547798
    }
}

Response

Parameter Type Description
topic string Topic Name
type string Data Type: snapshot, delta (currently not supported)
ts number Timestamp of Data Generation (ms)
data Object Data Object
> symbol string Currency Pair Name
> bids array Bids to be updated
>> price string Bid Price
>> quantity string Bid Quantity
> asks array Asks to be updated
>> price string Ask Price
>> quantity string Ask Quantity
> firstId integer First Update ID. Is a sequence.
> endId integer End Update ID. Is a sequence.

Trade

Subscribe to the recent trades stream.

After subscription, you will be pushed trade messages in real-time.

Topic: publicTrade:{symbol} e.g., publicTrade:BTC.USDT

Push Frequency: real-time

Request Sample

{
    "op": "subscribe",
    "args": ["publicTrade:BTC.USDT"]
}

Response Sample

{
    "topic": "publicTrade:BTC.USDT",
    "type": "snapshot",
    "ts": 1684468619710,
    "data": {
        "id": 20139,
        "symbol": "BTC.USDT",
        "price": "26412.56000",
        "volume": "0.00008",
        "side": "Buy",
        "time": 1684231057949
    }
}

Publishes new trades for an instrument (e.g. BTC.USDT).

Response

Parameter Type Description
topic string Topic Name
type string Data Type: snapshot
ts number Timestamp of Data Generation (ms)
data Object Data Object
> time number Timestamp of Order Execution (ms)
> symbol string Currency Pair Name
> side string Taker Side: BUY, SELL
> volume string Volume of Trade
> price string Execution Price
> id string Trade ID

Ticker

Subscribe to the ticker stream.

Topic: tickers:{symbol} e.g., tickers:BTC.USDT

Push Frequency: real-time

Request Sample

{
    "op": "subscribe",
    "args": ["tickers:BTC.USDT"]
}

Response Sample

{
    "topic": "tickers:BTC.USDT",
    "type": "snapshot",
    "ts": 1684469038843,
    "data": {
        "symbol": "BTC.USDT",
        "bid": "22372.93000",
        "ask": "26593.33000",
        "last": "24412.56000"
    }
}

Publishes new tickers for an instrument (e.g. BTC.USDT).

Response

Parameter Type Description
topic string Topic Name
type string Data Type: snapshot, delta (currently not supported)
ts number Timestamp of Data Generation (ms)
data Object Data Object
> symbol string Currency Pair Name
> bid string Best Bid Price
> ask string Best Ask Price
> last string Last Traded Price

Portfolios

Subscribe to the portfolio stream to see changes to your portfolio data in real-time.

Topic: portfolio:{segmentIndex} e.g., portfolio:0, portfolio:1, portfolio:all

Push Frequency: real-time

Request Sample

{
    "op": "subscribe",
    "args": [
        "portfolio:1"
    ]
}

Response Sample

{
  "topic": "portfolio:1",
  "ts": 1695124917191,
  "data": {
    "segmentIndex": 0,
    "canMargin": false,
    "currency": "USD",
    "balance": "28969899471.47",
    "equityWithLoan": "28969899471.47",
    "netLiquidation": "28969899471.47",
    "initMarginReq": "0.00",
    "initRiskRatio": "0.0000",
    "maintainMarginReq": "0.00",
    "maintainRiskRatio": "0.0000",
    "leverage": "1.0000",
    "excessEquity": "28969899471.47",
    "excessLiquidation": "28969899471.47",
    "availableEE": "28969893463.19",
    "lockedEE": "6008.29",
    "balances": [
      {
        "currency": "BTC",
        "balance": "1000000.84958",
        "availableEE": "1000000.79601",
        "availableCash": "1000000.79601",
        "borrow": "0.00000",
        "locked": "0.00661",
        "accruedInterest": "0.00000",
        "balanceBaseToAssignedCurrency": "27138801663.06"
      },
      {
        "currency": "AAVE",
        "balance": "1000000.000",
        "availableEE": "1000000.000",
        "availableCash": "1000000.000",
        "borrow": "0.000",
        "locked": "0.000",
        "accruedInterest": "0.000",
        "balanceBaseToAssignedCurrency": "63104809.85"
      },
      {
        "currency": "UNI",
        "balance": "1000003.69",
        "availableEE": "1000003.69",
        "availableCash": "1000003.69",
        "borrow": "0.00",
        "locked": "0.00",
        "accruedInterest": "0.00",
        "balanceBaseToAssignedCurrency": "4728990.30"
      },
      {
        "currency": "SAND",
        "balance": "997040.70",
        "availableEE": "997040.70",
        "availableCash": "997040.70",
        "borrow": "0.00",
        "locked": "0.00",
        "accruedInterest": "0.00",
        "balanceBaseToAssignedCurrency": "416206.40"
      },
      {
        "currency": "APE",
        "balance": "1000000.00",
        "availableEE": "1000000.00",
        "availableCash": "1000000.00",
        "borrow": "0.00",
        "locked": "0.00",
        "accruedInterest": "0.00",
        "balanceBaseToAssignedCurrency": "2153615.34"
      },
      {
        "currency": "ETH",
        "balance": "999997.04493",
        "availableEE": "999996.00943",
        "availableCash": "999996.00943",
        "borrow": "0.00000",
        "locked": "0.18836",
        "accruedInterest": "0.00000",
        "balanceBaseToAssignedCurrency": "1759710753.92"
      },
      {
        "currency": "SHIB",
        "balance": "0",
        "availableEE": "0",
        "availableCash": "0",
        "borrow": "0",
        "locked": "0",
        "accruedInterest": "0",
        "balanceBaseToAssignedCurrency": "0.00"
      },
      {
        "currency": "USDT",
        "balance": "983334.35",
        "availableEE": "980602.34",
        "availableCash": "980602.34",
        "borrow": "0.00",
        "locked": "11.48",
        "accruedInterest": "0.00",
        "balanceBaseToAssignedCurrency": "983432.68"
      }
    ],
    "positions": [],
    "timestamp": 1695124917191
  }
}

Publishes all new balance updates for the user.

Requires initial authentication as it is a private topic (see authentication section for more information)

Topic:portfolio

Response

Parameter Type Description
topic string Topic Name
ts number Timestamp of Data Generation (ms)
data Object Data Object
> segmentIndex number Segment Index
> canMargin boolean Whether Margin Trading is Allowed
> currency string Account Asset Calculation Currency Type
> balance number Balance
> equityWithLoan number Equity with Loan Value
> netLiquidation number Net Liquidation
> initMarginReq number Initial Margin Requirement
> initRiskRatio number Initial Margin Ratio
> maintainMarginReq number Maintenance Margin Requirement
> maintainRiskRatio number Maintenance Margin Ratio
> leverage number Leverage Ratio
> excessEquity number Excess Equity
> excessLiquidation number Excess Liquidation
> availableEE number Available Excess Equity
> lockedEE number Locked Equity
> balances [object] Balance Details
>> currency string Currency
>> balance number Balance
>> availableEE number Available Excess Equity
>> borrow number Borrowed Quantity
>> locked number Locked Asset
>> accruedInterest number Accrued Interest
>> balanceBaseToAssignedCurrency number Balance in Assigned Base Currency
> positions [object] none
>> symbol string Asset Symbol
>> expiry string Expiry Date
>> strike string Strike Price
>> right string Option Right
>> multiplier string Multiplier
>> latestPrice string Current Market Price
>> secType string Security Type
>> quantity string Quantity
>> averageCost string Average Cost
>> marketValue string Market Value
>> unrealPnl string Unrealized Profit/Loss
>> unrealPnlPercent string Unrealized Profit/Loss Percentage
> timestamp string Timestamp of Data Generation (ms)

Exection

Subscribe to the execution stream to see your executions in real-time.

Topic: execution:{segmentIndex} e.g., execution:0, execution:1, execution:all

Push Frequency: real-time

Request Sample

{
    "op": "subscribe",
    "args": [
        "execution:0",
        "execution:1"
    ]
}

Response Sample

{
  "topic": "execution:1",
  "ts": 1695126387268,
  "data": {
    "id": "32273489892343808",
    "segmentIndex": 1,
    "clientOrderId": "32272902210977792-2",
    "symbol": "ETH.USDT",
    "orderId": "32272902210977792",
    "side": "BUY",
    "quantity": "0.3060",
    "price": "1654.9800",
    "quoteQuantity": "",
    "commissionAndFee": "0.00",
    "commissionCurrency": "ETH",
    "transactedAt": 1695126387268,
    "maker": true,
    "errorCode": ""
  }
}

Publishes all new trades updates related to the user for a particular instrument, where the early response containing the same id serves as the confirmation to the request, and the rest of the responses with "id":-1 are live updates

Topic: execution

Requires initial authentication as it is a private topic (see authentication section for more information)

Response

Parameter Type Description
topic string Topic Name
ts number Timestamp of Data Generation (ms)
data Object Data Object
> id string Trade ID
> segmentIndex number Segment Index
> clientOrderId string Client Order ID
> symbol string Currency Pair Name
> orderId string Order ID
> side string Buy/Sell Direction: BUY, SELL
> quantity string Quantity Ordered in Base Currency
> price string Trade Price
> quoteQuantity string Quantity in Quote Currency
> commissionAndFee string Commission Fee
> commissionCurrency string Commission Currency Type
> transactedAt number Trade Time
> maker bool Is Maker Trade
> errorCode string Error Code

Order

Subscribe to the order stream to see changes to your orders in real-time.

Topic: order:{segmentIndex} e.g., order:0, order:1, order:all

Push Frequency: real-time

Request Sample

{
    "op": "subscribe",
    "args": [
        "order:all"
    ]
}

Response Sample

{
  "topic": "order:1",
  "ts": 1695126475705,
  "data": {
    "id": "32273370047840256",
    "segmentIndex": 1,
    "origClientOrderId": "32273370047840256-5",
    "clientOrderId": "32273370047840256-5",
    "secType": "SPOT",
    "symbol": "BTC.USDT",
    "side": "BUY",
    "totalQuantity": "0.01200",
    "filledQuantity": "0.00597",
    "totalQuoteQuantity": "",
    "filledQuoteQuantity": "",
    "type": "LMT",
    "price": "27230.05",
    "stopPrice": "",
    "avgFillPrice": "27230.05",
    "status": "PartiallyFilled",
    "replaceStatus": "REPLACED",
    "cancelStatus": "NONE",
    "commissionAndFee": "0.00",
    "errorCode": ""
  }
}

Publishes all new orders or order updates for the user for a particular instrument, where the early response containing the same id as the request is the current open orders, and the rest of the responses with "id":-1 are live updates

Requires initial authentication as it is a private topic (see authentication section for more information)

Topic: order

Response

Parameter Type Description
topic string Topic Name With Segment Index
ts number Timestamp of Data Generation (ms)
data Object Data Object
> id string Order ID
> segmentIndex number Segment Index
> origClientOrderId string Original Client Order ID
> clientOrderId string Client Order ID
> secType string Security Type
> symbol string Currency Pair Name
> side string Buy/Sell Direction: BUY, SELL
> totalQuantity string Total Quantity Ordered in Base Currency
> filledQuantity string Base Currency Quantity Filled
> totalQuoteQuantity string Total Quantity Ordered in Quote Currency
> filledQuoteQuantity string Quote Currency Quantity Filled
> type string Order Type
> price integer Order Limit Price
> stopPrice string Stop Price
> avgFillPrice string Average Execution Price
> status string Order Status
> replaceStatus string Replace Order Status
> cancelStatus string Cancel Order Status
> commissionAndFee string Commission Fee
> errorCode string Error Code

Errors

Category ErrorCode Description
System 10000 System error
10001 Timeout
10002 Unknown
10003 Parameter exception
10004 Expired order end of day
10005 Execution condition not met
10006 Rate limit
Contract 20000 Contract not support
20001 Halt temporary
20002 Short pool lack
20003 Contract not shortable
20005 Contract Not Listed
20006 Only open for this contract
20007 Only close for this contract
Price 21000 Limit price deviates too much
21001 Limit price Deviates stop price too much
21002 Invalid tick size
21004 The price of the stop limit order is unreasonable
21005 The trigger price of the stop order is unreasonable
Quantity 22000 Exceed quantity
22001 Exceed Max Lots
22002 New quantity smaller than filled qty
22003 Lot size invalid
22004 Exceed active orders