JU DOC logo

简体中文
english
Index Spot
首页 现货

Overview Edit

Welcome to JU API documentation. JU provides REST and Websocket APIs to suit your trading needs.

API Resources and Support Edit

Java libraries

A lightweight Java code library: Java SDK

JavaScript SDK

This JavaScript SDK provides access to various endpoints for interacting with the JU platform: JavaScript SDK

概述 Edit

欢迎使用 JU API 文档。 JU 提供 REST 和 Websocket API 来满足您的交易需求。

API 资源和支持 Edit

Java 库

一个轻量级的Java代码库: Java SDK

JavaScript 库

此 JavaScript SDK 提供对各种端点的访问,以便与 JU 平台进行交互: JavaScript SDK

REST API Edit

production environment: https://api.jucoin.com

https://api.jucoin.io(backup 1)
https://api.jucoin.live(backup 2)

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 JU 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, dataing in varying levels of latency between your local program and the JU 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://api.jucoin.io/v1/spot/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: 3976eb88-76d0-4f6e-a6b2-a57980770085

secretKey: bc6630d0231fda5cd98794f52c4998659beda290

Header part data:

validate-algorithms: HmacSHA256

validate-appkey: 3976eb88-76d0-4f6e-a6b2-a57980770085

validate-recvwindow: 5000

validate-timestamp: 1641446237201

validate-signature: 2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9

request data:

{
  type: 'LIMIT',
  timeInForce: 'GTC',
  side: 'BUY',
  symbol: 'btc_usdt',
  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:

/v1/spot/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&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1

    The above concatenated value is recorded as body

json:

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

    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=3976eb88-76d0-4f6e-a6b2-a57980770085&validate-recvwindow=5000&validate-timestamp=1641446237201

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=2063495b-85ec-41b3-a810-be84ceb78751&validate-recvwindow=60000&validate-timestamp=1666026215729#POST#/v1/spot/order#{"symbol":"JU_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}

sample request message:

    curl --location --request POST 'https://api.jucoin.io/v1/spot/order' 
    --header 'accept: */*' 
    --header 'Content-Type: application/json' 
    --header 'validate-algorithms: HmacSHA256' 
    --header 'validate-appkey: 10c172ca-d791-4da5-91cd-e74d202dac96' 
    --header 'validate-recvwindow: 60000' 
    --header 'validate-timestamp: 1666026215729' 
    --header 'validate-signature: 4cb36e820f50d2e353e5e0a182dc4a955b1c26efcb4b513d81eec31dd36072ba' 
    --data-raw '{"symbol":"JU_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}'    

matters needing attention:

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

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/jucoin-dev/ju-java-demo

response format Edit

All interface returns are in JSON format.

{
    "code": 200,
    "data": {
      },
    "msg": "SUCCESS"
    "msgInfo": []
}

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
code return Code
0 business success
1 business failure
msg 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
SYMBOL_007 The trading pair does not support order modification
SYMBOL_010 This market does not support your trading
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 or PROTECTION_LIMIT Filter
ORDER_F0501 Trigger PROTECTION_LIMIT Filter - Buy Max Deviation
ORDER_F0502 Trigger PROTECTION_LIMIT Filter - Sell Max Deviation
ORDER_F0503 Trigger PROTECTION_LIMIT Filter - Buy Limit Coefficient
ORDER_F0504 Trigger PROTECTION_LIMIT Filter - Sell Limit Coefficient
ORDER_F0601 Trigger PROTECTION_MARKET Filter
ORDER_F0704 Liquidation price limit for leveraged limit orders
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 Cancel the part that cannot be transacted immediately (taking orders)
FOK Cancellation if all transactions cannot be completed immediately
GTX Only pending orders, the triggering of transaction conditions will be cancelled immediately

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

/v1/spot/public/time

public String getServerInfo(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "serverTime": 1662435658062  
  }
}

Get client ip Edit

/v1/spot/public/client

public String getClient(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "ip": 192.168.1.1  
  }
}

Get symbol information Edit

/v1/spot/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
tags array false

Limit Flow Rules

1.single symbol:10/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 four parts:

1.buyMaxDeviation: The maximum deviation of the buy order, determine the minimum buy order price based on this value and the latest transaction price

2.buyPriceLimitCoefficient: The buy limit coefficient, determine the maximum buy order price based on this value and the latest transaction price

3.sellMaxDeviation: The maximum deviation of the sell order, determine the maximum sell order price based on this value and the latest transaction price

4.sellPriceLimitCoefficient: The sell limit coefficient, determine the minimum sell order price based on this value 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  && price <= latestPrice+latestPrice*buyPriceLimitCoefficient

sell order: price <= latestPrice+latestPrice*sellMaxDeviation  && price >= latestPrice-latestPrice*sellPriceLimitCoefficient


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.

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "time": 1662444177871,  
    "version": "7cd2cfab0dc979339f1de904bd90c9cb",  
    "symbols": [                   
      {
        "id": 614,                   //ID
        "symbol": "btc_usdt",        
        "displayName": "string",                    //展示名称
        "type": "string",  
        "state": "ONLINE",           //symbol state [ONLINE;OFFLINE,DELISTED]
        "stateTime": null,                          //状态时间
        "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,       
        "baseCurrencyLogo": "string",               //标的资产LOGO
        "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

/v1/spot/public/depth

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

Limit Flow Rules

1/s/ip

public String depth(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "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

/v1/spot/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

10/s/ip

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "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

/v1/spot/public/trade/recent

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

Limit Flow Rules

10/s/ip

public String tradeRecent(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "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

/v1/spot/public/trade/history

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

Limit Flow Rules

10/s/ip

public String tradeHistory(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "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

/v1/spot/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 array false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:10/s/ip

2.multiple symbols:10/s/ip

public String price(){


}

{
    "code": 200,
    "msg": "SUCCESS",
    "msgInfo": [],
    "data": [
          {
            "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

/v1/spot/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 array false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:10/s/ip

2.multiple symbols:10/s/ip

public String price(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "s": "btc_usdt",      //symbol
      "t": 1661856036925    //time
      "p": "9000.0000",     //price
      }
  ]
}

Get the best pending order ticker Edit

/v1/spot/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 array false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:10/s/ip

2.multiple symbols:10/s/ip

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "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

/v1/spot/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 array false Set of tags, separated by commas, currently only supports spot

Limit Flow Rules

1.single symbol:10/s/ip

2.multiple symbols:10/s/ip

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "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

/v1/spot/order/{orderId}

Parameters
Parameter Type mandatory Default Description Ranges
orderId number true
public String orderGet(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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",   
    "nftId": "string",
    "symbolType": "string",
    "state": "NEW",                         //order stat NEW,PARTIALLY_FILLED,FILLED,CANCELED,REJECTED,EXPIRED
    "deductServices":[{                     //Fee deduction list (if set JU deduction fee and the deduction occurs, use this field to represent the trade fee. Otherwise, use the original fee and feeCurrency fields to represent the trade fee). 
                          "fee":"0.1",     
                          "feeCurrency":"ju"
                      },
                      {   
                          "fee":"0.001",
                          "feeCurrency":"btc"
                      }],
    "closed": true,
    "time": 1655958915583,                  //order time
    "ip": "127.0.0.1",                      //ip address
    "updatedTime": 1655958915583  
  }
}

Query single Edit

/v1/spot/order

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


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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",  
    "nftId": "string",
    "symbolType": "string",
    "state": "NEW",                     //order stat NEW,PARTIALLY_FILLED,FILLED,CANCELED,REJECTED,EXPIRED
    "deductServices":[{                 //Fee deduction list (if set JU deduction fee and the deduction occurs, use this field to represent the trade fee. Otherwise, use the original fee and feeCurrency fields to represent the trade fee).  
                          "fee":"0.1",     
                          "feeCurrency":"ju"
                      },
                      {   
                          "fee":"0.001",
                          "feeCurrency":"btc"
                      }],
    "closed": true,
    "time": 1655958915583,              //order time
    "ip": "127.0.0.1",                      //ip address
    "updatedTime": 1655958915583  
  }
}

Submit order Edit

/v1/spot/order

Parameters
Parameter Type mandatory Default Description Ranges
symbol string true
clientOrderId string false Pattern: ^[a-zA-Z0-9_]{4,32}$
side enum true BUY,SELL
type enum true order type:LIMIT,MARKET
timeInForce enum true effective way:GTC, FOK, IOC, GTX
bizType enum 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
nftId string false nft id
media string false
mediaChannel string false

Remark

Create a BUY order based on market price, quantity must be null, quoteQty required; Create a SELL order based on market price, quoteQty must be null, quantity required.

Limit Flow Rules

50/s/apikey

public String orderPost(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "orderId": "6216559590087220004",
    "clientOrderId": "6216559590087220004"                 
  }
}

Cancell order Edit

/v1/spot/order/{orderId}

Parameters
Parameter Type mandatory Default Description Ranges
orderId number true
public String orderDel(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "cancelId": "6216559590087220004",
    "orderId": "string",
    "clientCancelId": "string"
  }
}

Get batch Edit

/v1/spot/batch-order

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

reponse field information, refer to the Get single interface

public String batchOrderGet(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "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",
      "nftId": "string",
      "symbolType": "string",
      "state": "NEW",
      "deductServices":[{   //Fee deduction list (if set JU deduction fee and the deduction occurs, use this field to represent the trade fee. Otherwise, use the original fee and feeCurrency fields to represent the trade fee). 
                            "fee":"0.1",     
                            "feeCurrency":"ju"
                        },
                        {   
                            "fee":"0.001",
                            "feeCurrency":"btc"
                        }],
      "closed": true,
      "time": 1655958915583,
      "ip": "127.0.0.1",
      "updatedTime": 1655958915583
    }
  ]
}

