Skip to content

REST_api_reference

topq-exchange edited this page Mar 3, 2020 · 3 revisions

API Reference

For the signature rules, please refer to the signature rules specification document

The interface list

Interface category Description Type Need attestation The request URL
The market KLine GET N /api/data/v1/klines
The market Ticker(Single symbol) GET N /api/data/v1/tickers
The market Trade(Single symbol) GET N /api/data/v1/trades
The market Market Depth(Single symboll) GET N /api/data/v1/entrusts
The market Get market list GET N /exchange/config/controller/website/marketcontroller/getByWebId
Trade type information Gets token list GET N /exchange/config/controller/website/currencycontroller/getCurrencyList
Account information Get all funding information POST Y /exchange/fund/controller/website/fundcontroller/findbypage
Trading Place order POST Y /exchange/entrust/controller/website/EntrustController/addEntrust
Trading Cancel order POST Y /exchange/entrust/controller/website/EntrustController/cancelEntrust
Trading Get order details GET Y /exchange/entrust/controller/website/EntrustController/getEntrustById
Trading Check current outstanding orders GET Y /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCacheWithPage
Trading Search for history commission GET Y /exchange/entrust/controller/website/EntrustController/getUserEntrustList
Deposit and withdrawal Get the deposit address POST Y /exchange/fund/controller/website/fundcontroller/getPayinAddress
Deposit and withdrawal Search for deposit records POST Y exchange/fund/controller/website/fundcontroller/getPayinCoinRecord
Deposit and withdrawal Search for withdrawal address GET Y /exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress
Deposit and withdrawal Search for withdrawal record GET Y /exchange/fund/controller/website/fundwebsitecontroller/getpayoutcoinrecord

Response:

{
    "datas":{},
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}
Parameter name Required Type Description Value range
datas true Array/Object Returned data
resMsg true Obeject The result information returned
resMsg.code true string Returned code 1: success, other errors, see error code document
resMsg.message true string Returns a description of the result
resMsg.method false string

The market

Interface description: get K line data

Interface type: GET

Interface URL: /api/data/v1/klines

Authentication: N

Request parameters:

Parameter name Required Type Description Default Value range
marketId true int Transfer market id or market name
marketName false string Transfer market id or market name
type true string Kline type, 1M:one minutes,5M:five minutes,15M:fifteen minutes,30M:thirty minutes,1H:Hour line,1D:Daily line,1W:Week line
dataSize false int Data size ,maximum is 500 0<=dataSize<=500

Example:

https://www.topliq.com/api/data/v1/klines?marketId=102&type=1M

Response:

