WEX DOC logo

简体中文
Spot

REST API Edit

production environment: https://sapi.wexex.io

Basic information of the interface Edit

Due to reasons such as high latency and poor stability, it is not recommended to access the API through a proxy.

GET request parameters are placed in query Params, POST request parameters are placed in request body

Please set the request header information to:Content-Type=application/json

For requests that start other than /public, the request message needs to be signed

Frequency Limiting Rules Edit

Some interfaces will have limited flow control (the corresponding interface will have a limited flow description). The flow limit is mainly divided into gateway flow limit and WAF flow limit.

If the interface request triggers the gateway flow limit, 429 will be returned, indicating that the access frequency exceeds the limit, and the IP or apiKey will be blocked.

Gateway flow limiting is divided into IP and apiKey flow limiting.

Example description of IP flow limit: 100/s/ip, indicating the limit of the number of requests per second for this interface per IP.

apiKey current limit example description: 50/s/apiKey, indicating the limit of the number of requests per second for the interface per apiKey.

Signature Instructions Edit

Since WEX needs to provide some open interfaces for third-party platforms,therefore, the issue of data security needs to be considered. Such as whether the data has been tampered with, whether the data is outdated, whether the data can be submitted repeatedly, and the access frequency of the interface, and whether data has been tampered with is the most important issue.

  1. Please apply for appkey and secretkey in the user center first, each user’s appkey and secretkey are different.

  2. Add timestamp, its value should be the unix timestamp (milliseconds) of the time when the request is sent, and the time of the data is calculated based on this value.

  3. Add signature, its value is obtained by a certain rule of signature algorithm.

  4. Add recvwindow (defining the valid time of the request), the valid time is currently relatively simple and uniformly fixed at a certain value.

When a request is received by the server, the timestamp in the request is checked to ensure it falls between 2 to 60 seconds. Any request with a timestamp older than 5,000 milliseconds is considered invalid. The time window value can be set using the optional parameter: “recvWindow”. Additionally, if the server determines that the client’s timestamp is more than one second ahead of the server, the request will also be invalid. Online conditions are not always 100% reliable in terms of the timeliness of trades, resulting in varying levels of latency between your local program and the WEX server. This is why we provide the “recvWindow” parameter - if you engage in high-frequency trading and require stricter transaction timeliness, you can adjust the “recvWindow” parameter to better meet your needs.

Recvwindow longer than 5 seconds is not recommended.

5、Added algorithm (signature method/algorithm), the user calculates the signature according to the protocol of the hash, and HmacSHA256 is recommended. For those protocols that are supported, see the table below.

HmacMD5、HmacSHA1、HmacSHA224、HmacSHA256(recommended)、HmacSHA384、HmacSHA512

Signature generation Edit

Take https://sapi.wexex.io/v4/order as an example.

The following is an example appkey and secret for placing an order using a call interface implemented by echo openssl and curl tools in the linux bash environment for demonstration purposes only:

appKey: 48f05386-4228-48e1-a69f-c9abd2d8fa52

secretKey: 8fcffde41cb50b18ce9178424f38d3b688fd0f47

Header part data:

validate-algorithms: HmacSHA256

validate-appkey: 48f05386-4228-48e1-a69f-c9abd2d8fa52

validate-recvwindow: 5000

validate-timestamp: 1692672585907

validate-signature: c58a59cf674b80bd3c9182f3db4feddc87ea4f3be7762bbf4bfab39429eec7e9

request data:

{
  type: 'LIMIT',
  timeInForce: 'GTC',
  side: 'BUY',
  symbol: 'btc_usdt',
  bizType: 'SPOT'
  price: '39000',
  quantity: '2'
}

1.data part

method: UpperCase method. eg: GET, POST, DELETE, PUT

path: Concatenate all values in the order in path. The restful path in the form of /test/{var1}/{var2}/ will be spliced according to the actual parameters filled in, for example: /sign/test/bb/aa

query: Sort all key=value according to the lexicographical order of the key. Example: userName=dfdfdf&password=ggg

body:   
    Json: Directly by JSON string without conversion or sorting.

    x-www-form-urlencoded: Sort all key=values according to the lexicographical order of keys, for example: userName=dfdfdf&password=ggg

    form-data:This format is not currently supported.

If there are multiple data forms, re-splicing is performed in the order of path, query, and body to obtain the splicing value of all data.

Method example:

POST

Path example:

/v4/order

The above concatenated value is recorded as path

Parameters passed query example:

symbol=btc_usdt

The above concatenated value is recorded as query

Parameters via body example

x-www-form-urlencoded:
  
    symbol=btc_usdt&side=BUY&bizType=SPOT&quantity=2&price=39000&type=LIMIT&timeInForce=GTC

    The above concatenated value is recorded as body

json:

    {"symbol":"btc_usdt","side":"BUY","bizType":"SPOT","quantity":2,"price":39000,"type":"LIMIT","timeInForce":"GTC"}

    The above concatenated value is recorded as body

Mixed use of query and body (divided into form and json format)

query: 
    symbol=btc_usdt&side=BUY&type=LIMIT
    The above concatenated value is recorded as query

body: 
    {"symbol":"btc_usdt","side":BUY,"type":"LIMIT"}
    The above concatenated value is recorded as body

The most concatenated value of the entire data is spliced with method, path, query, and body by the # symbol to form #method, #path, #query, and #body, and the final spliced value is recorded as Y=#method#path#query#body. Notice:

The query has data, but the body has no data: Y=#method#path#query

query has no data, body has data: Y=#method#path#body

query has data, body has data: Y=#method#path#query#body

2.request header part After the keys are in natural ascending alphabetical order, use & to join them together as X. like:

    validate-algorithms=HmacSHA256&validate-appkey=48f05386-4228-48e1-a69f-c9abd2d8fa52&validate-recvwindow=5000&validate-timestamp=1692672585907

3.generate signature

Finally, the string that needs to be encrypted is recorded as original=XY

Finally, encrypt the final concatenated value according to the following method to obtain a signature.

signature=org.apache.commons.codec.digest.HmacUtils.hmacSha256Hex(secretkey, original);

Put the generated signature singature in the request header, with validate-signature as the key and singature as the value.

4.example

sample of original signature message:
  
    validate-algorithms=HmacSHA256&validate-appkey=48f05386-4228-48e1-a69f-c9abd2d8fa52&validate-recvwindow=5000&validate-timestamp=1692672585907#POST#/v4/order#{"symbol":"btc_usdt","side":"BUY","bizType":"SPOT","quantity":2,"price":39000,"type":"LIMIT","timeInForce":"GTC"}