Submit batch order Edit

/v1/spot/batch-order

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

Limit Flow Rules

30/s/apikey

public String batchOrderPost(){


}

{
  "clientBatchId": "51232",
  "items": [
    {
      "symbol": "BTC_USDT",
      "clientOrderId": "16559590087220001",
      "side": "BUY",
      "type": "LIMIT",
      "timeInForce": "GTC",
      "bizType": "SPOT",
      "price": 40000,
      "quantity": 2,
      "quoteQty": 80000
    }
  ]
}
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "batchId": "123", 
    "items": [   
      {
        "index": "0", // start with 0 
        "clientOrderId": "123", 
        "orderId": "123", 
        "reject": false, 
        "reason": "invalid price precision" 
      }
    ]
  }
}

Update Order(Limit) Edit

/v1/spot/order/{orderId}

Parameters
Parameter Type mandatory Default Description Ranges
orderId number true order ID
price number true Price
quantity number true Quantity
clientOrderId string false client Order Id

Limit Flow Rules

50/s/apikey

public String orderPost(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "orderId": "6216559590087220004",   //order id
    "modifyId": "407329711723834560",    //modify id
    "clientModifyId": "string"
  }
}

Cancell batch order Edit

/v1/spot/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(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {}
}

Query the current pending order Edit

/v1/spot/open-order

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

Limit Flow Rules

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [      //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",
      "nftId": "string",
      "symbolType": "string",
      "state": "NEW",
      "deductServices":[{   //Fee deduction list (if set JU deduction fee and the deduction occurs, use this field to represent the trade fee. Otherwise, use the original fee and feeCurrency fields to represent the trade fee). 
                            "fee":"0.1",     
                            "feeCurrency":"ju"
                        },
                        {   
                            "fee":"0.001",
                            "feeCurrency":"btc"
                        }],
      "closed": true,
      "time": 1655958915583,
      "ip": "127.0.0.1",
      "updatedTime": 1655958915583
    }
  ]
}

Cancel the current pending order Edit

/v1/spot/open-order

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

Limit Flow Rules

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

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {}
}

Query historical orders Edit

/v1/spot/history-order

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

Limit Flow Rules

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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",
        "nftId": "string",
        "symbolType": "string",
        "deductServices":[{   //Fee deduction list (if set JU deduction fee and the deduction occurs, use this field to represent the trade fee. Otherwise, use the original fee and feeCurrency fields to represent the trade fee). 
                              "fee":"0.1",     
                              "feeCurrency":"ju"
                          },
                          {   
                              "fee":"0.001",
                              "feeCurrency":"btc"
                          }],
        "closed": true,
        "time": 1655958915583,
        "ip": "127.0.0.1",
        "updatedTime": 1655958915583
      }
    ]
  }
}

Query trade Edit

/v1/spot/trade

Parameters
Parameter Type mandatory Default Description Ranges
symbol string false Trading pair, if not filled in, represents all
bizType enum false SPOT, LEVER
orderSide enum false BUY,SELL
orderType enum false LIMIT, MARKET
orderId number false
fromId number false start id
direction enum false query direction:PREV, NEXT
limit number false 20 Limit number, max 100,min 1
startTime number false start time eg:1657682804112
endTime number false
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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", 
        "nftId": "000012313",               //nftId
        "symbolType": "nft",               
        "takerMaker": "taker"  //takerMaker
      }
    ]
  }
}

Get currency information Edit

/v1/spot/public/currencies

Parameters
Parameter Type mandatory Default Description Ranges
version string false
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
      "time":0,
      "version":"",
      "currencies": [
              {
                  "id": 11,                
                  "currency": "usdt",      
                  "displayName": "",    
                  "type": "",           
                  "nominalValue": "",   
                  "fullName": "usdt",       
                  "logo": null,             
                  "cmcLink": null,          
                  "weight": 100,            
                  "maxPrecision": 6,        
                  "depositStatus": 1,       
                  "withdrawStatus": 1,      
                  "convertEnabled": 1,      
                  "transferEnabled": 1,     
                  "isChainExist": 1,        
                  "plates": [],              
                  "isListing": 1,           
                  "withdrawCloseReason": ""  
              }
      ]

    }
}

Get a single currency asset Edit

/v1/spot/balance

Parameters
Parameter Type mandatory Default Description Ranges
currency string true eg:usdt
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "currency": "usdt",  
    "currencyId": 0,   
    "frozenAmount": 0,      
    "freeze": 0,            
    "lock": 0,              
    "copyTrade": 0,         
    "trade": 0,             
    "withdraw": 0,          
    "availableAmount": 0,  
    "totalAmount": 0,    
    "convertBtcAmount": 0,   //Converted BTC amount
    "convertUsdtAmount": 0   //Converted USDT amount
  }
}

Get a list of currency assets Edit

/v1/spot/balances

Parameters
Parameter Type mandatory Default Description Ranges
currencies string false List of currencies, comma separated,eg: usdt,btc
queryAccountId long false
filterIsDisplayFalse boolean false true

Limit Flow Rules

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "totalBtcAmount": 0,
    "totalUsdtAmount": 0,
    "assets": [    
      {        
        "currency": "string",
        "currencyId": 0,
        "frozenAmount": 0,      
        "freeze": 0,            
        "lock": 0,              
        "copyTrade": 0,         
        "trade": 0,            
        "withdraw": 0,         
        "availableAmount": 0,
        "totalAmount": 0,
        "convertBtcAmount": 0,
        "convertUsdtAmount": 0   
      }
    ]
  }
}

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

/v1/spot/public/wallet/support/currency

Remark

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

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
        "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
                "contract": "contractaddress" //contract address
            }
        ]           
    },
    {
        "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
                "contract": "contractaddress" //contract address
            }
        ]
    }
  ]
}

Get the deposit address Edit

/v1/spot/deposit/address

Parameters
Parameter Type mandatory Default Description Ranges
chain string true network for deposit
currency string true currency name
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "address": "0xfa3abfa50eb2006f5be7831658b17aca240d8526",     //wallet address
    "memo": ""
  }
}

Get history records of deposit Edit

/v1/spot/deposit/history

Parameters
Parameter Type mandatory Default Description Ranges
currency string true Currency name, can be obtained from the response of "Get the supported currencies for deposit or withdrawal" API
chain string true 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
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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

/v1/spot/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

Limit Flow Rules

1/s/apikey

{
    "currency":"zb",
    "chain":"Ethereum",
    "amount":1000,
    "address":"0xfa3abfa50eb2006f5be7831658b17aca240d8526",
    "memo":""
}
{
    "code": 200,
    "mc": "SUCCESS",
    "msgInfo": [],
    "data": {      
        "id": 100    //Long  Withdrawal record id, used for querying withdrawal history later
    }
}

Withdrawal history Edit

/v1/spot/withdraw/history

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
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
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
        "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
            }
        ]
  }
}

General WSS information Edit

Base Address

wss://stream.ju.com/public

Request Headers

The request header of the compression extension protocol must be added.

Sec-Websocket-Extensions:permessage-deflate

Request message format Edit

{
    "method": "subscribe", 
    "params": [
        "{topic}@{arg},{arg}", 
        "{topic}@{arg}"
    ], 
    "id": "{id}"    //call back ID
}
{
    "method": "unsubscribe", 
    "params": [
        "{topic}@{arg},{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"}   
{"id":"123", "code": 401, "msg": "token expire"}

Push message format Edit

{
    "topic": "trade",             
    "event": "trade@btc_usdt",    //title
    "data": { }                   
}
{
    "topic": "trade", 
    "event": "trade@btc_usdt", 
    "data": {
        "s": "btc_usdt",           //symbol
        "i": 6316559590087222000,  //tradeId
        "t": 1655992403617,        //time
        "oi": 6616559590087222666, //orderId
        "p": "43000",              //price
        "q": "0.21",               //quantity
        "v": "9030"                //quoteQty
        "b": true                  //whether is buyerMaker or not
    }
}

Heartbeat Edit

Each link of the client needs to send a text “ping” periodically, and the server will reply to the text “pong”. 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.ju.com/public , depth_update@btc_usdt

2.Buffer the events you receive from the stream.

3.Get a depth snapshot from https://api.jucoin.io/v1/spot/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,  //tradeId
        "t": 1655992403617,        //time
        "oi": 6616559590087222666, //orderId
        "p": "43000",              //price
        "q": "0.21",               //quantity
        "v": "9030"                //quoteQty
        "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
   }
}

General WSS information Edit

Base Address

wss://stream.ju.com/private

Request Headers

The request header of the compression extension protocol must be added.

Sec-Websocket-Extensions:permessage-deflate

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 /v1/spot/ws-token interface
    "id": "{id}"
}
{
    "method": "unsubscribe", 
    "params": [
        "{topic}@{arg},{arg}",    //event
        "{topic}@{arg}"
    ], 
    "listenKey": "512312356123123123",   //the listener Key, Apply accessToken through /v1/spot/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

/v1/spot/ws-token

Note:

The accessToken is valid for 2 days. Calling the endpoint again will reset the validity period.

accessToken = listenKey

{
    "code": 200,
    "mc": "SUCCESS",
    "msgInfo": [],
    "data": {
        "accessToken": "xxxxxx",
        "refreshToken": "xxxxxx"
    }
}

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",           // all spot 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
        "i": 6316559590087222000,  //tradeId
        "t": 1655992403617,        //time
        "oi": 6616559590087222666, //orderId
        "p": "43000",              //price
        "q": "0.21",               //quantity
        "v": "9030"                //quoteQty
        "b": true                  //whether is buyerMaker or not
    }
}