{
    "datas": [
        [
            "K",          //Data type, K line 
            "102",        //The market id
            "btc_usdt",   //Symbol
            "1569302520", //Timestamp
            "9741.6",     //Open
            "9741.7",     //High
            "9737.2",     //Low
            "9737.3",     //Close
            "5.18",       //Volume
            "0.0441",     //change
            "1M",         //Kline type,one minutes:1M
            "50458.35"    //Trading Volume
        ],
        // more kline data here...
    ],
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

Interface description: Get tickers (Single symbol)

Interface type: GET

Interface URL: /api/data/v1/tickers

Authentication: N

Request parameters:

Parameter name Required Type Description Default Value range
marketId true int Transfer market id or market name
marketName false string Transfer market id or market name

Example:

https://www.topliq.com/api/data/v1/ticker?marketId=102

Response:

{
    "datas": [
        "102",            //The market id
        "9754.4",         //Last
        "9968.8",         //High
        "9631.5",         //Low
        "47865.6432",     //24h Volume
        "-2.28",          //24h change
        // Last 6 hours closing price list
        "[[1, 9750.1], [2, 9737.1], [3, 9727.5], [4, 9722], [5, 9722.1], [6, 9754.4]]",  
        "9752.12",        //take 1 price
        "9756.69",        //make 1 price
        "469849357.2364"  // 24h trading volume, i.e. sum(each transaction price * the transaction volume)
    ],
    "resMsg": {
        "message": "success !",
        "method": null,
        "code": "1"
    }
}

Interface description: Get Trade (Single symbol)

Interface type: GET

Interface URL: /api/data/v1/trades

Authentication: N

Request parameters:

Parameter name Required Type Description Default Value range
marketId true int Transfer market id or market name
marketName false string Transfer market id or market name
dataSize false int Data size, maximum is 20 0<=dataSize<=20

Example:

https://www.topliq.com/api/data/v1/trades?marketId=102&dataSize=2

Response:

{
    "datas": [
        [
            "T",          //Data type, Trade data
            "102",        //The market id
            "1569303302", //Timestamp
            "BTC_USDT",   //Symbol
            "ask",        //Trade direction, ask: selling, bit: buying
            "9745.08",    //price
            "0.0026"      //amount
        ],
        // more trade detail data here...
    ],
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

Interface description: Get Market Depth(Single symbol)

Interface type: GET

Interface URL: /api/data/v1/entrusts

Authentication: N

Request parameters:

Parameter name Required Type Description Default Value range
marketId true int Transfer market id or market name
marketName false string Transfer market id or market name
dataSize false int Data size,maximum is 50 0<=dataSize<=50

Example:

https://www.topliq.com/api/data/v1/entrusts?marketId=102&dataSize=2

Response:

{
    "datas":{
        "asks":[           //The selling.
            [
                "9740.43", //price
                "0.0083"   //amount
            ],
           //more market depth data here
        ],
        "bids":[           //The buying
            [
                "9734.33", //price
                "0.0133"   //amount
            ],
            //more market depth data here...
        ],
        "timestamp":"1569303520"  //timestamp
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Trade type information

Interface description: Get market list

Interface type: GET

Interface URL: /exchange/config/controller/website/marketcontroller/getByWebId

Authentication: N

Request parameters: none

Example:

https://www.topliq.com/exchange/config/controller/website/marketcontroller/getByWebId

Response:

{
    "datas": [
        {   "marketId":"102",          //The market id
            "name":"btc_usdt",         //Symbol
            "leverType":"1",           //Trade type, 1:sopt,2:margin
            "buyerCurrencyId":"11",    //Buyer's token id
            "sellerCurrencyId":"2",    //Seller's token id
            "amountDecimal":4,         //Quantity accuracy
            "priceDecimal":2,          //Price accuracy
            "minAmount":"0.0001000000",//Minimum placing order amount
            "state":1,                 //Status, -1: delete, 0: stop trading, 1: available, 2: pause
            "openTime":1556640000000,  //The open trading time
            "defaultFee":"0.00100000", //The default rate
            "isMining":0               //Mining or not, 0: no, 1: yes
        },
        //more market data here...
    ],
    "resMsg": {
        "message": "success !",
        "method": null,
        "code": "1"
    }
}

Interface description: Gets token list

Interface type: GET

Interface URL: /exchange/config/controller/website/currencycontroller/getCurrencyList

Authentication: N

Request parameters: none

Example:

https://www.topliq.com/exchange/config/controller/website/currencycontroller/getCurrencyList

Response:

{
    "datas": [
        {
            "currencyId":"2",            //Token ID
            "name":"btc",                //Token name
            "alias":"btc",               //Token alias
            "description":"比特币",       //Token description
            "defaultDecimal":2,          //Default accuracy
            "state":1,                   //Status, default value is 1, -1: delete, 0: disable, 1: enable
            "mark":"Bitcoin",            //note
            "isMemo":0,                  //Whether it is the account Memo type currency, 0: no, 1: yes
            "isMining": "0",             //Mining or not, 0: no, 1: yes
            "drawFee":"0.00100000",      //Withdrawal fee
            "onceDrawLimit":120,         //Maximum amount of single withdrawal
            "dailyDrawLimit":300,        //Maximum amount of token withdrawal in a day
            "createTime": 1567995134910, //create time
        },
        // more currency data here...
    ],
    "resMsg": {
        "message": "success !",
        "method": null,
        "code": "1"
    }
}

Account information

Interface description: Get all funding information

Interface type: POST

Interface URL: /exchange/fund/controller/website/fundcontroller/findbypage

Authentication: Y

Rate limit: 1 requests per 2 seconds

Request parameters:

Parameter name Required Type Description Default Value range
pageSize false int Number of lines per page
pageNum false int Page number

Note: if no parameter is passed in, {} is passed in as parameter and signed

Response:

{
    "datas":{
        "totalRow":6,
        "pageSize":99,
        "list":[
            {
                "amount":"0.000090000000000000", // The current number of tokens available
                "currencyTypeId":2,              // Token ID
                "freeze":"0.009900000000000000", // Current token freezing quantity
            },
            // more balance data here...
        ],
        "pageNum":1
    },
    "resMsg":{
        "code":"1",
        "message":"success !"
    }
}

Trading

Interface description: Place order

Interface type: POST

Interface URL: /exchange/entrust/controller/website/EntrustController/addEntrust

Authentication: Y

Rate limit: 4 requests per 2 seconds

Request parameters:

Parameter name Required Type Description Default Value range
amount true int Order quantity
type true int Buying or selling direction 0:sell,1:buy
rangeType true int Commission type 0: limit price commission 1: interval commission, currently only supports limit price commission
marketId true string The market id
price true int Order price

The ordering interface of TopQ is asynchronous ordering interface. If the ordering is successful, please call the order status inquiry interface for final confirmation.

Response:

{
    "datas":{
        "entrustId":"E6581105708337483776"   // Order id
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Cancel order

Interface type: POST

Interface URL: /exchange/entrust/controller/website/EntrustController/cancelEntrust

Authentication: Y

Rate limit: 4 requests per 2 seconds

Request parameters:

Parameter name Required Type Description Default Value range
entrustId true int Order id
marketId true string The market id

The cancelOrder interface of TopQ is asynchronous. If cancelOrder is successful, please call the order status inquiry interface for final confirmation.

Response:

{
    "datas":null,
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Get order details

Interface type: GET

Interface URL: /exchange/entrust/controller/website/EntrustController/getEntrustById

Authentication: Y

Rate limit: 6 requests per 2 seconds

Example:

https://www.topliq.com/exchange/entrust/controller/website/EntrustController/getEntrustById?entrustId=E6581108027628212224&marketId=318

Request parameters:

Parameter name Required Type Description Default Value range
marketId true string The market id
entrustId true string Order id

Response:

      
{
    "datas":{
        "entrustId":"E6581108027628212224", //Order id
        "price":"1450",                     //price
        "rangeType":0,                      //Commission type 0: limit price commission 1: interval commission
        "amount":"14.05",                   //Order quantity
        "totalMoney":"20372.50",            //Total order amount
        "completeAmount":"0",               //Quantity sold
        "completeTotalMoney":"0",           //Total dealt amount
        "type":1,                           //Trade direction, 0: sell, 1: buy, -1: cancel
        "entrustType":0,                    //Commission type, 0: ordinary current price commission, 1: lever commission
        "status":0,                         //Order status,-3:fund Freeze exception,Order status to be confirmed  -2: fund freeze failure, order failure, -1: insufficient funds, order failure, 0: pending order, 1: cancelled, 2: dealt, 3: partially dealt
        "marketId":"318",                   //The market id
        "createTime":1569058424861,         //Create time
       "availabelAmount":"14.05"            //Outstanding quantity
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Check current outstanding orders

Interface type: GET

Interface URL: /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCacheWithPage

Authentication: Y

Rate limit: 4 requests per 2 seconds

Example:

https://www.topliq.com/exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCacheWithPage?marketId=318&pageIndex=1&pageSize=10

Request parameters:

Parameter name Required Type Description Default Value range
marketId true string The market id
pageSize true int Number of lines per page
pageIndex true int Page number

Response:

{
    "datas":{
        "entrustList":[
            {
                "entrustId":"E6581108027628212224", //Order id
                "price":"1450",                     //Order price
                "rangeType":0,                      //Commission type,0: limit price commission 1: interval commission
                "amount":"14.05",                   //Order quantity
                "totalMoney":"20372.50",            //Total order amount
                "completeAmount":"0",               //Quantity sold

                "completeTotalMoney":"0",           //Total dealt amount
                "type":1,                           //Trade direction, 0: sell, 1: buy, -1: cancel
                "entrustType":0,                    //Commission type, 0: ordinary current price commission, 1: lever commission
                "status":0,                         //Order status,-3:fund Freeze exception,Order status to be confirmed  -2: fund freeze failure, order failure, -1: insufficient funds, order failure, 0: pending order, 1: cancelled, 2: dealt, 3: partially dealt 
                "marketId":"318",                   //The market id
                "createTime":1569058424861,         //Create time
                "availabelAmount":"14.05"           //Outstanding quantity
            }
        ],
        "totalRow":1,                               //Total number of rows
        "pageNum":1,                                //Page number
        "pageSize":10,                              //Number of lines per page
        "totalPage":1                               //Total number of pages
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Search for history commission

Interface type: GET

Interface URL: /exchange/entrust/controller/website/EntrustController/getUserEntrustList

Authentication: Y

Rate limit: 4 requests per 2 seconds

Example:

https://www.topliq.com/exchange/entrust/controller/website/EntrustController/getUserEntrustList?marketId=318

Request parameters:

Parameter name Required Type Description Default Value range
marketId true string The market id
pageIndex true int Page number
pageSize true int Number of lines per page
type false int Commission type 0: sell, 1: buy, -1: cancel
status false int Order status -1: insufficient funds, order failure, 0: pending order, 1: cancelled, 2: dealt, 3: partially dealt
startDateTime false Timestamp End time of commission order, 13 bit timestamp
endDateTime false Timestamp End time of commission order, 13 bit timestamp

Response:

{
    "datas":{
        "pageNum":1,
        "pageSize":2,
        "totalPage":20,
        "totalRow":40,
        "entrustList":[
            {
                "amount":"14.050000000000000000",       //Order quantity
                "rangeType":0,                          //Commission type 0: limit price commission 1: interval commission
                "totalMoney":"20372.500000000000000000",//Total order amount
                "entrustId":"E6581108027628212224",     //Order id
                "type":1,                               //Trade direction, 0: sell, 1: buy, -1: cancel
                "completeAmount":"0",                   //Quantity sold

                "marketId":"318",                       //The market id
                "createTime":1569058424861,             //Create time
                "price":"1450.000000000",               //price
                "completeTotalMoney":"0",               //Quantity sold
                "entrustType":0,                        //Commission type, 0: ordinary current price commission, 1: lever commission
                "status":0                              //Order status,-3:fund Freeze exception,Order status to be confirmed  -2: fund freeze failure, order failure, -1: insufficient funds, order failure, 0: pending order, 1: cancelled, 2: dealt, 3: partially dealt 
            },
            //more data item here...
        ]
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Deposit and withdrawal

Interface description: Get the deposit address

Interface type: GET

Interface URL: /exchange/fund/controller/website/fundcontroller/getPayinAddress

Authentication: Y

Request parameters:

Parameter name Required Type Description Default Value range
currencyTypeName true string Token name

Response:

Memo format, such as EOS
{
    "datas":{
        "isMemo":true,                                // Memo format false: no, true: yes
        "address":"eosdeposit_787928102918558272",  // Deposit address
        "memo":"787928102918558272",                  // Token memo
        "account":"eosdeposit"                      // Token account
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}
Non-memo format, such as: BTC

{
    "datas":{
        "isMemo":false,                                 // Memo format false: no, true: yes
        "address":"1Atxn1snU7kdPYUskdsTQ14tsZxNdLbwtq"  // Deposit address
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Search for deposit records

Interface type: GET

Interface URL: /exchange/fund/controller/website/fundcontroller/getPayinCoinRecord

Authentication: Y

Request parameters:

Parameter name Required Type Description Default Value range
currencyTypeName true string Token name
sort false int Whether sorting 1: ascending sorting
pageNum true string Page number
pageSize true string Number of lines per page

Response:

{
    "datas":{
        "totalRow":2,
        "totalPage":1,
        "pageSize":2,
        "pageNum":1,
        "list":[
            {
                "depositId":"D6574268549744189441",                  // Deposit ID
                "amount":"54.753589700000000000",                    // Deposit amount
                "txId":"INNER_SYSTEM_TRANSFER_1198941",              // Trading ID
                "confirmTimes":0,                                    // Confirmation number
                "depositAddress":"eosdeposit_787928102918558272",  // Deposit address
                "createTime":"2019-09-02 20:36:08.0",                // Deposit time
                "status":1,                                          // Deposit status, 0: not received, 1: received
                "currencyTypeId":7                                   // Token ID
            },
            // more data here...
        ]
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Search for withdrawal address

Interface type: GET

Interface URL: /exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress

Authentication: Y

Example:

https://www.topliq.com/exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress?currencyId=7&pageIndex=1&pageSize=2

Request parameters:

Parameter name Required Type Description Default Value range
currencyId true string Token ID
pageIndex true string Page number
pageSize true string Number of lines per page

Response:

{
    "datas":{
        "totalRow":1,
        "totalPage":1,
        "pageSize":2,
        "pageNum":1,
        "list":[
            {
                "currencyId":"7",                // Token ID
                "type":1,                        // Address type: 1: withdrawal address; 2: deposit address
                "address":"okbtothemoon_941657", // withdrawal target address
                "status":"1",                    // Status, 1: normal, -1: delete
                "createTime":1556276874509,      // Create time
                "remark":"okex_eos",             // Address note
                "currencyName":"eos"             // Withdrawal token
            }
        ]
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}

Interface description: Search for withdrawal record

Interface type: GET

Interface URL: /exchange/fund/controller/website/fundwebsitecontroller/getpayoutcoinrecord

Authentication: Y

Example:

https://www.topliq.com/exchange/fund/controller/website/fundwebsitecontroller/getpayoutcoinrecord?currencyId=7&pageIndex=1&pageSize=2&tab=all

Request parameters:

Parameter name Required Type Description Default Value range
currencyId true string Token ID
tab true string Withdrawal status All: all, wait: submitted, not audited, success: auditing passed, fail: auditing failed, cancel: the user takes the initiative to cancel
pageIndex true string Page number
pageSize true string Number of lines per page

Response:

{
    "datas":{
        "totalRow":1,
        "totalPage":1,
        "pageSize":2,
        "pageNum":1,
        "list":[
            {
                "withdrawalId":"W6527498439872634880",      // Withdrawal ID
                "fees":"0.500000000000000000",              // Withdrawal fee
                "withdrawalAddress":"okbtothemoon_941657",  // Withdrawal address 
                "currencyId":"7",                           // Token ID
                "amount":"10.000000000000000000",           // Withdrawal amount
                "state":1,                                  // Status, 1: normal, -1: delete
                "verifyStatus":1,                           // Audit status, 0: to be audited, 1: auditing passed, -1: auditing failed
                "createTime":1556276903656,                 // WIthdrawal time 
                "actuallyAmount":"9.500000000000000000"     // Actual amount received
            }
        ]
    },
    "resMsg":{
        "message":"success !",
        "method":null,
        "code":"1"
    }
}
Clone this wiki locally