sample request message:

    curl --location --request POST 'https://sapi.wexex.io/v4/order' 
    --header 'accept: */*' 
    --header 'Content-Type: application/json' 
    --header 'validate-algorithms: HmacSHA256' 
    --header 'validate-appkey: 48f05386-4228-48e1-a69f-c9abd2d8fa52' 
    --header 'validate-recvwindow: 5000' 
    --header 'validate-timestamp: 1692672585907' 
    --header 'validate-signature: c58a59cf674b80bd3c9182f3db4feddc87ea4f3be7762bbf4bfab39429eec7e9' 
    --data-raw '{"symbol":"btc_usdt","side":"BUY","bizType":"SPOT","quantity":2,"price":39000,"type":"LIMIT","timeInForce":"GTC"}'    

matters needing attention:

    Pay attention to checking the parameter format of Content Type, signature original message and request message

API Key application steps Edit

The interface may require the user’s API Key, Apply for the uri of the api is Here .

API code library Edit

Java connector

A lightweight Java codebase that provides methods that allow users to directly call the API。

Sdks for each language:

  java : https://github.com/wex2023/java-demo

Sample request information for each interface:

  https://github.com/wex2023/java-demo/blob/master/request.txt

response format Edit

All interface returns are in JSON format.

{
    "rc": 0,
    "result": {
      },
    "mc": "SUCCESS"
    "ma": []
}

response code Edit

httpStatus description
200 The request is successful, please check the rc and mc sections further
404 interface does not exist
429 The request is too frequent, please control the request rate according to the speed limit requirement
500 Service exception
502 Gateway exception
503 Service unavailable, please try again later
rc return Code
0 business success
1 business failure
mc message code
SUCCESS success
FAILURE fail
AUTH_001 missing request header validate-appkey
AUTH_002 missing request header validate-timestamp
AUTH_003 missing request header validate-recvwindow
AUTH_004 bad request header validate-recvwindow
AUTH_005 missing request header validate-algorithms
AUTH_006 bad request header validate-algorithms
AUTH_007 missing request header validate-signature
AUTH_101 ApiKey does not exist
AUTH_102 ApiKey is not activated
AUTH_103 Signature error
AUTH_104 Unbound IP request
AUTH_105 outdated message
AUTH_106 Exceeded apikey permission
SYMBOL_001 Symbol not exist
SYMBOL_002 Symbol offline
SYMBOL_003 Symbol suspend trading
SYMBOL_004 Symbol country disallow trading
SYMBOL_005 The symbol does not support trading via API
ORDER_001 Platform rejection
ORDER_002 insufficient funds
ORDER_003 Trading Pair Suspended
ORDER_004 no transaction
ORDER_005 Order not exist
ORDER_006 Too many open orders
ORDER_007 The sub-account has no transaction authority
ORDER_008 The order price or quantity precision is abnormal
ORDER_F0101 Trigger Price Filter - Min
ORDER_F0102 Trigger Price Filter - Max
ORDER_F0103 Trigger Price Filter - Step Value
ORDER_F0201 Trigger Quantity Filter - Min
ORDER_F0202 Trigger Quantity Filter - Max
ORDER_F0203 Trigger Quantity Filter - Step Value
ORDER_F0301 Trigger QUOTE_QTY Filter - Min Value
ORDER_F0401 Trigger PROTECTION_ONLINE Filter
ORDER_F0501 Trigger PROTECTION_LIMIT Filter - Buy Max Deviation
ORDER_F0502 Trigger PROTECTION_LIMIT Filter - Sell Max Deviation
ORDER_F0601 Trigger PROTECTION_MARKET Filter
COMMON_001 The user does not exist
COMMON_002 System busy, please try it later
COMMON_003 Operation failed, please try it later
CURRENCY_001 Information of currency is abnormal
DEPOSIT_001 Deposit is not open
DEPOSIT_002 The current account security level is low, please bind any two security verifications in mobile phone/email/Google Authenticator before deposit
DEPOSIT_003 The format of address is incorrect, please enter again
DEPOSIT_004 The address is already exists, please enter again
DEPOSIT_005 Can not find the address of offline wallet
DEPOSIT_006 No deposit address, please try it later
DEPOSIT_007 Address is being generated, please try it later
DEPOSIT_008 Deposit is not available
WITHDRAW_001 Withdraw is not open
WITHDRAW_002 The withdrawal address is invalid
WITHDRAW_003 The current account security level is low, please bind any two security verifications in mobile phone/email/Google Authenticator before withdraw
WITHDRAW_004 The withdrawal address is not added
WITHDRAW_005 The withdrawal address cannot be empty
WITHDRAW_006 Memo cannot be empty
WITHDRAW_008 Risk control is triggered, withdraw of this currency is not currently supported
WITHDRAW_009 Withdraw failed, some assets in this withdraw are restricted by T+1 withdraw
WITHDRAW_010 The precision of withdrawal is invalid
WITHDRAW_011 free balance is not enough
WITHDRAW_012 Withdraw failed, your remaining withdrawal limit today is not enough
WITHDRAW_013 Withdraw failed, your remaining withdrawal limit today is not enough, the withdrawal amount can be increased by completing a higher level of real-name authentication
WITHDRAW_014 This withdrawal address cannot be used in the internal transfer function, please cancel the internal transfer function before submitting
WITHDRAW_015 The withdrawal amount is not enough to deduct the handling fee
WITHDRAW_016 This withdrawal address is already exists
WITHDRAW_017 This withdrawal has been processed and cannot be canceled
WITHDRAW_018 Memo must be a number
WITHDRAW_019 Memo is incorrect, please enter again
WITHDRAW_020 Your withdrawal amount has reached the upper limit for today, please try it tomorrow
WITHDRAW_021 Your withdrawal amount has reached the upper limit for today, you can only withdraw up to {0} this time
WITHDRAW_022 Withdrawal amount must be greater than {0}
WITHDRAW_023 Withdrawal amount must be less than {0}
WITHDRAW_024 Withdraw is not supported
WITHDRAW_025 Please create a FIO address in the deposit page
FUND_001 Duplicate request (a bizId can only be requested once)
FUND_002 Insufficient account balance
FUND_003 Transfer operations are not supported (for example, sub-accounts do not support financial transfers)
FUND_004 Unfreeze failed
FUND_005 Transfer prohibited
FUND_014 The transfer-in account id and transfer-out account ID cannot be the same
FUND_015 From and to business types cannot be the same
FUND_016 Leverage transfer, symbol cannot be empty
FUND_017 Parameter error
FUND_018 Invalid freeze record
FUND_019 Freeze users not equal
FUND_020 Freeze currency are not equal
FUND_021 Operation not supported
FUND_022 Freeze record does not exist
FUND_044 The maximum length of the amount is 113 and cannot exceed the limit
SYMBOL_001 Symbol does not exist
TRANSFER_001 Duplicate request (a bizId can only be requested once)
TRANSFER_002 Insufficient account balance
TRANSFER_003 User not registered
TRANSFER_004 The currency is not allowed to be transferred
TRANSFER_005 The user’s currency is not allowed to be transferred
TRANSFER_006 Transfer prohibited
TRANSFER_007 Request timed out
TRANSFER_008 Transferring to a leveraged account is abnormal
TRANSFER_009 Departing from a leveraged account is abnormal
TRANSFER_010 Leverage cleared, transfer prohibited
TRANSFER_011 Leverage with borrowing, transfer prohibited
TRANSFER_012 Currency transfer prohibited
GATEWAY_0001 Trigger risk control
GATEWAY_0002 Trigger risk control
GATEWAY_0003 Trigger risk control
GATEWAY_0004 Trigger risk control

