- Register an account by email on https://dex.top
- Bind the trader address on the account page.
- Deposit eth or tokens on the balance page.
- You can use https://testnet271828.dex.top for test which base on Kovan testnet, You can go to Gitter ask for test tokens
- APIs rate limit is 100/sec per ip or account
Note
API rate limit per IP address is 100/second, and per user is 600/minute.
Place a new order.
Request POST /v1/placeorder
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
Params
traderAddrTrader addresspairIdId of the trading token pairamountAmount of token to buy or sellpriceOrder priceaction"Buy" or "Sell"nonceOrder nonce. Recommended value is the current timestamp in millisecondexpireTimeSecOrder expire time (timestamp in second)sigSignature of signing the order with the private key of the trader address, see API Introduction for details.
Sample Request
{
"amount": "66.51501244",
"price": "0.00150342",
"action": "Buy",
"nonce": 1522290645732,
"expireTimeSec": 1522377045,
"sig": "0x3d42c49bebfc912d5b6698556db273e9e38b72928b052eccd967a4bb4d31cb007b363a1a30d45ee5055b64a8a7d8bac7fc1d4d2f3009d910b856467699a58b4f00",
"pairId": "ETH_ADX"
}Sample Response
{
"order": {
"orderId": "10000004",
"pairId": "ETH_ADX",
"action": "Buy",
"price": "0.01000000",
"amountTotal": "10.00000000",
"amountFilled": "0.00000000",
"filledAveragePrice": "0.00000000",
"status": "Unfilled", // "Filled" or "Unfilled" or "PartiallyFilled" or "Cancelled" or "Expired"
"createTimeMs": "1522554774421",
"updateTimeMs": "1522554774421",
"expireTimeSec": "1522641169",
"nonce": "1522554769144"
}
}-
Full data samples of order signing, including the used private keys, can be found at here.
-
Signing Scheme 1 (Friendly to API usage)
The bytes to be hashed (using keccak256) for signing are the concatenation of the following (uints are in big-endian order):
-
Prefix
"\x19Ethereum Signed Message:\n70". -
String
"DEx2 Order: "(Note the trailing whitespace) -
The
market address.This is for replay attack protection when we deploy a new market.
-
nonce(64) -
expireTimeSec(64) amountE8(64) priceE8(64) 0x00(8) action(8) pairId(32)
-
Cancel an existing order.
Request POST /v1/cancelorder
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
traderAddrTrader addressorderIdThe order id you want to cancelpairIdThe id of the trading token pairnonceOrder nonce. The recommended value is the current timestamp in millisecond.
Sample Request
{
"orderId":"10000004",
"pairId":"ETH_ADX",
"nonce":1522554949196, // nonce use timestamp in millisecond
}Sample response
{}Cancel all existing orders using given parameters.
Request POST /v1/cancelallorders
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
traderAddrTrader addresspairIdThe id of the trading token pairnonceOrder nonce. The recommended value is the current timestamp in millisecond.
Sample Request
{
"pairId":"ETH_ADX",
"nonce":1522554949196, // nonce use timestamp in millisecond
}Sample response
{
cancelledOrderIds: [1000373, 1000374] // ids of all cancelled orders
}Withdraw a token with the specified amount.
Request POST /v1/withdraw
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
required params
tokenId: Withdraw token idamount: Withdraw Amount
Sample Request
{
"tokenId":"ETH",
"amount":"0.1",
}Sample response
{}Get relevant market information such as market contract address and token codes for signature.
Request GET /v1/market
Sample Request
http://dex.top/v1/marketSample Response
{
"marketAddr": "0x91952Ce7d434E84E8932AAB0F8A3f2E6A72F89a1", // Market Address for signature and deposit
"label": "NoneLabel",
"config": {
"makerFeeRateE4": "0",
"takerFeeRateE4": "0",
"withdrawFeeRateE4": "0",
"cashTokens": [
{
"tokenId": "ETH",
"tokenCode": 0, // Cash Token Code for signature
"tokenAddr": "",
"scaleFactor": "1000000000000000000"
}
],
"stockTokens": [
{
"tokenId": "BTM",
"tokenCode": 300, // Stock Token Code for signature
"tokenAddr": "0x45ddA1360019D2D26Bfa482A629a03f31A3a1A37",
"scaleFactor": "1000"
},
{
"tokenId": "OMG",
"tokenCode": 400,
"tokenAddr": "0x693f7fD5A8153A56bEc70189a1ae1943E07Be495",
"scaleFactor": "1000"
}
]
},
"networkName": ""
}Get the real-time trading information of all available trading pairs of the specified cash token (e.g. "ETH").
Request GET /v1/pairlist/:cashTokenId
cashTokenIdThe basic cash token like ETH
Sample Request
http://dex.top/v1/pairlist/ETHSample Response
{
"pairs":[
{
"pairId": "ETH_ADX", // request trade pair's Id
"timeMs": "1517975573850", // response timestamp
"lastPrice": "5.095449", // price of timeMs
"volume24": "414.056370", // total volume of this pair in 24 hours
"amount24": "2340.81387265", // total token amount in 24 hours
"change24": "4.421090", // price change of this pair in 24 hours
"changePercent24": "", // price change rate of this pair in 24 hours
"high24": "9.612255", // highest price of this pair in last 24 hours
"low24": "3.170465" // lowest price of this pair in 24 hours
}
],
}Get the real-time information of a trading pair.
Request GET /v1/pairinfo/:pairId
pairIdOrder trade pair
Sample Request
http://dex.top/v1/pairinfo/ETH_ADXSample Response
{
"pairInfo": {
"pairId": "ETH_ADX",
"timeMs": "1517974573647",
"lastPrice": "5.813280",
"volume24": "402.666631",
"amount24": "2340.81387265",
"change24": "4.497973",
"changePercent24": "",
"high24": "7.978321",
"low24": "3.491216"
}
}Get recent trades by pairId sort by trade time.
Request GET /v1/tradehistory/:pairId/:size
pairIdThe id of the trading token pair.sizeThe number of levels of history to get.
Sample Request
http://dex.top/v1/tradehistory/ETH_ADX/3Sample Response
{
"records": [
{
"pairId": "ETH_ADX",
"timeMs": "1522208665707", // The timestamp in millisecond of this trade.
"action": "Buy",
"price": "0.00010000",
"amount": "934.00000000"
},
{
"pairId": "ETH_ADX",
"timeMs": "1522208545271",
"action": "Buy",
"price": "0.00010000",
"amount": "66.00000000"
},
{
"pairId": "ETH_ADX",
"timeMs": "1522208486796",
"action": "Buy",
"price": "0.00010000",
"amount": "1000.00000000"
}
]
}Get the depth data of a trading pair.
Request GET /v1/depth/:pairId/:size
pairIdThe id of the trading token pair.sizeThe number of levels of depth to get.
Sample Request
http://dex.top/v1/depth/ETH_ADX/5Sample Response:
{
"depth": {
"pairId": "ETH_ADX",
"timeMs": "1513244690782", // The timestamp in millisecond of this depth data.
// `asks` are ascending by price.
"asks": [
{
"price": "0.00157384",
"amount": "66.00000000"
},
{
"price": "0.00159438",
"amount": "80.00000000"
},
{
"price": "0.00163499",
"amount": "100.00000000"
},
{
"price": "0.00168030",
"amount": "666.00000000"
},
{
"price": "0.00175212",
"amount": "800.00000000"
}
],
// `bids` are descending by price.
"bids": [
{
"price": "0.00155000",
"amount": "665.00000000"
},
{
"price": "0.00151903",
"amount": "66.00000000"
},
{
"price": "0.00150021",
"amount": "1000.00000000"
},
{
"price": "0.00144436",
"amount": "78.00000000"
},
"price": "0.00140912",
"amount": "753.35833123"
}
]
}
}Get unfilled or partially filled orders that have not been cancelled or expired of a trader.
Request GET /v1/activeorders/:addr/:pairId/:size/:page
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
pairIdThe id of the trading token pair.sizeThe number of each page of user active orders to get.pageThe pages number to getaddrTrader eth address
Sample Request
http://dex.top/v1/activeorders/0x6a83D834951F29924559B8146D11a70EaB8E328b/ETH_ADX/100/1Sample response
{
"orders": [
{
"orderId": "10126257",
"pairId": "ETH_ADX",
"action": "Buy",
"price": "0.00010000",
"amountTotal": "500.00000000",
"amountFilled": "0.00000000",
"filledAveragePrice": "0.00000000",
"status": "Unfilled", // "Filled" or "Unfilled" or "PartiallyFilled" or "Cancelled" or "Expired"
"createTimeMs": "1528790525164",
"updateTimeMs": "1528790525164",
"expireTimeSec": "1529395319",
"nonce": "1528790519061"
}
],
"page": 1,
"total": 1
}Get past orders on current wallet address.
Request GET /v1/pastorders/:addr/:pairId/:size/:page?from_time_sec=&to_time_sec=
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
pairIdThe id of the trading token pair.sizeThe number of each page of user past orders to get.pageThe pages number to getaddrTrader eth address
-
optional params
from_time_secTimestamp in sec to get past orders from INCLUSIVEto_time_secTimestamp in sec to get past orders until INCLUSIVE
Sample Request
http://dex.top/v1/pastorders/0x6a83D834951F29924559B8146D11a70EaB8E328b/ETH_ADX/100/1?from_time_sec=1498793709&to_time_sec=1498794709Sample response
{
"orders": [
{
"orderId": "10000470",
"pairId": "ETH_ADX",
"action": "Buy",
"price": "0.00004100",
"amountTotal": "1500.00000000",
"amountFilled": "1500.00000000",
"filledAveragePrice": "0.00003924",
"status": "Filled",
"createTimeMs": "1528112182218",
"updateTimeMs": "1528112182218",
"expireTimeSec": "1528716977",
"nonce": "1528112177402"
}
],
"page": 1,
"total": 1
}Get the details of an order by order id.
Request GET /v1/orderbyid/:traderAddr/:orderId
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
traderAddrTrader eth addressorderIdThe id of the order.
Sample Request
http://dex.top/v1/orderbyid/0x6a83D834951F29924559B8146D11a70EaB8E328b/10000005Sample response
{
"order": {
"orderId": "10000005",
"pairId": "ETH_ADX",
"action": "Sell",
"price": "0.00165000",
"amountTotal": "200.00000000",
"amountFilled": "200.00000000",
"filledAveragePrice": "0.00165000",
"status": "Filled",
"createTimeMs": "1524809137398",
"updateTimeMs": "1524809653759",
"expireTimeSec": "1525413935",
"nonce": "1524809135488"
}
}Request GET /v1/kline/history?symbol={pairID}&resolution={resolution}&from={startTimeStamp}&to={endTimeStamp}
- params
pairIdThe id of the trading token pair.resolutionduration for each bar, only support5,15,30,60,D,W.startTimeStampthe start time of history data.endTimeStampthe end time of history data.
Sample Request
http://dex.top/v1/kline/history?symbol=ETH_YEE&resolution=60&from=1527807437&to=1527843437Sample response
{
s: "ok",
errmsg: "",
// Timestamp
t: [
"1527825600",
"1527829200",
"1527832800",
"1527836400",
"1527840000"
],
// Close
c: [
0.00004501,
0.00004324,
0.00004311,
0.0000437,
0.00004211
],
// Open
o: [
0.00004392,
0.00004501,
0.00004324,
0.00004311,
0.0000437
],
// High
h: [
0.00004504,
0.00004401,
0.00004376,
0.0000437,
0.0000431
],
// Low
l: [
0.00004392,
0.00004324,
0.00004311,
0.0000437,
0.00004211
],
// Volume
v: [
0.9682618499999999,
73.98493420589,
3.018485526814107,
0.0809761,
143.76744365959996
]
}Get recent trades on current wallet address.
Request GET /v1/trades/:addr/:pairId/:size
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
pairIdThe id of the trading token pair.sizeThe number of recent trades to get.addrTrader eth address
Sample Request
http://dex.top/v1/trades/0x6a83D834951F29924559B8146D11a70EaB8E328b/ETH_ADX/2Sample response
{
"trades": [
{
"pairId": "ETH_ADX",
"timeMs": "1525231321804",
"orderId": "10000776",
"isBuyer": true,
"isMaker": false,
"price": "0.00156080",
"amount": "163.06101648",
"fee": "0.32612203"
},
{
"pairId": "ETH_ADX",
"timeMs": "1525231321804",
"orderId": "10000776",
"isBuyer": true,
"isMaker": false,
"price": "0.00155810",
"amount": "242.11581591",
"fee": "0.48423163"
}
]
}API used to login to exchange.
Request POST /v1/authenticate
Sample Request
{
"email": 'flynn@dex.top',
"password": '**********',
"durationSec": 86400 // The default value is 259200, i.e. 3 days. The maximum is 30 days.
}Response:
{
"token": 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdGRDbGFpbXMiOnsiYXVkIjoiREV4IFNlcnZlcnMiLCJleHAiOjE1MjEyNjU3MTcsImp0aSI6ImEwY2VmNGQ0LTBmNWQtNDVmMS05MzYwLTkwOGQ0MmY1ZWMzYiIsImlhdCI6MTUyMTAwNjUxNywiaXNzIjoiREV4Iiwic3ViIjoiMiJ9fQ.r0kwUhMh8pZCGazZt0Lp4gPl1JEOdQIGyXlNpi5zHQ90NloUXNuEhlSRvSrTu5rug6nhkO_cbvIGc2okeC9zLQ',
"user": {
},
}Get the balances of all tokens of a trader.
Request GET /v1/balances/:traderAddr
-
HTTP Request Header
Authorization: Bearer <token>Token obtained when signing in.
-
params
traderAddrTrader address
Sample Request
http://dex.top/v1/balances
Sample Response
{
"balances": [
{
"tokenId": "ADX", // TokenId
"total": "0", // Token total amount
"active": "0", // Token amount can withdraw
"locked": "0", // Token amount is locked at this moment
"withdrawing": "0"
},
{
"tokenId": "EOS",
"total": "0",
"active": "0",
"locked": "0",
"withdrawing": "0"
},
{
"tokenId": "ETH",
"total": "1.00000000",
"active": "0.99790000",
"locked": "0.00210000",
"withdrawing": "0"
}
],
"estimatedValue": "" // Account total estimate value
}