REST API Edit

生产环境: https://api.jucoin.com

https://api.jucoin.io(备用1)
https://api.jucoin.live(备用2)

接口的基本信息 Edit

鉴于延迟高和稳定性差等原因,不建议通过代理的方式访问API。

GET请求参数放入query Params中,POST请求参数放入request body中

请求头信息请设置为:Content-Type=application/json

对于/public以外开头的请求,需要对请求报文进行签名

限频规则 Edit

部分接口会有限流控制(对应接口下会有限流说明),限流主要分为网关限流和WAF限流。

若接口请求触发了网关限流则会返回429,表示警告访问频次超限,即将被封IP或者apiKey。

网关限流分为针对IP和apiKey限流。

IP限流示例说明:100/s/ip,表示每个IP每秒该接口请求次数限制。

apiKey限流示例说明:50/s/apiKey,表示每个apiKey每秒该接口请求次数限制。

签名说明 Edit

由于JU需要为第三方平台提供一些开放性的接口,所以需要接口的数据安全问题,比如数据是否被篡改,数据是否已过时,数据是否可以重复提交,接口在某个时间内访问频率等问题。其中数据是否被篡改是最重要的。

1、先通过用户中心申请appkey和secretkey,针对不同的调用,提供不同的appkey和secretkey

2、加入timestamp(时间戳),其值应当是请求发送时刻的unix时间戳(毫秒),数据的有郊时间根据此值来计算。

3、加入signature(数据签名),所有数据的签名信息。

4、加入recvwindow(自定义请求有效时间),有效时间目前相对简单统一固定为某个值。

服务器收到请求时会判断请求中的时间戳,最长60秒,最小为2秒,如果是5000毫秒之前发出的,则请求会被认为无效。这个时间窗口值可以通过发送可选参数recvWindow来设置。 另外,如果服务器计算得出客户端时间戳在服务器时间的‘未来’一秒以上,也会拒绝请求。 关于交易时效性 互联网状况并不100%可靠,不可完全依赖,因此你的程序本地到JU服务器的时延会有抖动. 这是我们设置recvwindow的目的所在,如果你从事高频交易,对交易时效性有较高的要求,可以灵活设置recvwindow以达到你的要求。

不推荐使用5秒以上的recvwindow

5、加入algorithms (签名方法/算法),用户计算签名是基于哈希的协议,推荐使用HmacSHA256。具体支持那些协议,请参见下面表格中所列出。

HmacMD5、HmacSHA1、HmacSHA224、HmacSHA256(推荐)、HmacSHA384、HmacSHA512

签名生成 Edit

以https://api.jucoin.io/v1/spot/order为例。

以下是在linux bash环境下使用 echo openssl 和curl工具实现的一个调用接口下单的示例 appkey、secret仅供示范:

appKey: 3976eb88-76d0-4f6e-a6b2-a57980770085

secretKey: bc6630d0231fda5cd98794f52c4998659beda290

Header部分数据:

validate-algorithms: HmacSHA256

validate-appkey: 3976eb88-76d0-4f6e-a6b2-a57980770085

validate-recvwindow: 5000

validate-timestamp: 1641446237201

validate-signature: 2b5eb11e18796d12d88f13dc27dbbd02c2cc51ff7059765ed9821957d82bb4d9

请求数据:

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

1、数据部分

method: 大写的请求方法,例如:GET、POST、DELETE、PUT

path: 按照path中顺序将所有value进行拼接。形如/test/{var1}/{var2}/的restful路径将按填入的实际参数后路径拼接,示例:/sign/test/bb/aa

query: 按照key的字典序排序,将所有key=value进行拼接。示例:userName=dfdfdf&password=ggg

body:   
    Json: 直接按JSON字符串不做转换或排序操作。

    x-www-form-urlencoded: 按照key的字典序排序,将所有key=value进行拼接,示例:userName=dfdfdf&password=ggg 

    form-data:此格式暂不支持。

如果存在多种数据形式,则按照path、query、body的顺序进行再拼接,得到所有数据的拼接值。

方法method示例:

POST

路径path示例:

/v1/spot/order

上述拼接值记作为path

参数通过query示例:

symbol=btc_usdt

上述值拼接记作query

参数通过body示例

x-www-form-urlencoded:
  
    symbol=btc_usdt&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1

    上述值拼接记作body

json:

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

    上述值拼接记作body

混合使用query与body(分为表单与json两种格式)

query: 
    symbol=btc_usdt&side=BUY&type=LIMIT
    上述拼接值记作query

body: 
    {"symbol":"btc_usdt","side":BUY,"type":"LIMIT"}
    上述拼接值记作body

整个数据最且拼接值由#符号分别与method、path、query、body进行拼接成#method、#path、#query、#body,最终拼接值记作为Y=#method#path#query#body。 注意:

query有数据,body无数据:Y=#method#path#query

query无数据,body有数据:Y=#method#path#body

query有数据,body有数据:Y=#method#path#query#body

2、请求头部分 将key按照字母自然升序后,使用&方式拼接在一起,作为X。如:

    validate-algorithms=HmacSHA256&validate-appkey=3976eb88-76d0-4f6e-a6b2-a57980770085&validate-recvwindow=5000&validate-timestamp=1641446237201

3、生成签名

最终把需要进行加密的字符串,记作为original=XY

最后将最终拼接值按照如下方法进行加密得到签名。

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

将生成的签名singature放到请求头中,以validate-signature为Key,以singature为值。

4、样例

签名原始报文样例:

    validate-algorithms=HmacSHA256&validate-appkey=2063495b-85ec-41b3-a810-be84ceb78751&validate-recvwindow=60000&validate-timestamp=1666026215729#POST#/v1/spot/order#{"symbol":"JU_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}

请求报文样例:
  
    curl --location --request POST 'https://api.jucoin.io/v1/spot/order' 
    --header 'accept: */*' 
    --header 'Content-Type: application/json' 
    --header 'validate-algorithms: HmacSHA256' 
    --header 'validate-appkey: 10c172ca-d791-4da5-91cd-e74d202dac96' 
    --header 'validate-recvwindow: 60000' 
    --header 'validate-timestamp: 1666026215729' 
    --header 'validate-signature: 4cb36e820f50d2e353e5e0a182dc4a955b1c26efcb4b513d81eec31dd36072ba' 
    --data-raw '{"symbol":"JU_USDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","bizType":"SPOT","price":3,"quantity":2}'

注意事项:
    注意检查 Content-Type、签名原始报文中的参数格式、请求报文中的参数格式

API 代码库 Edit

Java connector

一个轻量级的Java代码库,提供让用户直接调用API的方法。

各个语言的sdk:

  java : https://github.com/jucoin-dev/ju-java-demo

响应格式 Edit

所有的接口返回都是JSON格式。

{
    "code": 200,
    "data": {
      },
    "msg": "SUCCESS"
    "msgInfo": []
}

响应代码 Edit