Public module Edit

Order state

State Description
NEW The order has been accepted by the engine.
PARTIALLY_FILLED A part of the order has been filled.
FILLED The order has been completed.
CANCELED The order has been canceled by the user.
REJECTED The order was not accepted by the engine and not processed.
EXPIRED The order has expired (e.g. Order canceled due to timeout or canceled due to premium)

Order type

Type Description
LIMIT Limit price order
MARKET Market price order

Symbol state

State Description
ONLINE The symbol is online
OFFLINE The symbol is offline
DELISTED The symbol has been delisted

Time in force

This sets how long an order will be active before expiration.

TimeInForces Description
GTC It remains valid until the transaction is concluded.
IOC ancel the part that cannot be transacted immediately (taking orders)
FOK Cancellation if all transactions cannot be completed immediately
GTX Revoke if unable to become a pending party

Deposit/Withdraw status

Status Description
SUBMIT The withdrawal amount is not frozen.
REVIEW The withdrawal amount has been frozen and is pending review.
AUDITED The withdraw has been reviewed and is ready to on-chaining.
AUDITED_AGAIN Reexamine
PENDING The deposit or withdraw is already on-chaining.
SUCCESS The deposit or withdraw is success.
FAIL The deposit or withdraw failed.
CANCEL The deposit or withdraw has been canceled by the user.

BizType

Status Description
SPOT spot account
LEVER Leverage account
FINANCE Financial account
FUTURES_U USDT-M futures account
FUTURES_C COIN-M futures account

FAQ Edit

1.AUTH_ 105: The server verifies the request header parameters validate-timestamp (validTimeStamp) and validate-recvwindow (recvwindow) The following rules must be followed: dealTimeStamp (server time when the request is processed, in milliseconds) - validTimeStamp < recvwindow, otherwise AUTH_105 will be returned. To avoid this error, validate-timestamp recommends using the time when the request was sent, and it is measured in milliseconds. The validate-recvwindow is set a little larger

Get server time Edit

/v4/public/time

public String getServerInfo(){


}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "serverTime": 1662435658062  
  }
}

Get symbol information Edit

/v4/public/symbol

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false trading pair eg:btc_usdt
symbols array false Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt
version string false Version number, when the request version number is consistent with the response content version, the list will not be returned, reducing IO eg: 2e14d2cd5czcb2c2af2c1db6

Limit Flow Rules

1.single symbol:100/s/ip

2.multiple symbols:10/s/ip


FILTER

Filter, defines a series of trading rules. There are different filters for different fields or entities. Here we mainly introduce the filter for the entity symbol. For symbols, there are two kinds of filters, one is a global filter, and the other is a filter customized for a certain trading pair.


PRICE FILTER

The price filter is used to check the validity of the price parameter in the order. Contains the following three parts:

1.min Defines the minimum allowable price in the order

2.max Defines the maximum price allowed in the order

3.tickSize Defines the step interval of price in the order, that is, price must be equal to minPrice+(integer multiple of tickSize)

Each of the above items can be null, when it is null, it means that this item is no longer restricted

The logical pseudocode is as follows:

  • price >= min
  • price <= max
  • (price-minPrice) % tickSize == 0

QUANTITY FILTER

The logic is similar to PRICE FILTER ,but for the order quantity.

It contains three parts:

1.min minimum allowed

2.max maximum allowed

3.tickSize  Step interval, that is, quantity must be equal to minQuantity+(integer multiple of tickSize)

Each of the above items can be null, when it is null, it means that this item is no longer restricted

The logical pseudocode is as follows:

  • quantity>= min
  • quantity<= max
  • (quantity-minQuantity)% tickSize == 0

QUOTE_QTY FILTER

Limit the amount of the order

It internally defines the minimum allowable value-min

When min is null, the order is not limited

Otherwise the restriction rules are as follows:

1.For orders of the LIMIT type,must meet the following conditions: price*quantity>=min

2.For orders of the MARKET type and BUY type,must meet the following conditions: quoteQty>=min,(quoteQty,The required amount when placing an order of MARKET type by amount)


PROTECTION_LIMIT FILTER

There are price protection restrictions for orders whose order type (orderType) is LIMIT, including the following two parts:

1.buyMaxDeviation The maximum deviation of the buy order, which limits the difference between the buy order price and the latest transaction price

2.sellMaxDeviation The maximum deviation of the sell order, which limits the difference between the sell order price and the latest transaction price

If there is no latest transaction price, there will be no restrictions, or if the above parameters are null, the corresponding direction type orders will not be restricted.

In order to pass the limit price protection, the order price must meet the following conditions (latestPrice is the latest transaction price)

buy order: price >= latestPrice-latestPrice*buyMaxDeviation 

sell order: price <= latestPrice+latestPrice*sellMaxDeviation


PROTECTION_MARKET FILTER

There is a price limit protection mechanism for orders of the order type MARKET, which internally specifies the maximum deviation rate(maxDeviation).

For market type orders, the market price must meet the following conditions for the order to pass(sellBestPrice  sell one price,buyBestPrice buy one price,latestPrice The latest transaction price, these data are obtained through historical transaction data)

buy order: latestPrice + latestPrice* maxDeviation >= sellBestPrice 

sell order: latestPrice - latestPrice* maxDeviation <= buyBestPrice

For the above situation maxDeviation,latestPrice,sellBestPrice,buyBestPrice

All may be empty or there is no latest transaction price, buy one price, sell one price, there is no limit


PROTECTION_ONLINE FILTER

Limit the price of orders of the MARKET type within the specified time range after the opening

The maximum price multiple is defined inside this filter(maxPriceMultiple),duration(durationSeconds)。

Limitation logic: when it is within the durationSeconds time range after the opening of the symbol, Orders with an order type of LIMIT must meet the following conditions to pass

price<=openPrice*maxPriceMultiple,(openPrice is the opening price).

There are no restrictions on other types of orders or orders outside the opening time frame.

For maxPriceMultiple, durationSeconds can be null, when they are null, no opening protection limit is applied.

{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "time": 1662444177871,  
    "version": "7cd2cfab0dc979339f1de904bd90c9cb",  
    "symbols": [                   
      {
        "id": 614,                   //ID
        "symbol": "btc_usdt",         
        "state": "ONLINE",           //symbol state [ONLINE;OFFLINE,DELISTED]
        "tradingEnabled": true,
        "openapiEnabled": true,      //Openapi transaction is available or not
        "nextStateTime": null,              
        "nextState": null,                 
        "depthMergePrecision": 5,    //Depth Merge Accuracy
        "baseCurrency": "btc",                  
        "baseCurrencyPrecision": 5,              
        "baseCurrencyId": 2,                 
        "quoteCurrency": "usdt",             
        "quoteCurrencyPrecision": 6,        
        "quoteCurrencyId": 11,             
        "pricePrecision": 4,         //Transaction price accuracy
        "quantityPrecision": 6,           
        "orderTypes": [              //Order Type [LIMIT;MARKET]
          "LIMIT",
          "MARKET"
        ],
        "timeInForces": [            //Effective ways [GTC=It remains valid until the transaction is concluded; IOC=Cancel the part that cannot be transacted immediately (taking orders); FOK=Cancellation if all transactions cannot be completed immediately; GTX=Revoke if unable to become a pending party]
          "GTC",
          "FOK",
          "IOC",
          "GTX"
        ],
        "displayWeight": 1,          //Show the weight, the greater the weight, the more forward
        "displayLevel": "FULL",      //Presentation level, [FULL=Full display,SEARCH=Search display,DIRECT=Direct display,NONE=Don't show]
        "plates": [],                //  eg:22,23,24
        "filters": [                       
          {
            "filter": "PROTECTION_LIMIT",
            "buyMaxDeviation": "0.8"
            "sellMaxDeviation": "0.8"
          },
          {
            "filter": "PROTECTION_MARKET",
            "maxDeviation": "0.1"
          },
          {
            "filter": "PROTECTION_ONLINE",
            "durationSeconds": "300",
            "maxPriceMultiple": "5"
          },
          {
            "filter": "PRICE",
            "min": null,
            "max": null,
            "tickSize": null
          },
          {
            "filter": "QUANTITY",
            "min": null,
            "max": null,
            "tickSize": null
          },
          {
            "filter": "QUOTE_QTY",
            "min": null
          },
       ]
      }
    ]
  }
}

Get depth data Edit

/v4/public/depth

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true trading pair eg:btc_usdt
limit number false 50 1~500

Limit Flow Rules

200/s/ip

public String depth(){


}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "timestamp": 1662445330524,  
    "lastUpdateId": 137333589606963580,     //Last updated record
    "bids": [                               //buy order([?][0]=price;[?][1]=pending order volume)
      [
        "200.0000",                         //price
        "0.996000"                          //pending order volume
      ],
      [
        "100.0000",
        "0.001000"
      ],
      [
        "20.0000",
        "10.000000"
      ]
    ],
    "asks": []                              //sell order([?][0]=price;[?][1]=pending order volume)
  }
}

Get K-line data Edit

/v4/public/kline

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true trading pair eg:btc_usdt
interval string true K line type, eg:1m [1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M]
startTime number false start timestamp
endTime number false end timestamp
limit number false 100 1~1000

Limit Flow Rules

100/s/ip

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "t": 1662601014832,   //open time
      "o": "30000",         //open price
      "c": "32000",         //close price
      "h": "35000",         //highest price
      "l": "25000",         //lowest price
      "q": "512",           //transaction quantity
      "v": "15360000"       //transaction volume
    }
  ]
}

Query the list of recent transactions Edit

/v4/public/trade/recent

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true trading pair
limit number false 200 1,1000

Limit Flow Rules

100/s/ip

public String tradeRecent(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "i": 0,           //ID
      "t": 0,           //transaction time
      "p": "string",    //transaction price
      "q": "string",    //transaction quantity
      "v": "string",    //transaction volume
      "b": true         //whether is buyerMaker or not
    }
  ]
}

Query historical transaction list Edit

/v4/public/trade/history

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true trading pair
limit number false 200 1,1000
direction string true query direction PREV-previous page,NEXT-next page
fromId number false Start ID,eg: 6216559590087220004

Limit Flow Rules

100/s/ip

public String tradeHistory(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "i": 0,           //ID
      "t": 0,           //transaction time
      "p": "string",    //transaction price
      "q": "string",    //transaction quantity
      "v": "string",    //transaction volume
      "b": true         //whether is buyerMaker or not
    }
  ]
}

Full ticker Edit

/v4/public/ticker

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false trading pair eg:btc_usdt
symbols array false Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt
tags string false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:100/s/ip

2.multiple symbols:10/s/ip

public String price(){


}
{
    "rc": 0,
    "mc": "SUCCESS",
    "ma": [],
    "result": [
          {
            "s": "btc_usdt",        //symbol
            "t": 1662444879425,     //update time
            "cv": "0.00",           //change value
            "cr": "0.0000",         //change rate
            "o": "200.00",          //open
            "l": "200.00",          //low
            "h": "200.00",          //high
            "c": "200.00",          //close
            "q": "0.002",           //quantity
            "v": "0.40",            //volume
            "ap": null,             //asks price(sell one price)
            "aq": null,             //asks qty(sell one quantity)
            "bp": null,             //bids price(buy one price)
            "bq": null              //bids qty(buy one quantity)
            }
        ]
}

Get latest prices ticker Edit

/v4/public/ticker/price

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false trading pair eg:btc_usdt
symbols array false Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt
tags string false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:100/s/ip

2.multiple symbols:10/s/ip

public String price(){


}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",      //symbol
      "t": 1661856036925    //time
      "p": "9000.0000",     //price
      }
  ]
}

Get the best pending order ticker Edit

/v4/public/ticker/book

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false trading pair eg:btc_usdt
symbols array false Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt
tags string false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:100/s/ip

2.multiple symbols:10/s/ip

{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",      //symbol
      "t": 1661856036925,   //last updated time 
      "ap": null,           //asks price(sell one price)
      "aq": null,           //asks qty(sell one quantity)
      "bp": null,           //bids price(buy one price)
      "bq": null            //bids qty(buy one quantity)
    }
  ]
}

Get 24h statistics ticker Edit

/v4/public/ticker/24h

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false trading pair eg:btc_usdt
symbols array false Collection of trading pairs. Priority is higher than symbol. eg: btc_usdt,eth_usdt
tags string false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:100/s/ip

2.multiple symbols:10/s/ip

{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",      //symbol
      "t": 1661856036925,   //time 
      "cv": "0.0000",       //price change value
      "cr": "0.00",         //price change rate
      "o": "9000.0000",     //open price
      "l": "9000.0000",     //lowest price
      "h": "9000.0000",     //highest price
      "c": "9000.0000",     //close price
      "q": "0.0136",        //transaction quantity
      "v": "122.9940"       //transaction volume
    }
  ]
}