httpStatus 描述
200 请求成功,请进一步查看rc、mc部分
404 接口不存在
429 请求过于频繁,请按照限速要求,控制请求速率
500 服务异常
502 网关异常
503 服务不可用,请稍后重试
code return Code
200 业务成功
500 业务失败
msg message code
SUCCESS 成功
FAILURE 失败
AUTH_001 缺少请求头 validate-appkey
AUTH_002 缺少请求头 validate-timestamp
AUTH_003 缺少请求头 validate-recvwindow
AUTH_004 错误的请求头 validate-recvwindow
AUTH_005 缺少请求头 validate-algorithms
AUTH_006 错误的请求头 validate-algorithms
AUTH_007 缺少请求头 validate-signature
AUTH_101 ApiKey不存在
AUTH_102 ApiKey未激活
AUTH_103 签名错误
AUTH_104 非绑定IP请求
AUTH_105 报文过时
AUTH_106 超出apikey权限
SYMBOL_001 交易对不存在
SYMBOL_002 交易对未开盘
SYMBOL_003 交易对暂停交易
SYMBOL_004 此交易对不支持您所在的国家
SYMBOL_005 该市场不支持通过API进行交易
SYMBOL_007 该交易对暂不支持改单
SYMBOL_010 该市场不支持您进行交易
ORDER_001 平台拒单
ORDER_002 资金不足
ORDER_003 交易对暂停交易
ORDER_004 禁止交易
ORDER_005 订单不存在
ORDER_006 过多的未完成订单
ORDER_007 子账户暂无交易权限
ORDER_008 当前下单价格或数量精度异常
ORDER_F0101 触发价格过滤器-最小值
ORDER_F0102 触发价格过滤器-最大值
ORDER_F0103 触发价格过滤器-步进值
ORDER_F0201 触发数量过滤器-最小值
ORDER_F0202 触发数量过滤器-最大值
ORDER_F0203 触发数量过滤器-步进值
ORDER_F0301 触发金额过滤器-最小值
ORDER_F0401 触发开盘保护滤器或限价保护过滤器
ORDER_F0501 触发限价保护滤器-买单最大偏离度
ORDER_F0502 触发限价保护滤器-卖单最大偏离度
ORDER_F0503 触发限价保护滤器-买单限制系数
ORDER_F0504 触发限价保护滤器-卖单限制系数
ORDER_F0601 触发市价保护滤器
ORDER_F0704 杠杠限价订单爆仓价格限制
COMMON_001 用户不存在
COMMON_002 系统繁忙,请稍后再试
COMMON_003 操作失败,请稍后再试
CURRENCY_001 币种信息异常
DEPOSIT_001 充值暂未开放
DEPOSIT_002 当前账号安全等级较低,请绑定手机/邮箱/谷歌身份验证器中的任意两种安全验证后再进行充值
DEPOSIT_003 地址格式不正确,请重新输入
DEPOSIT_004 地址已存在,请重新输入
DEPOSIT_005 冷钱包地址未找到
DEPOSIT_006 暂无充值地址,请稍后再试
DEPOSIT_007 地址生成中,请稍后再试
DEPOSIT_008 不支持充值
WITHDRAW_001 提现暂未开放
WITHDRAW_002 提币地址不合法
WITHDRAW_003 当前账号安全等级较低,请绑定手机/邮箱/谷歌身份验证器中的任意两种安全验证后再进行提现
WITHDRAW_004 未添加提币地址
WITHDRAW_005 提币地址不能为空
WITHDRAW_006 Memo不能为空
WITHDRAW_008 触发风控,暂不支持该币提现
WITHDRAW_009 提现失败,本次提现中部分资产受T+1提币限制
WITHDRAW_010 提币精度不合法
WITHDRAW_011 可用余额不足
WITHDRAW_012 提现失败,您今日剩余提现额度不足
WITHDRAW_013 提现失败,您今日剩余提现额度不足,可通过完成更高等级的实名认证提高额度
WITHDRAW_014 该笔提现地址不能使用内部转账功能,请取消内部转账功能后再提交
WITHDRAW_015 提现金额不足以抵扣手续费
WITHDRAW_016 提币地址已经存在
WITHDRAW_017 本次提币已处理,无法取消
WITHDRAW_018 Memo必须为数字
WITHDRAW_019 Memo不正确,请重新输入
WITHDRAW_020 您今日提现额度已达上限,请明天再试
WITHDRAW_021 您今日提现额度已达上限,本次最多只能提现{0}
WITHDRAW_022 提现金额必须大于{0}
WITHDRAW_023 提现金额必须小于{0}
WITHDRAW_024 不支持提现
WITHDRAW_025 请前往充值页面创建FIO地址
FUND_001 请求重复(一个bizId请求多次接口)
FUND_002 余额不足
FUND_003 划转操作不支持 (比如子账户不支持理财划入划出)
FUND_004 解冻失败
FUND_005 划转禁止
FUND_014 划入账户id和划出账户id不可以一样
FUND_015 from和to 业务类型不可相同(用户不可以操作自己现货划转到现货)
FUND_016 杠杆交易对不可为空
FUND_017 参数错误
FUND_018 冻结记录无效
FUND_019 解冻用户不相等
FUND_020 解冻币种不相等
FUND_021 操作不支持
FUND_022 冻结记录不存在
FUND_044 金额最大长度为113 不可超过限制
SYMBOL_001 交易对不存在
TRANSFER_001 请求重复(一个bizId请求多次接口)
TRANSFER_002 余额不足
TRANSFER_003 用户未注册
TRANSFER_004 币种不允许划转
TRANSFER_005 用户币种不允许划转
TRANSFER_006 划转禁止
TRANSFER_007 请求超时
TRANSFER_008 杠杆划入异常
TRANSFER_009 杠杆划出异常
TRANSFER_010 杠杆清零 划出禁止
TRANSFER_011 杠杆有借贷 划出禁止
TRANSFER_012 币种划转禁止
GATEWAY_0001 触发风控
GATEWAY_0002 触发风控
GATEWAY_0003 触发风控
GATEWAY_0004 触发风控

公共模块 Edit

订单状态码及含义

State 说明
NEW 新建
PARTIALLY_FILLED 部分成交
FILLED 全部成交
CANCELED 用户撤单
REJECTED 下单失败
EXPIRED 过期(time_in_force撤单或溢价撤单)

订单类型及含义

Type 说明
LIMIT 限价单
MARKET 市价单

交易对状态及含义

State 说明
ONLINE 上线的
OFFLINE 下线的
DELISTED 退市的

有效方式及含义

这里定义了订单多久能够失效

TimeInForces 说明
GTC 成交为止,一直有效
IOC 无法立即成交(吃单)的部分就撤销
FOK 无法全部立即成交就撤销
GTX 只挂单,触发成交条件会被立即撤销

充值/提现记录状态码及含义

Status 说明
SUBMIT 提现: 未冻结
REVIEW 提现: 已冻结,待审核
AUDITED 提现: 已审核,发送钱包,待上链
AUDITED_AGAIN 复审中
PENDING 充值/提现: 已上链
SUCCESS 完成
FAIL 失败
CANCEL 已取消

BizType

Status Description
SPOT 现货
LEVER 杠杠
FINANCE 理财
FUTURES_U 合约u本位
FUTURES_C 合约币本位

FAQ Edit

1.AUTH_105:服务器在校验请求头参数validate-timestamp(validTimeStamp)、validate-recvwindow(recvwindow)时, 需要符合以下规则:dealTimeStamp(请求被处理时服务器时间,单位毫秒)- validTimeStamp < recvwindow ,否则就会返回AUTH_105,为了避免此错误,建议validate-timestamp 设置为请求发出的时间,以毫秒为单位,validate-recvwindow设置的大一点

获取服务器时间 Edit

/v1/spot/public/time

public String getServerInfo(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "serverTime": 1662435658062  //服务器时间
  }
}

获取客户端IP Edit

/v1/spot/public/client

public String getClient(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "ip": 192.168.1.1  
  }
}

获取交易对信息 Edit

/v1/spot/public/symbol

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对 eg:btc_usdt
symbols array false 交易对集合,优先级高于symbol。 eg: btc_usdt,eth_usdt
version string false 版本号,当请求版本号与响应内容版本一致时,不返回清单,减少IO eg: 2e14d2cd5czcb2c2af2c1db65078d075
tags array false

限流规则

1.获取单个交易对:10/s/ip

2.获取多个交易对:10/s/ip


过滤器

过滤器,即Filter,定义了一系列交易规则。针对不同的领域或者实体有不同的过滤器,这里主要介绍针对symbol这个实体的过滤器。 对于symbol来说,有两种过滤器,一种是全局过滤器,一种是针对某个交易对定制的过滤器。


价格过滤器 PRICE FILTER

价格过滤器 用于检测订单中 price 参数的合法性。包含以下三个部分:

1.min 定义了订单中price允许的最小值

2.max 定义了订单中price允许的最大值

3.tickSize 定义了订单中price的步进间隔,即price必须等于minPrice+(tickSize的整数倍)

以上每一项均可为null,为null时代表这一项不再做限制

逻辑伪代码如下:

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

数量过滤器  QUANTITY FILTER

其逻辑和PRICE FILTER 类似,不过针对的是订单数量。

其内部包含三个部分

1.min 允许的最小值

2.max 允许的最大值

3.tickSize  步进间隔,即quantity必须等于minQuantity+(tickSize的整数倍)

以上每一项均可为null,为null时代表这一项不再做限制

逻辑伪代码如下:

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

金额过滤器 QUOTE_QTY FILTER

对于订单的金额做限制

其内部定义了min允许的最小值

当min为null时,订单不做限制

否则限制规则如下:

1.对于限价LIMIT类型的订单,需满足 price*quantity>=min

2.对于市价MARKET类型并且是购买类型(orderSide=BUY)订单,需满足quoteQty>=min,(quoteQty,市价按金额下单时必填的金额)


开盘保护过滤器 PROTECTION_ONLINE FILTER

对处于开盘之后指定的时间范围内,对于限价类型的订单的价格进行限制

该过滤器内部定义了最大价格倍数(maxPriceMultiple),持续时间(durationSeconds)。

限制逻辑:当处于交易对开盘后durationSeconds时间范围内,订单类型为限价类(LIMIT)的订单

须满足订单价格price<=openPrice*maxPriceMultiple,才会通过(openPrice为开盘价)。

其他类型的订单或者不在开盘时间范围内的订单不做限制。

对于maxPriceMultiple,durationSeconds均可为null,为null时,不做开盘保护限制。


限价保护过滤器 PROTECTION_LIMIT FILTER

对于订单类型(orderType)为LIMIT(限价) 类型的订单具有价格保护限制,包含以下四个部分

1.buyMaxDeviation: 买单最大偏离度,根据该值和最新成交价确定买单价格最小值

2.buyPriceLimitCoefficient: 买单限制系数,根据该值和最新成交价确定买单价格最大值

3.sellMaxDeviation: 卖单最大偏离度,根据该值和最新成交价确定卖单价格最大值

4.sellPriceLimitCoefficient: 卖单限制系数,根据该值和最新成交价确定卖单价格最小值

若没有最新成交价则不做限制,或者以上参数为null,则对应方向类型订单不做限制

为了通过限价保护,订单price必须满足以下条件(latestPrice为最新成交价)

买单: price >= latestPrice-latestPrice*buyMaxDeviation  && price <= latestPrice+latestPrice*buyPriceLimitCoefficient

卖单: price <= latestPrice+latestPrice*sellMaxDeviation  && price >= latestPrice-latestPrice*sellPriceLimitCoefficient


市价保护过滤器 PROTECTION_MARKET FILTER

对于订单类型为MARKET的订单具有价格限制保护机制,其内部规定了maxDeviation最大偏差率。

对于市价类型订单,市场价格须满足以下条件,订单才会通过(sellBestPrice  卖一价格,buyBestPrice 买一价格,latestPrice 最新成交价,这些数据均通过历史成交数据获得)

买单: latestPrice + latestPrice* maxDeviation >= sellBestPrice 

卖单: latestPrice - latestPrice* maxDeviation <= buyBestPrice

对于以上情况maxDeviation,latestPrice,sellBestPrice ,buyBestPrice