Get single Edit

/v4/order/{orderId}

Parameters
Parameter Type mandatory Default Description Ranges
orderId number true

Limit Flow Rules

100/s/apikey

public String orderGet(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "symbol": "BTC_USDT",   
    "orderId": "6216559590087220004",  
    "clientOrderId": "16559590087220001",  
    "baseCurrency": "string",   
    "quoteCurrency": "string",   
    "side": "BUY",                          //order side:BUY,SELL
    "type": "LIMIT",                        //order type  LIMIT,MARKET 
    "timeInForce": "GTC",                   //effective way:GTC,IOC,FOK,GTX
    "price": "40000",   
    "origQty": "2",                         //original quantity
    "origQuoteQty": "48000",                //original amount
    "executedQty": "1.2",                   //executed quantity
    "leavingQty": "string",                 //The quantity to be executed (if the order is cancelled or the order is rejected, the value is 0)
    "tradeBase": "2",                       //transaction quantity
    "tradeQuote": "48000",                  //transaction amount
    "avgPrice": "42350",                    //average transaction price
    "fee": "string",                        //handling fee
    "feeCurrency": "string",   
    "state": "NEW",                         //order stat NEW,PARTIALLY_FILLED,FILLED,CANCELED,REJECTED,EXPIRED
    "time": 1655958915583,                  //order time
    "updatedTime": 1655958915583  
  }
}

Query single Edit

/v4/order

Parameters
Parameter Type mandatory Default Description Ranges
orderId number false
clientOrderId string false
public String orderGet(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "symbol": "BTC_USDT",   
    "orderId": "6216559590087220004",  
    "clientOrderId": "16559590087220001",  
    "baseCurrency": "string",   
    "quoteCurrency": "string",   
    "side": "BUY",                      //order side:BUY,SELL
    "type": "LIMIT",                    //order type  LIMIT,MARKET 
    "timeInForce": "GTC",               //effective way:GTC,IOC,FOK,GTX
    "price": "40000",   
    "origQty": "2",                     //original quantity
    "origQuoteQty": "48000",            //original amount
    "executedQty": "1.2",               //executed quantity
    "leavingQty": "string",             //The quantity to be executed (if the order is cancelled or the order is rejected, the value is 0)
    "tradeBase": "2",                   //transaction quantity
    "tradeQuote": "48000",              //transaction amount
    "avgPrice": "42350",                //average transaction price
    "fee": "string",                    //handling fee
    "feeCurrency": "string",   
    "state": "NEW",                     //order stat NEW,PARTIALLY_FILLED,FILLED,CANCELED,REJECTED,EXPIRED
    "time": 1655958915583,              //order time
    "updatedTime": 1655958915583  
  }
}

Submit order Edit

/v4/order

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true
clientOrderId string false Pattern: ^[a-zA-Z0-9_]{4,32}$
side string true BUY,SELL
type string true order type:LIMIT,MARKET
timeInForce string true effective way:GTC, FOK, IOC, GTX
bizType string true SPOT, LEVER
price number false price. Required if it is the LIMIT price; blank if it is the MARKET price
quantity number false quantity. Required if it is the LIMIT price or the order is placed at the market price by quantity
quoteQty number false amount. Required if it is the LIMIT price or the order is the market price when placing an order by amount

Limit Flow Rules

50/s/apikey

public String orderPost(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "orderId": "6216559590087220004"  
  }
}

Cancell order Edit

/v4/order/{orderId}

Parameters
Parameter Type mandatory Default Description Ranges
orderId number true

Limit Flow Rules

100/s/apikey

public String orderDel(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "cancelId": "6216559590087220004"
  }
}

Get batch Edit

/v4/batch-order

Parameters
Parameter Type mandatory Default Description Ranges
orderIds string true order Ids eg: 6216559590087220004,
6216559590087220004

reponse field information, refer to the Get single interface

public String batchOrderGet(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "symbol": "BTC_USDT",
      "orderId": "6216559590087220004",
      "clientOrderId": "16559590087220001",
      "baseCurrency": "string",
      "quoteCurrency": "string",
      "side": "BUY",
      "type": "LIMIT",
      "timeInForce": "GTC",
      "price": "40000",
      "origQty": "2",
      "origQuoteQty": "48000",
      "executedQty": "1.2",
      "leavingQty": "string",
      "tradeBase": "2",
      "tradeQuote": "48000",
      "avgPrice": "42350",
      "fee": "string",
      "feeCurrency": "string",
      "state": "NEW",
      "time": 1655958915583,
      "updatedTime": 1655958915583
    }
  ]
}

Cancell batch order Edit

/v4/batch-order

Parameters
Parameter Type mandatory Default Description Ranges
clientBatchId string false client batch id
orderIds array true 6216559590087220004,
6216559590087220005

Note: The parameters should be placed in the request body in the form of json

public String batchOrderDel(){


}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {}
}

Query the current pending order Edit

/v4/open-order

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false Trading pair, if not filled in, represents all
bizType string false SPOT, LEVER
side string false BUY,SELL

Limit Flow Rules

10/s/apikey

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [      //For field information, refer to the Get single interface
    {
      "symbol": "BTC_USDT",
      "orderId": "6216559590087220004",
      "clientOrderId": "16559590087220001",
      "baseCurrency": "string",
      "quoteCurrency": "string",
      "side": "BUY",
      "type": "LIMIT",
      "timeInForce": "GTC",
      "price": "40000",
      "origQty": "2",
      "origQuoteQty": "48000",
      "executedQty": "1.2",
      "leavingQty": "string",
      "tradeBase": "2",
      "tradeQuote": "48000",
      "avgPrice": "42350",
      "fee": "string",
      "feeCurrency": "string",
      "state": "NEW",
      "time": 1655958915583,
      "updatedTime": 1655958915583
    }
  ]
}

Cancel the current pending order Edit

/v4/open-order

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false Trading pair, if not filled in, represents all
bizType string false SPOT, LEVER
side string false BUY,SELL

Limit Flow Rules

10/s/apikey
Note: The parameters should be placed in the request body in the form of json

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {}
}

Query historical orders Edit

/v4/history-order

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false Trading pair, if not filled in, represents all
bizType string false SPOT, LEVER
side string false BUY,SELL
type string false LIMIT, MARKET
state string false order state,
PARTIALLY_FILLED,
FILLED, CANCELED,
REJECTED,EXPIRED
fromId number false start id
direction string false query direction:PREV, NEXT
limit number false 20 Limit number, max 100
startTime number false eg:1657682804112
endTime number false
hiddenCanceled bool false

Limit Flow Rules

10/s/apikey

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "hasPrev": true,
    "hasNext": true,
    "items": [   //For field information, refer to the Get single interface
      {
        "symbol": "BTC_USDT",
        "orderId": "6216559590087220004",
        "clientOrderId": "16559590087220001",
        "baseCurrency": "string",
        "quoteCurrency": "string",
        "side": "BUY",
        "type": "LIMIT",
        "timeInForce": "GTC",
        "price": "40000",
        "origQty": "2",
        "origQuoteQty": "48000",
        "executedQty": "1.2",
        "leavingQty": "string",
        "tradeBase": "2",
        "tradeQuote": "48000",
        "avgPrice": "42350",
        "fee": "string",
        "feeCurrency": "string",
        "state": "NEW",
        "time": 1655958915583,
        "updatedTime": 1655958915583
      }
    ]
  }
}

Query trade Edit

/v4/trade

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false Trading pair, if not filled in, represents all
bizType string false SPOT, LEVER
orderSide string false BUY,SELL
orderType string false LIMIT, MARKET
orderId number false
fromId number false start id
direction string false query direction:PREV, NEXT
limit number false 20 Limit number, max 100
startTime number false start time eg:1657682804112
endTime number false
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "hasPrev": true,
    "hasNext": true,
    "items": [
      {
        "symbol": "BTC_USDT",  
        "tradeId": "6316559590087222001",  
        "orderId": "6216559590087220004",  
        "orderSide": "BUY",    
        "orderType": "LIMIT",  
        "bizType": "SPOT",    
        "time": 1655958915583,  
        "price": "40000",     
        "quantity": "1.2",    
        "quoteQty": "48000",   //amount
        "baseCurrency": "BTC",  
        "quoteCurrency": "USDT",  
        "fee": "0.5",   
        "feeCurrency": "USDT", 
        "takerMaker": "taker"  //takerMaker
      }
    ]
  }
}

Get currency information Edit

/v4/public/currencies

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
       "id": 11,                //currency id
      "currency": "usdt",       //currency name
      "fullName": "usdt",       //currency full name
      "logo": null,             //currency logo
      "cmcLink": null,          //cmc link
      "weight": 100,    
      "maxPrecision": 6,  
      "depositStatus": 1,       //Recharge status(0 close 1 open)
      "withdrawStatus": 1,      //Withdrawal status(0 close 1 open)
      "convertEnabled": 1,      //Small asset exchange switch[0=close;1=open]
      "transferEnabled": 1      //swipe switch[0=close;1=open]
    }
  ]
}

Get a single currency asset Edit

/v4/balance

Parameters
Parameter Type mandatory Default Description Ranges
currency string true eg:usdt
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "currency": "usdt",  
    "currencyId": 0,   
    "frozenAmount": 0,  
    "availableAmount": 0,  
    "totalAmount": 0,    
    "convertBtcAmount": 0  //Converted BTC amount
  }
}

Get a list of currency assets Edit

/v4/balances

Parameters
Parameter Type mandatory Default Description Ranges
currencies string false List of currencies, comma separated,eg: usdt,btc

Limit Flow Rules

10/s/apikey

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "totalBtcAmount": 0,
    "assets": [    
      {        
        "currency": "string",
        "currencyId": 0,
        "frozenAmount": 0,
        "availableAmount": 0,
        "totalAmount": 0,
        "convertBtcAmount": 0
      }
    ]
  }
}

Get information of currencies (available for deposit and withdraw) Edit

/v4/public/wallet/support/currency

Remark

The currency and chain in the response need to be used in other deposit/withdrawal API

{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
        "currency": "BTC",                  //currency name
        "supportChains": [
            {
                "chain": "Bitcon",          //supported transfer network
                "depositEnabled": true,     //deposit is supported or not
                "withdrawEnabled": true     //withdraw is supported or not
                "withdrawFeeAmount": 0.2,   //withdraw fee
                "withdrawMinAmount": 10,    //minimum withdrawal amount
                "depositFeeRate": 0.2       //deposit fee rate
            }
        ]           
    },
    {
        "currency": "ETH",                  //currency name
        "supportChains": [
            {
                "chain": "Ethereum",        //supported transfer network
                "depositEnabled": true,     //deposit is supported or not
                "withdrawEnabled": true     //withdraw is supported or not
                "withdrawFeeAmount": 0.2,   //withdraw fee
                "withdrawMinAmount": 10,    //minimum withdrawal amount
                "depositFeeRate": 0.2       //deposit fee rate
            }
        ]
    }
  ]
}

Get the deposit address Edit

/v4/deposit/address

Parameters
Parameter Type mandatory Default Description Ranges
chain string true network for deposit
currency string true currency name
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "address": "0xfa3abfa50eb2006f5be7831658b17aca240d8526",     //wallet address
    "memo": ""
  }
}

Get history records of deposit Edit

/v4/deposit/history

Parameters
Parameter Type mandatory Default Description Ranges
currency string false Currency name, can be obtained from the response of "Get the supported currencies for deposit or withdrawal" API
chain string false Transfer networks, can be obtained from the response of "Get the supported currencies for deposit or withdrawal" API
status string false The status of deposit SUBMIT、REVIEW、AUDITED、PENDING、SUCCESS、FAIL、CANCEL
fromId long false Start ID, e.g. 6216559590087220004
direction string false NEXT query direction query direction:PREV, NEXT
limit int false 10 Limit number, max 200 1<=limit<=200
startTime long false Start time used for filtering deposit list, timestamp in milliseconds
endTime long false End time used for filtering deposit list, timestamp in milliseconds
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
    "hasPrev": true,            //Is there a previous page
    "hasNext": true,            //Is there a next page
    "items": [
      {
         "id": 169669597,       //Unique ID of the deposit record
         "currency": "xlm2",    //Currency name
         "chain": "XLM",        //Transfer Network
         "memo": "441824256",   //memo
         "status": "SUCCESS",   //The status of deposit
         "amount": "0.1",       //Deposit amount
         "confirmations": 12,   //Number of block confirmations
         "transactionId": "28dd15b5c119e00886517f129e5e1f8283f0286b277bcd3cd1f95f7fd4a1f7fc",   //Unique ID of transaction
         "address": "GBY6UIYEYLAAXRQXVO7X5I4BSSCS54EAHTUILXWMW6ONPM3PNEA3LWEC",     //Target address of deposit
         "fromAddr": "GBTISB3JK65DG6LEEYYFW33RMMDHBQ65AEUPE5VDBTCLYYFS533FTG6Q",    //From address of deposit
         "createdTime": 1667260957000   //Time of deposit record in millisecondstime
      }
    ]
  }
}

Withdraw Edit

/v4/withdraw