均有可能为空或者没有最新成交价,买一价格,卖一价格,则不做限制

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "time": 1662444177871,                          //时间
    "version": "7cd2cfab0dc979339f1de904bd90c9cb",  //内容版本
    "symbols": [                                    //交易对清单
      {
        "id": 614,                                  //ID
        "symbol": "btc_usdt",                       //交易对
        "displayName": "string",                    //展示名称
        "type": "string",                       
        "state": "ONLINE",                          //交易对状态[ONLINE=上线的;OFFLINE=下线的,DELISTED=退市]
        "stateTime": null,                          //状态时间
        "tradingEnabled": true,                     //启用交易
        "openapiEnabled": true,                     //启用OPENAPI
        "nextStateTime": null,                      //下一个状态时间
        "nextState": null,                          //下一个状态
        "depthMergePrecision": 5,                   //深度合并精度
        "baseCurrency": "btc",                      //标的资产
        "baseCurrencyPrecision": 5,                 //标的资产精度
        "baseCurrencyId": 2,                        //标的资产ID
        "baseCurrencyLogo": "string",               //标的资产LOGO
        "quoteCurrency": "usdt",                    //报价资产
        "quoteCurrencyPrecision": 6,                //报价资产精度
        "quoteCurrencyId": 11,                      //报价资产ID
        "pricePrecision": 4,                        //交易价格精度
        "quantityPrecision": 6,                     //交易数量精度
        "orderTypes": [                             //订单类型[LIMIT=限价单;MARKET=市价单]
          "LIMIT",
          "MARKET"
        ],
        "timeInForces": [                           //有效方式[GTC=成交为止,一直有效; IOC=无法立即成交(吃单)的部分就撤销; FOK=无法全部立即成交就撤销; GTX=无法成为挂单方就撤销]
          "GTC",
          "FOK",
          "IOC",
          "GTX"
        ],
        "displayWeight": 1,                         //展示权重,越大越靠前
        "displayLevel": "FULL",                     //展示级别,[FULL=完全展示,SEARCH=搜索展示,DIRECT=直达展示,NONE=不展示]
        "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
          },
       ]
      }
    ]
  }
}            

获取深度数据 Edit

/v1/spot/public/depth

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string true 交易对 eg:btc_usdt
limit number false 50 数量 1~1000

限流规则

1/s/ip

public String depth(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": {
    "timestamp": 1662445330524,          //时间戳
    "lastUpdateId": 137333589606963580,  //最后更新记录
    "bids": [                            //买盘([?][0]=价位;[?][1]=挂单量)
      [
        "200.0000",                      //价位
        "0.996000"                       //挂单量
      ],
      [
        "100.0000",
        "0.001000"
      ],
      [
        "20.0000",
        "10.000000"
      ]
    ],
    "asks": []                          //卖盘([?][0]=价位;[?][1]=挂单量)
  }
}

获取k线数据 Edit

/v1/spot/public/kline

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string true 交易对 eg:btc_usdt
interval string true K线类型 ,1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M eg:1m [1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M]
startTime number false 起始时间戳
endTime number false 结束时间戳
limit number false 100 限制数量 1~1000

限流规则

10/s/ip

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "t": 1662601014832,   //开盘时间(time)
      "o": "30000",         //开盘价(open)
      "c": "32000",         //收盘价(close)
      "h": "35000",         //最高价(high)
      "l": "25000",         //最低价(low)
      "q": "512",           //成交量(quantity)
      "v": "15360000"       //成交额(volume)
    }
  ]
}

查询近期成交列表 Edit

/v1/spot/public/trade/recent

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string true 交易对
limit number false 200 数量 1,1000

限流规则

10/s/ip

public String tradeRecent(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "i": 0,           //ID
      "t": 0,           //成交时间(time)
      "p": "string",    //成交价(price)
      "q": "string",    //成交量(quantity)
      "v": "string",    //成交额(volume)
      "b": true         //方向(buyerMaker)
    }
  ]
}

查询历史成交列表 Edit

/v1/spot/public/trade/history

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string true 交易对
limit number false 200 数量 1,1000
direction enum true 查询方向 PREV-上一页,NEXT-下一页
fromId number false 起始ID,eg: 6216559590087220004

限流规则

10/s/ip

public String tradeHistory(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "i": 0,           //ID
      "t": 0,           //成交时间(time)
      "p": "string",    //成交价(price)
      "q": "string",    //成交量(quantity)
      "v": "string",    //成交额(volume)
      "b": true         //方向(buyerMaker)
    }
  ]
}

完整ticker Edit

/v1/spot/public/ticker

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对 eg:btc_usdt
symbols array false 交易对集合,优先级高于symbol。 eg: btc_usdt,eth_usdt
tags array false 标签集合,逗号分割,当前仅支持 spot

限流规则

1.单个交易对:10/s/ip

2.多个交易对:10/s/ip

public String price(){


}

{
    "code": 200,
    "msg": "SUCCESS",
    "msgInfo": [],
    "data": [
          {
            "s": "btc_usdt",        //交易对(symbol)
            "t": 1662444879425,     //更新时间(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(卖一价)
            "aq": null,             //asks qty(卖一量)
            "bp": null,             //bids price(买一价)
            "bq": null              //bids qty(买一量)
            }
        ]
}

获取最新价格ticker Edit

/v1/spot/public/ticker/price

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对 eg:btc_usdt
symbols array false 交易对集合,优先级高于symbol。 eg: btc_usdt,eth_usdt
tags array false 标签集合,逗号分割,当前仅支持 spot

限流规则

1.单个交易对:10/s/ip

2.多个交易对:10/s/ip

public String price(){


}

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "s": "btc_usdt",     //交易对(symbol)
      "t": 1661856036925   //时间(time)
      "p": "9000.0000",    //价格(price)
      }
  ]
}

获取最优挂单ticker Edit

/v1/spot/public/ticker/book

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对 eg:btc_usdt
symbols array false 交易对集合,优先级高于symbol。 eg: btc_usdt,eth_usdt
tags array false 标签集合,逗号分割,当前仅支持 spot

限流规则

1.单个交易对:10/s/ip

2.多个交易对:10/s/ip

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "s": "btc_usdt",      //交易对(symbol)
      "t": 1661856036925,   //最后更新时间(last updated time) 
      "ap": null,           //asks price(卖一价)
      "aq": null,           //asks qty(卖一量)
      "bp": null,           //bids price(买一价)
      "bq": null            //bids qty(买一量)
    }
  ]
}

获取24h统计ticker Edit

/v1/spot/public/ticker/24h

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对 eg:btc_usdt
symbols array false 交易对集合,优先级高于symbol。 eg: btc_usdt,eth_usdt
tags array false 标签集合,逗号分割,当前仅支持 spot

限流规则

1.单个交易对:10/s/ip

2.多个交易对:10/s/ip

{
  "code": 200,
  "msg": "SUCCESS",
  "msgInfo": [],
  "data": [
    {
      "s": "btc_usdt",     //交易对(symbol)
      "t": 1661856036925,  //时间(time) 
      "cv": "0.0000",      //价格变动(change value)
      "cr": "0.00",        //价格变动百分比(change rate)
      "o": "9000.0000",    //最早一笔(open)
      "l": "9000.0000",    //最低(low)
      "h": "9000.0000",    //最高(high)
      "c": "9000.0000",    //最后一笔(close)
      "q": "0.0136",       //成交量(quantity)
      "v": "122.9940"      //成交额(volume)
    }
  ]
}

单笔获取 Edit

/v1/spot/order/{orderId}

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
orderId number true 订单ID
public String orderGet(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "symbol": "BTC_USDT",                   //交易对
    "orderId": "6216559590087220004",       //订单号
    "clientOrderId": "16559590087220001",   //客户端订单号
    "baseCurrency": "string",               //标的币种
    "quoteCurrency": "string",              //报价币种
    "side": "BUY",                          //订单方向 BUY-买,SELL-卖
    "type": "LIMIT",                        //订单类型  LIMIT-限价,MARKET-市价 
    "timeInForce": "GTC",                   //有效方式  GTC,IOC,FOK,GTX
    "price": "40000",                       //价格
    "origQty": "2",                         //原始数量
    "origQuoteQty": "48000",                //原始金额
    "executedQty": "1.2",                   //已执行数量
    "leavingQty": "string",                 //待执行数量(若撤单或下单拒绝,该值为0
    "tradeBase": "2",                       //成交标的(成交数量)
    "tradeQuote": "48000",                  //成交报价(成交金额)
    "avgPrice": "42350",                    //成交均价
    "fee": "string",                        //手续费
    "feeCurrency": "string",                //手续费币种
    "nftId": "string",
    "symbolType": "string",
    "state": "NEW",                         //订单状态 NEW-新建,PARTIALLY_FILLED-部分成交,FILLED-全部成交,CANCELED-用户撤单,REJECTED-下单失败,EXPIRED-过期(time_in_force撤单或溢价撤单)
    "deductServices":[{                     //手续费抵扣列表(如果设置手续费抵扣并产生抵扣,使用该字段代表手续费,没有抵扣使用原有fee、feeCurrency字段代表手续费)                         
                          "fee":"0.1",     
                          "feeCurrency":"ju"
                      },
                      {   
                          "fee":"0.001",
                          "feeCurrency":"btc"
                      }],
    "closed": true,
    "time": 1655958915583,                  //订单时间
    "ip": "127.0.0.1",                      //ip地址
    "updatedTime": 1655958915583            //订单更新时间
  }
}

单笔查询 Edit