Parameters
Parameter Type mandatory Default Description Ranges
currency string true Currency name, which can be obtained from the 'Get the supported currencies for deposit or withdrawal' interface
chain string true The name of the transfer network, which can be obtained from the interface of 'Get the supported currencies for deposit or withdrawal' interface
amount number true Withdrawal amount, including handling fee
address string true Withdrawal address
memo String false memo,For EOS similar chains that require memo must be transferred

Note: The parameters are placed in the body in the form of json

{
    "currency":"zb",
    "chain":"Ethereum",
    "amount":1000,
    "address":"0xfa3abfa50eb2006f5be7831658b17aca240d8526",
    "memo":""
}

Withdrawal history Edit

/v4/withdraw/history

Parameters
Parameter Type mandatory Default Description Ranges
currency string false Currency name, which can be obtained from the 'Get the supported currencies for deposit or withdrawal' interface
chain string false The name of the transfer network, which can be obtained from the interface of 'Get the supported currencies for deposit or withdrawal' interface
status string false The status of the withdrawal record, string type,Refer to public module-Deposit/withdrawal status SUBMIT、REVIEW、AUDITED、AUDITED_AGAIN、PENDING、SUCCESS、FAIL、CANCEL
fromId Long false The Id of the last pagination, that is, the primary key id of the record
direction String false NEXT Page direction NEXT:next page,PREV:previous page
limit int false 10 Number of records per page, maximum 200 1<=limit<=200
startTime Long false Query range start boundary, timestamp in milliseconds
endTime Long false Query range end boundary, timestamp in milliseconds
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": {
        "hasPrev": true,                      //Is there a previous page                              
        "hasNext": true,                      //Is there a next page                              
        "items": [
            {
                "id": 763111,                 //Withdrawal record id 
                "currency": "usdt",           //currency name 
                "chain": "Ethereum",          //Withdraw network 
                "address": "0xfa3abf",        //Withdrawal target address 
                "memo": "",
                "status": "REVIEW",           //Refer to public module-Deposit/withdrawal record status
                "amount": "30",               //Withdrawal Amount
                "fee": "0",                   //Withdrawal fee
                "confirmations": 0,           //number of block confirmations
                "transactionId": "",          //transaction hash
                "createdTime": 1667763470000  //Withdrawal application time, timestamp in milliseconds
            },
            {
                "id": 763107,
                "currency": "usdt",
                "chain": "Tron",
                "address": "TYnJJw",
                "memo": "",
                "status": "REVIEW",
                "amount": "50",
                "fee": "1",
                "confirmations": 0,
                "transactionId": "",
                "createdTime": 1667428286000
            }
        ]
  }
}

Transfer between user business systems Edit

/v4/balance/transfer

Parameters
Parameter Type mandatory Default Description Ranges
bizId string true Unique id for idempotent processing Maximum length is 128
from enum true Fund transfer out account bizType enmu
to enum true Fund transfer in account bizType enum
currency string true Currency name must be all lowercase (usdt,btc)
symbol string false The transfer symbol must be all lowercase (this field must be passed if one of the transfer-in and transfer-out parties is leverage)
amount bigDecimal true Transfer amount
public String transferPost(){


}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": 123456 //The returned unique id of the transfer, it is recommended to store it for reconciliation
}

Transfer between sub-account business systems Edit

/v4/balance/account/transfer

Parameters
Parameter Type mandatory Default Description Ranges
bizId string true Unique id for idempotent processing Maximum length is 128
from enum true Fund transfer out account bizType enmu
to enum true Fund transfer in account bizType enum
currency string true Currency name must be all lowercase (usdt,btc)
symbol string false The transfer symbol must be all lowercase (this field must be passed if one of the transfer-in and transfer-out parties is leverage)
amount bigDecimal true Transfer amount
toAccountId long true Transfer-in account id (must belong to the same user as the transfer-out account ID)
fromAccountId long false Transfer-out account id
public String accountTransferPost(){


}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": 123456 //The returned unique id of the transfer, it is recommended to store it for reconciliation
}

Base address Edit

wss://stream.wexex.io/public

Request message format Edit

{
    "method": "subscribe", 
    "params": [
        "{topic}@{arg},{arg}", 
        "{topic}@{arg}"
    ], 
    "id": "{id}"    //call back ID
}

Response message format Edit

{
    "id": "{id}",   //call back ID
    "code": 1,      //result 0=success;1=fail;2=listenKey invalid
    "msg": ""
}
{"id":"123", "code": 0, "msg": "success"}   

Push message format Edit

{
    "topic": "trade",             
    "event": "trade@btc_usdt",    //title
    "data": { }                   
}
{
    "topic": "trade", 
    "event": "trade@btc_usdt", 
    "data": {
        "s": "btc_usdt", 
        "i": 6316559590087222000, 
        "t": 1655992403617, 
        "p": "43000", 
        "q": "0.21", 
        "b": true
    }
}

Heartbeat Edit

Each link of the client needs to send a ping message periodically, and the server will reply to the pong message. If the server does not receive a ping message from the client within 1 minute, it will actively disconnect the link.

Subscription parameters Edit

format

{topic}@{arg},{arg},…

Orderbook manage Edit

How to manage a local order book correctly

1.Open a stream to wss://stream.wexex.io/public , depth_update@btc_usdt

2.Buffer the events you receive from the stream.

3.Get a depth snapshot from https://sapi.wexex.io/v4/public/depth?symbol=btc_usdt&limit=500

4.Drop any event where i is <= lastUpdateId in the snapshot.

5.The first processed event should have fi <= lastUpdateId+1 AND i >= lastUpdateId+1.

6.While listening to the stream, each new event’s fi should be equal to the previous event’s i+1.

7.The data in each event is the absolute quantity for a price level.

8.If the quantity is 0, remove the price level.

9.Receiving an event that removes a price level that is not in your local order book can happen and is normal.

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

Trade record Edit

request

format: trade@{symbol}

eg: trade@btc_usdt

rate: real

{
    "topic": "trade", 
    "event": "trade@btc_usdt", 
    "data": {
        "s": "btc_usdt",          // symbol
        "i": 6316559590087222000, // trade id
        "t": 1655992403617,       // trade time
        "p": "43000",             // trade price
        "q": "0.21",              // qty,trade quantity
        "b": true                 // whether is buyerMaker or not
    }
}

K-line Edit

request

 

format: kline@{symbol},{interval}

interval: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M

eg: kline@btc_usdt,5m

rate: 1000ms

 

{
    "topic": "kline", 
    "event": "kline@btc_usdt,5m", 
    "data": {
        "s": "btc_usdt",        // symbol
        "t": 1656043200000,     // time
        "i": "5m",              // interval
        "o": "44000",           // open price
        "c": "50000",           // close price
        "h": "52000",           // highest price
        "l": "36000",           // lowest price
        "q": "34.2",            // qty(quantity)
        "v": "230000"           // volume
    }
}