/v1/spot/order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
orderId number false 订单ID
clientOrderId string false 客户端订单号
public String orderGet(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "symbol": "BTC_USDT",                   //交易对
    "orderId": "6216559590087220004",       //订单号
    "clientOrderId": "16559590087220001",   //客户端订单号
    "baseCurrency": "string",               //标的币种
    "quoteCurrency": "string",              //报价币种
    "side": "BUY",                          //订单方向 BUY-买,SELL-卖
    "type": "LIMIT",                        //订单类型  LIMIT-限价,MARKET-市价 
    "timeInForce": "GTC",                   //有效方式  GTC,IOC,FOK,GTX
    "price": "40000",                       //价格
    "origQty": "2",                         //原始数量
    "origQuoteQty": "48000",                //原始金额
    "executedQty": "1.2",                   //已执行数量
    "leavingQty": "string",                 //待执行数量(若撤单或下单拒绝,该值为0
    "tradeBase": "2",                       //成交标的(成交数量)
    "tradeQuote": "48000",                  //成交报价(成交金额)
    "avgPrice": "42350",                    //成交均价
    "fee": "string",                        //手续费
    "feeCurrency": "string",                //手续费币种
    "nftId": "string",
    "symbolType": "string",
    "state": "NEW",                         //订单状态 NEW-新建,PARTIALLY_FILLED-部分成交,FILLED-全部成交,CANCELED-用户撤单,REJECTED-下单失败,EXPIRED-过期(time_in_force撤单或溢价撤单)
    "deductServices":[{                     //手续费抵扣列表(如果设置手续费抵扣并产生抵扣,使用该字段代表手续费,没有抵扣使用原有fee、feeCurrency字段代表手续费)
                          "fee":"0.1",     
                          "feeCurrency":"ju"
                      },
                      {   
                          "fee":"0.001",
                          "feeCurrency":"btc"
                      }],
    "closed": true,
    "time": 1655958915583,                  //订单时间
    "ip": "127.0.0.1",                      //ip address
    "updatedTime": 1655958915583            //订单更新时间
  }
}

单笔下单 Edit

/v1/spot/order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string true 交易对
clientOrderId string false 客户端ID正则:^[a-zA-Z0-9_]{4,32}$
side enum true 买卖方向  BUY-买,SELL-卖
type enum true 订单类型  LIMIT-限价,MARKET-市价 
timeInForce enum true 有效方式 GTC, FOK, IOC, GTX
bizType enum true 业务类型 SPOT-现货, LEVER-杠杆
price number false 价格。限价必填; 市价不填
quantity number false 数量。限价必填;市价按数量下单时必填
quoteQty number false 金额。限价不填;市价按金额下单时必填
nftId string false nft id
media string false
mediaChannel string false

备注

按照市价创建BUY订单时,quantity为空,quoteQty必填;按照市价创建SELL订单时,quoteQty为空,quantity必填。

限流规则

50/s/apikey

public String orderPost(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "orderId": "6216559590087220004",   //订单ID
    "clientOrderId": "6216559590087220004" 
  }
}

单笔撤单 Edit

/v1/spot/order/{orderId}

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
orderId number true 订单ID
public String orderDel(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "cancelId": "6216559590087220004",
    "orderId": "string",
    "clientCancelId": "string"
  }
}

批量获取 Edit

/v1/spot/batch-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
orderIds long true 订单ID集合,逗号分割 eg: 6216559590087220004,6216559590087220004

reponse 字段信息参考单笔订单获取接口

public String batchOrderGet(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
      "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",
      "nftId": "string",
      "symbolType": "string",
      "state": "NEW",
      "deductServices":[{   //手续费抵扣列表(如果设置手续费抵扣并产生抵扣,使用该字段代表手续费,没有抵扣使用原有fee、feeCurrency字段代表手续费)
                            "fee":"0.1",     
                            "feeCurrency":"ju"
                        },
                        {   
                            "fee":"0.001",
                            "feeCurrency":"btc"
                        }],
      "closed": true,
      "time": 1655958915583,
      "ip": "127.0.0.1",
      "updatedTime": 1655958915583
    }
  ]
}

批量下单 Edit

/v1/spot/batch-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
clientBatchId string false 客户端批次号,正则:^[a-zA-Z0-9_]{4,32}$
items array true 集合
item.symbol string true 交易对
item.clientOrderId string false 客户端ID,正则:^[a-zA-Z0-9_]{4,32}$
item.side enum true 订单方向 BUY-买,SELL-卖
item.type enum true 订单类型 LIMIT-限价,MARKET-市价
item.timeInForce enum true 有效方式 GTC,IOC,FOK,GTX
item.bizType enum true 业务类型 SPOT-现货, LEVER-杠杆
item.price number false 价格。现价必填; 市价不填
item.quantity number false 数量。现价必填;市价按数量下单时必填
item.quoteQty number false 金额。现价不填;市价按金额下单时必填
item.media string false
item.mediaChannel string false
item.nftId string false

限流规则

30/s/apikey

public String batchOrderPost(){


}

{
  "clientBatchId": "51232",
  "items": [
    {
      "symbol": "BTC_USDT",
      "clientOrderId": "16559590087220001",
      "side": "BUY",
      "type": "LIMIT",
      "timeInForce": "GTC",
      "bizType": "SPOT",
      "price": 40000,
      "quantity": 2,
      "quoteQty": 80000
    }
  ]
}
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "batchId": "123",                       // 批次号 
    "items": [                              //订单集合
      {
        "index": "0",                       // 下标,从0开始 
        "clientOrderId": "123",             // 客户端订单ID 
        "orderId": "123",                   // 订单ID 
        "reject": false,                  // 是否拒单 
        "reason": "invalid price precision" // 拒单原因 
      }
    ]
  }
}

单笔改单(限价) Edit

/v1/spot/order/{orderId}

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
orderId number true 订单号
price number true 价格
quantity number true 数量
clientOrderId string false 客户端订单ID

限流规则

50/s/apikey

public String orderPost(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "orderId": "6216559590087220004",   //订单ID
    "modifyId": "407329711723834560",    //修改 id
    "clientModifyId": "string"
  }
}

批量撤单 Edit

/v1/spot/batch-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
clientBatchId string false 客户端批次号
orderIds array true 集合[6216559590087220004,6216559590087220005]

注意:参数以json形式放在body中

public String batchOrderDel(){


}

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {}
}

查询当前挂单 Edit

/v1/spot/open-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对,不传代表所有
bizType enum false 业务类型 SPOT-现货, LEVER-杠杆
side enum false BUY-买,SELL-卖

限流规则

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [      //字段信息参考单笔订单获取接口
    {
      "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",
      "nftId": "string",
      "symbolType": "string",          
      "state": "NEW",
      "deductServices":[{   //手续费抵扣列表(如果设置手续费抵扣并产生抵扣,使用该字段代表手续费,没有抵扣使用原有fee、feeCurrency字段代表手续费)
                            "fee":"0.1",     
                            "feeCurrency":"ju"
                        },
                        {   
                            "fee":"0.001",
                            "feeCurrency":"btc"
                        }],
      "closed": true,
      "time": 1655958915583,
      "ip": "127.0.0.1",
      "updatedTime": 1655958915583
    }
  ]
}

撤销当前挂单 Edit

/v1/spot/open-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对,不传代表所有
bizType enum true 业务类型 SPOT-现货, LEVER-杠杆
side enum false BUY-买,SELL-卖
mode enum false CMD, ITERATOR

限流规则

10/s/apikey
注意:参数以json形式放在body中

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {}
}

历史订单查询 Edit

/v1/spot/history-order

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对,不传代表所有
bizType enum false 业务类型 SPOT-现货, LEVER-杠杆
side enum false BUY-买,SELL-卖
type enum false 订单类型 LIMIT-限价, MARKET-市价
state enum false 订单状态 NEW-新建,PARTIALLY_FILLED-部分成交,FILLED-全部成交,CANCELED-用户撤单,REJECTED-下单失败,EXPIRED-过期(time_in_force撤单或溢价撤单)
fromId number false 起始ID
direction enum false 查询方向:PREV, NEXT
limit number false 20 限制数量,最大100,最小1
startTime number false 开始时间 eg:1657682804112
endTime number false 结束时间
hiddenCanceled bool false 隐藏已取消

限流规则

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "hasPrev": true,
    "hasNext": true,
    "items": [   //内容信息参考单笔获取订单接口
      {
        "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",
        "nftId": "string",
        "symbolType": "string",          
        "deductServices":[{   //手续费抵扣列表(如果设置手续费抵扣并产生抵扣,使用该字段代表手续费,没有抵扣使用原有fee、feeCurrency字段代表手续费)
                              "fee":"0.1",     
                              "feeCurrency":"ju"
                          },
                          {   
                              "fee":"0.001",
                              "feeCurrency":"btc"
                          }],
        "closed": true,
        "time": 1655958915583,
        "ip": "127.0.0.1",
        "updatedTime": 1655958915583
      }
    ]
  }
}

成交查询 Edit

/v1/spot/trade

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
symbol string false 交易对,不传代表所有
bizType enum false 业务类型 SPOT-现货, LEVER-杠杆
orderSide enum false BUY-买,SELL-卖
orderType enum false 订单类型 LIMIT-限价, MARKET-市价
orderId number false 订单号
fromId number false 分页起始ID
direction enum false 查询方向:PREV, NEXT
limit number false 20 限制数量,最大100,最小1
startTime number false 开始时间 eg:1657682804112
endTime number false 结束时间
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "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",                //成交金额
        "baseCurrency": "BTC",              //标的币种类型
        "quoteCurrency": "USDT",            //报价币种类型
        "fee": "0.5",                       //手续费资产金额
        "feeCurrency": "USDT",              //手续费资产类型
        "nftId": "000012313",               //nftId
        "symbolType": "nft",               //交易对类型
        "takerMaker": "taker"               //takerMaker
      }
    ]
  }
}