Limited depth Edit

request

 

format: depth@{symbol},{levels}

levels: 5, 10, 20, 50

eg: depth@btc_usdt,20

rate: 1000ms

{
    "topic": "depth", 
    "event": "depth@btc_usdt,20", 
    "data": {
        "s": "btc_usdt",        // symbol
        "i": 12345678,          // updateId
        "t": 1657699200000,     // time
        "a": [                  // asks(sell order)
            [                   //[0]price, [1]quantity
                "34000",        //price
                "1.2"           //quantity 
            ], 
            [
                "34001", 
                "2.3"
            ]
        ], 
        "b": [                   // bids(buy order)
            [
                "32000", 
                "0.2"
            ], 
            [
                "31000", 
                "0.5"
            ]
        ]
    }
}

Incremental depth Edit

request

format: depth_update@{symbol}

eg: depth_update@btc_usdt

rate: 100ms

{
    "topic": "depth_update", 
    "event": "depth_update@btc_usdt", 
    "data": {
        "s": "btc_usdt",        // symbol
        "fi": 121,              // firstUpdateId = previous lastUpdateId + 1
        "i": 123,               // lastUpdateId
        "a": [                  // asks  sell order
            [                   // [0]price, [1]quantity
                "34000",        //price
                "1.2"           //quantity
            ], 
            [
                "34001", 
                "2.3"
            ]
        ], 
        "b": [                  // bids buy order
            [
                "32000", 
                "0.2"
            ], 
            [
                "31000", 
                "0.5"
            ]
        ]
    }
}

ticker Edit

request

format: ticker@{symbol}

eg: ticker@btc_usdt

rate: 1000ms

{
    "topic": "ticker", 
    "event": "ticker@btc_usdt", 
    "data": {
        "s": "btc_usdt",      // symbol
        "t": 1657586700119,   // time(Last transaction time)
        "cv": "-200",         // priceChangeValue(24 hour price change)
        "cr": "-0.02",        // priceChangeRate 24-hour price change (percentage)
        "o": "30000",         // open price
        "c": "39000",         // close price
        "h": "38000",         // highest price
        "l": "40000",         // lowest price
        "q": "4",             // quantity
        "v": "150000",        // volume
   }
}

All ticker Edit

request

format: tickers

rate: 1000ms, only when there are changes

{
    "topic": "tickers", 
    "event": "tickers", 
    "data": [ ]  // refer to ticker(real-time push)
}

Base address Edit

wss://stream.wexex.io/private

Request message format Edit

param format

{topic}@{arg},{arg},…

{
    "method": "subscribe", 
    "params": [
        "{topic}@{arg},{arg}",    //event
        "{topic}@{arg}"
    ], 
    "listenKey": "512312356123123123",   //the listener Key, Apply accessToken through /v4/ws-token interface
    "id": "{id}"
}

Response message format Edit

{
    "id": "{id}", //call back ID
    "code": 1,     //result 0=success;1=fail;2=listenKey invalid
    "msg": ""
}

Get token Edit

/v4/ws-token

{
    "rc": 0,
    "mc": "SUCCESS",
    "ma": [],
    "result": {
        "accessToken": "eyJhbqGciOiJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoiYXV0aCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.h3zJlJBQrK2x1HvUxsKivnn6PlSrSDXXXJ7WqHAYSrN2CG5XPTKc4zKnTVoYFbg6fTS0u1fT8wH7wXqcLWXX71vm0YuP8PCvdPAkUIq4-HyzltbPr5uDYd0UByx0FPQtq1exvsQGe7evXQuDXx3SEJXxEqUbq_DNlXPTq_JyScI",
        "refreshToken": "eyJhbGciOiqJSUzI1NiJ9.eyJhY2NvdW50SWQiOiIyMTQ2Mjg1MzIyNTU5Iiwic3ViIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsInNjb3BlIjoicmVmcmVzaCIsImlzcyI6Inh0LmNvbSIsImxhc3RBdXRoVGltZSI6MTY2MzgxMzY5MDk1NSwic2lnblR5cGUiOiJBSyIsInVzZXJOYW1lIjoibGh4dDRfMDAwMUBzbmFwbWFpbC5jYyIsImV4cCI6MTY2NjQwNTY5MCwiZGV2aWNlIjoidW5rbm93biIsInVzZXJJZCI6MjE0NjI4NTMyMjU1OX0.Fs3YVm5YrEOzzYOSQYETSmt9iwxUHBovh2u73liv1hLUec683WGfktA_s28gMk4NCpZKFeQWFii623FvdfNoteXR0v1yZ2519uNvNndtuZICDdv3BQ4wzW1wIHZa1skxFfqvsDnGdXpjqu9UFSbtHwxprxeYfnxChNk4ssei430"
    }
}

Push message format Edit

{
    "topic": "trade",          
    "event": "trade@btc_usdt", 
    "data": { }                
}

Change of balance Edit

param

format: balance

eg: balance

{
    "topic": "balance", 
    "event": "balance", 
    "data": {
        "a": "123",           // accountId                     
        "t": 1656043204763,   // time happened time
        "c": "btc",           // currency
        "b": "123",           // balance available balance
        "f": "11",            // frozen
        "z": "SPOT",           // bizType [SPOT,LEVER]
        "s": "btc_usdt"       // symbol
    }
}

Change of order Edit

param

format: order

eg: order

{
    "topic": "order", 
    "event": "order", 
    "data": {
        "s": "btc_usdt",                // symbol
        "bc": "btc",                    // base currency 
        "qc": "usdt",                   // quotation currency 
        "t": 1656043204763,             // happened time
        "ct": 1656043204663,            // create time
        "i": "6216559590087220004",     // order id,
        "ci": "test123",                // client order id
        "st": "PARTIALLY_FILLED",       // state NEW/PARTIALLY_FILLED/FILLED/CANCELED/REJECTED/EXPIRED
        "sd": "BUY",                    // side BUY/SELL
        "tp": "LIMIT",                  // type LIMIT/MARKET
        "oq":  "4"                      // original quantity
        "oqq":  48000,                  // original quotation quantity 
        "eq": "2",                      // executed quantity
        "lq": "2",                      // remaining quantity
        "p": "4000",                    // price 
        "ap": "30000",                  // avg price
        "f":"0.002"                     // fee 
    }
}

Order filled Edit

param

format: trade

eg: trade

{
    "topic": "trade", 
    "event": "trade", 
    "data": {
        "s": "btc_usdt",                // symbol
        "t": 1656043204763,             //time 
        "i": "6316559590087251233",     // tradeId
        "oi": "6216559590087220004",    // orderId
        "p": "30000",                   // trade price
        "q": "3",                       // qty quantity
        "v": "90000"                    //volumn trade amount
    }
}