获取币种信息 Edit

/v1/spot/public/currencies

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
version string false
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "time":0,
    "version":"",
    "currencies": [
            {
                "id": 11,                //币种id
                "currency": "usdt",       //币种名称
                "displayName": "",    //展示名称
                "type": "",           //币种类型,FT | NFT
                "nominalValue": "",   //面值
                "fullName": "usdt",       //币种全称
                "logo": null,             //币种logo
                "cmcLink": null,          //cmc链接
                "weight": 100,            //权重
                "maxPrecision": 6,        //精度
                "depositStatus": 1,       //充值状态(0关闭 1开放)
                "withdrawStatus": 1,      //提现状态(0关闭 1开放)
                "convertEnabled": 1,      //小额资产兑换开关[0=关;1=开]
                "transferEnabled": 1,     //划转开关[0=关;1=开]
                "isChainExist": 1,        //链上是否存在 0 1
                "plates": [],              //所属板块
                "isListing": 1,           //是否上架 0 1 默认为1
                "withdrawCloseReason": ""  //提现关闭原因
            }
    ]
    
  }
}

获取单个币种资产 Edit

/v1/spot/balance

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
currency string true eg:usdt
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "currency": "usdt",     //币种
    "currencyId": 0,        //币种ID
    "frozenAmount": 0,      //不可用(全部冻结=冻结+锁仓+跟单+委托+提现)
    "freeze": 0,      //冻结
    "lock": 0,      //锁仓
    "copyTrade": 0,      //跟单
    "trade": 0,      //委托
    "withdraw": 0,      //提现
    "availableAmount": 0,   //可用数量
    "totalAmount": 0,       //总数量
    "convertBtcAmount": 0,   //折算BTC数量
    "convertUsdtAmount": 0   //折算USDT数量
  }
}

获取币种资产列表 Edit

/v1/spot/balances

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
currencies string false 币种列表,逗号分隔,eg: usdt,btc
queryAccountId long false 查询账户id不传递的话默认使用当前账户id
filterIsDisplayFalse boolean false true

限流规则

10/s/apikey

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "totalBtcAmount": 0,
    "totalUsdtAmount": 0,
    "assets": [    //参数内容参考获取单个币种资产接口
      {        
        "currency": "string",
        "currencyId": 0,
        "frozenAmount": 0,      //不可用(全部冻结=冻结+锁仓+跟单+委托+提现)
        "freeze": 0,            //冻结
        "lock": 0,              //锁仓
        "copyTrade": 0,         //跟单
        "trade": 0,             //委托
        "withdraw": 0,          //提现
        "availableAmount": 0,
        "totalAmount": 0,
        "convertBtcAmount": 0,
        "convertUsdtAmount": 0   //折算USDT数量
      }
    ]
  }
}

获取JU可充提的币种 Edit

/v1/spot/public/wallet/support/currency

备注

currency 、chain 字段需要在后续充值/提现接口中使用

{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": [
    {
        "currency": "BTC",                  //币种
        "supportChains": [
            {
                "chain": "Bitcon",          //支持的转账网络
                "depositEnabled": true,     //是否支持充值,true:支持,false:不支持
                "withdrawEnabled": true,    //是否支持提现,true:支持,false:不支持
                "withdrawFeeAmount": 0.2,   //提现手续费
                "withdrawMinAmount": 10,    //最小提现数量
                "depositFeeRate": 0.2,      //充值费率,百分比
                "contract": "contractaddress" //合约地址
            }
        ]           
    },
    {
        "currency": "ETF",                  //币种
        "supportChains": [
            {
                "chain": "Ethereum",        //支持的转账网络
                "depositEnabled": true,     //是否支持充值,true:支持,false:不支持
                "withdrawEnabled": true,    //是否支持提现,true:支持,false:不支持
                "withdrawFeeAmount": 0.2,   //提现手续费
                "withdrawMinAmount": 10,    //最小提现数量
                "depositFeeRate": 0.2,      //充值费率,百分比
                "contract": "contractaddress" //合约地址
            }
        ]
    }
  ]
}

获取充值地址 Edit

/v1/spot/deposit/address

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
chain string true 转账网络名称
currency string true 币种名称
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "address": "0xfa3abfa50eb2006f5be7831658b17aca240d8526",     //钱包地址
    "memo": ""
  }
}

充值历史 Edit

/v1/spot/deposit/history

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
currency string true 币种名称,可从“获取JU可充提的币种”接口中获取
chain string true 转账网络名称,可从“获取JU可充提的币种”接口中获取
status string false 充值记录的状态 SUBMIT、REVIEW、AUDITED、PENDING、SUCCESS、FAIL、CANCEL
fromId long false 上次开始分页的Id,即记录的主键id
direction string false NEXT 分页方向 NEXT:下一页,PREV:上一页
limit int false 10 每页记录数,最大不超过200 1<=limit<=200
startTime long false 查询范围开始边界,毫秒级时间戳
endTime long false 查询范围结束边界,毫秒级时间戳
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
    "hasPrev": true,            //是否有上一页
    "hasNext": true,            //是否有下一页
    "items": [
      {
         "id": 169669597,       //提现记录id
         "currency": "xlm2",    //币种名称
         "chain": "XLM",        //转账网络名称
         "memo": "441824256",   //memo
         "status": "SUCCESS",   //充值状态
         "amount": "0.1",       //充值金额
         "confirmations": 12,   //区块确认数
         "transactionId": "28dd15b5c119e00886517f129e5e1f8283f0286b277bcd3cd1f95f7fd4a1f7fc",   //交易哈希
         "address": "GBY6UIYEYLAAXRQXVO7X5I4BSSCS54EAHTUILXWMW6ONPM3PNEA3LWEC",     //充值目标地址
         "fromAddr": "GBTISB3JK65DG6LEEYYFW33RMMDHBQ65AEUPE5VDBTCLYYFS533FTG6Q",    //来源地址
         "createdTime": 1667260957000   //充值时间,毫秒级时间戳
      }
    ]
  }
}

提现 Edit

/v1/spot/withdraw

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
currency string true 币种名称,可从'获取JU可充提的币种'接口中获取
chain string true 转账网络名称,可从'获取JU可充提的币种'接口中获取
amount number true 提现金额,包含手续费部分
address string true 提现地址
memo String false memo,对于EOS类似的需要memo的链必传

注意:参数以json形式放在body中

限流规则

1/s/apikey

{
    "currency":"zb",
    "chain":"Ethereum",
    "amount":1000,
    "address":"0xfa3abfa50eb2006f5be7831658b17aca240d8526",
    "memo":""
}
{
    "code": 200,
    "mc": "SUCCESS",
    "msgInfo": [],
    "data": {      
        "id": 100    //Long  提现记录id,用于后期查询提现历史记录
    }
}

提现历史 Edit

/v1/spot/withdraw/history

Parameters
参数 数据类型 是否必须 默认值 描述 取值范围
currency string true 币种名称,可从'获取JU可充提的币种'接口中获取
chain string true 转账网络名称,可从'获取JU可充提的币种'接口中获取
status string false 提现记录的状态,字符串类型(含义见公共模块-充值/提现记录状态码及含义) SUBMIT、REVIEW、AUDITED、AUDITED_AGAIN、PENDING、SUCCESS、FAIL、CANCEL
fromId Long false 上次开始分页的Id,即记录的主键id
direction String false NEXT 分页方向 NEXT:下一页,PREV:上一页
limit int false 10 每页记录数,最大不超过200 1<=limit<=200
startTime Long false 查询范围开始边界,毫秒级时间戳
endTime Long false 查询范围结束边界,毫秒级时间戳
{
  "code": 200,
  "msg": "string",
  "msgInfo": [
    {}
  ],
  "data": {
        "hasPrev": true,                       //是否有上一页
        "hasNext": true,                       //是否有下一页
        "items": [
            {
                "id": 763111,                  //提现记录id
                "currency": "usdt",            //币种名称
                "chain": "Ethereum",           //提现网络
                "address": "0xfa3abfa50eb2",   //提现目标地址
                "memo": "",
                "status": "REVIEW",            //状态,含义见公共模块-充值/提现记录状态码及含义
                "amount": "30",                //提现金额
                "fee": "0",                    //提现手续费
                "confirmations": 0,            //区块确认数
                "transactionId": "",           //交易哈希
                "createdTime": 1667763470000                                
            },
            {
                "id": 763107,
                "currency": "usdt",
                "chain": "Tron",
                "address": "TYnJJwaJKkqVvE2zEfUvFbHgKxVBY5zGq9",
                "memo": "",
                "status": "REVIEW",
                "amount": "50",
                "fee": "1",
                "confirmations": 0,
                "transactionId": "",
                "createdTime": 1667428286000
            }
        ]
  }
}

基本信息 Edit

基地址

wss://stream.ju.com/public

Request Headers

请求头必须添加压缩扩展协议。

Sec-Websocket-Extensions:permessage-deflate

请求报文格式 Edit

{
    "method": "subscribe", 
    "params": [
        "{topic}@{arg},{arg}", 
        "{topic}@{arg}"
    ], 
    "id": "{id}"    //回调ID
}
{
    "method": "unsubscribe", 
    "params": [
        "{topic}@{arg},{arg}"
    ], 
    "id": "{id}"   //回调ID
}

响应报文格式 Edit

{
    "id": "{id}",   //请求回调ID
    "code": 1,      //结果0=成功;1=失败;2=listenKey⽆效
    "msg": ""
}
{"id":"123", "code": 0, "msg": "success"}   
{"id":"123", "code": 401, "msg": "token expire"}

推送报文格式 Edit

{
    "topic": "trade",             //事件
    "event": "trade@btc_usdt",    //主题
    "data": { }                   //数据
}
{
    "topic": "trade", 
    "event": "trade@btc_usdt", 
    "data": {
        "s": "btc_usdt",           //symbol
        "i": 6316559590087222000,  //成交id
        "t": 1655992403617,        //时间
        "oi": 6616559590087222666, //订单id
        "p": "43000",              //价格
        "q": "0.21",               //数量
        "v": "9030"                //金额
        "b": true                  //是否是buyerMaker
    }
}

心跳 Edit

客户端每个链接需要定期发送”ping”字符串,服务端会回复”pong”,服务端在1分钟内没有收到客户端的ping消息,会主动断开链接

订阅参数 Edit

结构

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

Orderbook 维护 Edit

如何正确在本地维护一个orderbook副本

1.订阅 wss://stream.ju.com/public,depth_update@btc_usdt

2.开始缓存收到的更新。同一个价位,后收到的更新覆盖前面的。

3.访问Rest接口 https://api.jucoin.io/v1/spot/public/depth?symbol=btc_usdt&limit=500 获得一个500档的深度快照

4.将目前缓存到的信息中i <= 步骤3中获取到的快照中的lastUpdateId的部分丢弃(丢弃更早的信息,已经过期)。

5.将深度快照中的内容更新到本地orderbook副本中,并从websocket接收到的第一个fi <= lastUpdateId+1 且 i >= lastUpdateId+1 的event开始继续更新本地副本。

6.每一个新event的fi应该恰好等于上一个event的i+1,否则可能出现了丢包,请从step3重新进行初始化。

7.每一个event中的挂单量代表这个价格目前的挂单量绝对值,而不是相对变化。

8.如果某个价格对应的挂单量为0,表示该价位的挂单已经撤单或者被吃,应该移除这个价位。

注意: 因为深度快照对价格档位数量有限制,初始快照之外的价格档位并且没有数量变化的价格档位不会出现在增量深度的更新信息内。因此,即使应用来自增量深度的所有更新,这些价格档位也不会在本地 order book 中可见, 所以本地的 order book 与真实的 order book 可能会有一些差异。 不过对于大多数用例,500 的深度限制足以有效地了解市场和交易。

成交记录 Edit

请求

语法: trade@{symbol}

示例: trade@btc_usdt

速率: 实时

{
    "topic": "trade", 
    "event": "trade@btc_usdt", 
    "data": {
        "s": "btc_usdt",           //symbol
        "i": 6316559590087222000,  //成交id
        "t": 1655992403617,        //时间
        "oi": 6616559590087222666, //订单id
        "p": "43000",              //价格
        "q": "0.21",               //数量
        "v": "9030"                //金额
        "b": true                  //是否是buyerMaker
    }
}

K线 Edit

请求

 

语法: kline@{symbol},{interval}

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

示例: kline@btc_usdt,5m

速率: 1000ms

 

{
        "topic": "kline",
        "event": "kline@btc_usdt,5m",
            "data": {
            "s": "btc_usdt",       // symbol 交易对
            "t": 1656043200000,    // time 时间
            "i": "5m",             // interval 间隔
            "o": "44000",          // open 开盘价
            "c": "50000",          // close 收盘价
            "h": "52000",          // high 最⾼价
            "l": "36000",          // low 最低价
            "q": "34.2",           // qty 成交量
            "v": "230000"          // volume 成交额
            }
}

有限深度 Edit

请求

 

语法: depth@{symbol},{levels}

levels: 5, 10, 20, 50

示例: depth@btc_usdt,20

速率: 1000ms

{
    "topic": "depth", 
    "event": "depth@btc_usdt,20", 
    "data": {
        "s": "btc_usdt",        // symbol 交易对
        "i": 12345678,          // updateId
        "t": 1657699200000,     // time 时间戳
        "a": [                  // asks 卖盘
            [                   //[0]价格, [1]数量
                "34000",        //价格
                "1.2"           //数量 
            ], 
            [
                "34001", 
                "2.3"
            ]
        ], 
        "b": [                   // bids 买盘
            [
                "32000", 
                "0.2"
            ], 
            [
                "31000", 
                "0.5"
            ]
        ]
    }
}

增量深度 Edit

请求

语法: depth_update@{symbol}

示例: depth_update@btc_usdt

速率:100ms

{
    "topic": "depth_update", 
    "event": "depth_update@btc_usdt", 
    "data": {
        "s": "btc_usdt",        // symbol 交易对
        "fi": 121,              // firstUpdateId 等于上一次推送的lastUpdateId + 1
        "i": 123,               // lastUpdateId
        "a": [                  // asks 卖盘
            [                   // [0]价格, [1]数量
                "34000",        //价格
                "1.2"           //数量
            ], 
            [
                "34001", 
                "2.3"
            ]
        ], 
        "b": [                  // bids 买盘
            [
                "32000", 
                "0.2"
            ], 
            [
                "31000", 
                "0.5"
            ]
        ]
    }
}

ticker Edit

请求

语法: ticker@{symbol}

示例: ticker@btc_usdt

速率: 1000ms

{
    "topic": "ticker", 
    "event": "ticker@btc_usdt", 
    "data": {
        "s": "btc_usdt",      // symbol 交易对
        "t": 1657586700119,   // time 最后成交时间
        "cv": "-200",         // priceChangeValue 24⼩时价格变化
        "cr": "-0.02",        // priceChangeRate 24⼩时价格变化(百分⽐)
        "o": "30000",         // open 第⼀笔
        "c": "39000",         // close 最后⼀笔
        "h": "38000",         // high 最⾼价
        "l": "40000",         // low 最低价
        "q": "4",             // quantity 成交量
        "v": "150000",        // volume 成交额
    }
}

基本信息 Edit

基地址

wss://stream.ju.com/private

Request Headers

请求头必须添加压缩扩展协议。

Sec-Websocket-Extensions:permessage-deflate

请求报文格式 Edit

param结构

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

{
    "method": "subscribe", 
    "params": [
        "{topic}@{arg},{arg}",    //event
        "{topic}@{arg}"
    ], 
    "listenKey": "512312356123123123",   //监听Key,先通过/v1/spot/ws-token接⼝获取accessToken
    "id": "{id}"
}
{
    "method": "unsubscribe", 
    "params": [
        "{topic}@{arg},{arg}",    //event
        "{topic}@{arg}"
    ], 
    "listenKey": "512312356123123123",   //监听Key,先通过/v1/spot/ws-token接⼝获取accessToken
    "id": "{id}"
}

响应报⽂格式 Edit

{
    "id": "{id}",   //请求回调ID
    "code": 1,      //结果1=成功;0=失败;2=listenKey⽆效
    "msg": ""
}

获取token接口 Edit

/v1/spot/ws-token

备注:

accessToken有效期是2天,重新调用接口获取token会重置有效期。

accessToken = listenKey

{
    "code": 200,
    "mc": "SUCCESS",
    "msgInfo": [],
    "data": {
        "accessToken": "xxxxxx",
        "refreshToken": "xxxxxx"
    }
}

推送报⽂格式 Edit

{
    "topic": "trade",          //主题
    "event": "trade@btc_usdt", //事件
    "data": { }                //数据
}

余额变动 Edit

param

语法: balance

示例: balance

{
    "topic": "balance", 
    "event": "balance", 
    "data": {
        "a": "123",           // accountId 账号 
        "t": 1656043204763,   // time 发⽣时间
        "c": "btc",           // currency 币种
        "b": "123",           // balance 全部现货资产
        "f": "11",            // frozen 冻结资产
        "z": "SPOT",          // bizType 业务类型[SPOT,LEVER]
        "s": "btc_usdt"       // symbol 交易市场  
    }
}

订单变动 Edit

param

语法: order

示例: order

{
    "topic": "order", 
    "event": "order", 
    "data": {
        "s": "btc_usdt",                // symbol 交易对
        "bc": "btc",                    // baseCurrency 标的币种
        "qc": "usdt",                   // quoteCurrency 报价币种
        "t": 1656043204763,             // time 发⽣时间
        "ct": 1656043204663,            // createTime 下单时间
        "i": "6216559590087220004",     // orderId 订单号
        "ci": "test123",                // clientOrderId 客户端订单号
        "st": "PARTIALLY_FILLED",       // state 状态 NEW/PARTIALLY_FILLED/FILLED/CANCELED/REJECTED/EXPIRED
        "sd": "BUY",                    // side 方向 BUY/SELL
        "tp": "LIMIT",                  // type 类型 LIMIT/MARKET
        "oq":  "4"                      // origQty 原始数量
        "oqq":  48000,                  // origQuoteQty 原始金额
        "eq": "2",                      // executedQty 已执⾏数量
        "lq": "2",                      // leavingQty 待执行数量
        "p": "4000",                    // price 价格
        "ap": "30000",                  // avg price 均价
        "f": "0.001"                    // fee 手续费
    }
}

订单成交 Edit

param

语法: trade

示例: trade

{
    "topic": "trade", 
    "event": "trade", 
    "data": {
        "s": "btc_usdt",           //symbol
        "i": 6316559590087222000,  //成交id
        "t": 1655992403617,        //时间
        "oi": 6616559590087222666, //订单id
        "p": "43000",              //价格
        "q": "0.21",               //数量
        "v": "9030"                //金额
        "b": true                  //是否是buyerMaker
    }
}