Skip to content

rest api_CN

leolianger edited this page Mar 16, 2020 · 18 revisions

接口列表

接口数据类型 请求方法 类型 描述 需要验签
交易品种信息 GET /symbols GET 交易对的计价货币和报价精度 N
交易品种信息 GET /currencies GET 交易币种列表 N
市场行情 GET /tickers GET 全部symbol或单个symbol的24小时的价格变化 N
市场行情 GET /depth GET 单个symbol的市场深度行情 N
市场行情 GET /klines GET 单个symbol的K线 N
市场行情 GET /trades GET 单个symbol的成交记录 N
账户信息 GET /balance/ GET 查询用户的账户状态 Y
用户订单信息 GET /orders/all GET 获取用户单个或者所有symbol的open和closed订单 N
用户订单信息 GET /orders/open GET 获取用户单个或者所有symbol的open订单 N
用户订单信息 GET /orders/closed GET 获取用户单个或者所有symbol的closed订单 N
用户订单信息 GET /orders/{id} GET 根据orderid查询订单详情 N
用户订单信息 GET /orders/trades GET 获取用户的历史成交详情 N
充提币及转币信息 GET /depositaddress GET 获取充值地址 N
充提币及转币信息 GET /withdrawals GET 查询提币信息 N
充提币及转币信息 GET /deposits GET 查询充币信息 N
充提币及转币信息 GET /transfers GET 查询转账记录 N
交易 POST /transaction/createorder POST 创建订单 Y
交易 POST /transaction/cancelorder POST 取消订单 Y
提币 POST /transaction/withdraw POST 申请提币 Y
转账 POST /transaction/transfer POST 申请转账 Y

访问地址

其它说明

ByteTrade去中心化交易所已通过CCXT认证,可以使用CCXT的接口在ByteTrade进行查询和交易。在初始化CCXT的ByteTrade实例时,传入的apiKey参数为用户在ByteTrade的用户名,secret参数为用户的私钥。

GET /symbols 查询所有交易对及精度

请求参数: (无)

响应数据:

symbol list

请求响应例子:

[
    {
      "symbol": "68719476706",     // market symbol, unique,在其它接口中,如果需要使用symbol标明market,请使用这个symbol
      "name": "ETH/BTC",     // market symbol name, unique
      "base": "2",             // base coin currency
      "quote": "32",           // quote coin currency
      "baseName": "ETH",     // base coin code
      "quoteName": "BTC",    // quote coin code
      "active": true,
      "maker": "0.0008",     // maker fee
      "taker": "0.0008",     // taker fee
      "precision": {         // number of decimal digits "after the dot"
        "amount": 8,        // 交易时,amount的精度,代表小数点后的最大位数
        "price": 10           // 交易时,price的精度,代表小数点后的最大位数
      },
      "limits": {
        "amount": {
          "min": "0.00000001", // 交易时,amount的最小值
          "max": "-1"            // 当值为-1时,代表没有上限
        },
        "price": {
          "min": "0.0000000001",   // 交易时,price的最小值
          "max": "-1"            // 当值为-1时,代表没有上限
        }
      }
    }
]

其它说明

  1. 订单创建,订单创建,账户间转账,每次收取0.0003个BTT作为手续费用;
  2. 订单被撮合后,交易手续费费率如上述接口所述,为0.08%.

GET /currencies 查询所有币种

请求参数:

(无)

响应数据:

currency list
[
      {
        "code": "32",       // currency id, unique,在其它接口中,如果需要使用currency信息,请使用这个id
        "name": "BTC",      // currency name, unique
        "type": "crypto",
        "fullname": "Bitcoin",
        "active": true,
        "basePrecision": 18,      // 在ByteTrade链上,1个BTC将表示为1000000000000000000的整数
        "transferPrecision": 10,  // 在ByteTrade链上,转账最小值为0.0000000001
        "externalPrecision": 8,   // 在BTC的链上,最小单位为0.00000001
        "fee":"53004",            // withdraw fee, only valid for BTC
        "chainType":"bitcoin",   
        "chainContractAddress": "",
        "limits": {
            "deposit": {
              "min": "0.001",    // pixiu 系统支持的最小充值数量,需要再确认下接口
              "max": "-1"        // 当值为-1时,代表没有上限
             },
            "withdraw": {
              "min": "0.01",     // pixiu 系统支持的最小充值数量,需要再确认下接口
              "max": "-1"        // 当值为-1时,代表没有上限
            }
        }
      }
]

GET /tickers 查询全部symbol或单个symbol的24小时的价格变化

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
symbol false string 交易对symbol 68719476706, 4294967297, ...

响应数据:

ticker list

请求响应例子:

[
      {
        "symbol": "68719476706",                 // unique id, unique
        "name": "ETH/BTC",                       // string symbol of the market, unique
        "base": "2",                             // base coin id
        "quote": "32",                           // quote coin id
        "timestamp": 1559124034283,              // int (64-bit Unix Timestamp in milliseconds since Epoch 1 Jan 1970)
        "datetime": "2019-05-29T10:00:34.283Z",  // ISO8601 datetime string with milliseconds
        "high": "0.031526",                        // highest price
        "low": "0.030771",                         // lowest price
        "open": "0.031009",                        // opening price
        "close": "0.031035",                       // price of last trade (closing price for current period)
        "last": "0.031035",                        // same as `close`, duplicated for convenience
        "change": "2.6e-05",                       // absolute change, `last - open`
        "percentage": "0.084",                     // relative change, `(change/open) * 100`
        "baseVolume": "209771.771",                // volume of base currency traded for last 24 hours
        "quoteVolume": "6519.97393184"             // volume of quote currency traded for last 24 hours
      }
]

GET /depth 查询单个symbol的市场深度行情

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对symbol 68719476706, 4294967297, ...
limit false int asks或bids个数 [1,100]
type false string 深度的价格聚合度,step0时无聚合,step1\2\3\4\5分别代表聚合度为报价精度*10\100\1000\10000\100000 step0 step0,step1,step2,step3,step4,step5

响应数据:

depth dict

请求响应例子:

{
      "bids": [
        [
          "0.031138",   // price
          "0.05"        // amount
        ],
        [
          "0.031137",
          "1.94"
        ],
        [
          "0.031136",
          "0.236"
        ]
       ],
      "asks": [
        [
          "0.031147",
          "14.237"
        ],
        [
          "0.031149",
          "0.033"
        ],
        [
          "0.03115",
          "0.417"
        ],
        [
          "0.031151",
          "0.755"
        ],
    "timestamp": 1559549045008,
    "datetime": "2019-06-03T08:04:05.008Z"
}

GET /klines 查询单个symbol的K线

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对symbol 68719476706, 4294967297, ...
timeframe true string K线类型 1m, 5m,15m,30m,1h,4h,1d,5d,1w,1M
since false int K线开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个kline
limit false int K线数据个数 100 [1,500]

响应数据:

kline list

请求响应例子:

[
    [
      1559574540000,      // UTC timestamp in milliseconds, integer
      "0.030753",         // (O)pen price, String
      "0.030778",         // (H)ighest price
      "0.030752",         // (L)owest price
      "0.030778",         // (C)losing price
      "30.716"            // (V)olume (in terms of the base currency)
    ],
    [
      1559574600000,
      "0.030778",
      "0.030789",
      "0.030775",
      "0.030775",
      "86.1294"
    ]
]

GET /trades 获取单个symbol的成交记录

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
symbol true string 交易对symbol 68719476706, 4294967297, ...
since false int 获取trade开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个trade
limit false int trades数据个数 100 [1,500]

响应数据:

trade list

请求响应例子:

[
    {
      "id": "6863a873ed87443bfc8bd759451d5c9ec4a2dafc",        // string trade id
      "txid":"909108605661dfd3e6d85ae2a9faceb524dce733",       // transaction id in bytetrade
      "order": "e0bfe265bab9ac017a867eceff9f5b3464053972",     // sring order id
      "timestamp": 1559633809458,               // Unix timestamp in milliseconds
      "datetime": "2019-06-04T07:36:49.458Z",   // ISO8601 datetime with milliseconds
      "symbol": "68719476706",                    // symbol
      "name": "ETH/BTC",                        // symbol name
      "side": "buy",                            // direction of the trade, "buy" or "sell"
      "price": "0.031118",                      // price in quote currency
      "amount": "0.2379",                       // amount of base currency
      "cost": "0.0074029722"                    // amount of quote currency
    }
]

GET /balance 获取用户的balance

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, ...

响应数据:

balance list

请求响应例子:

[
    {
      "code": "32",                              // string coin id
      "name": "BTC",                           // string coin name
      "free": "0.23",                          // money available for trading
      "used": "0.03",                          // money on hold, locked, frozen or pending
      "total": "0.26"                          // total balance (free + used)
    }
]

GET /orders/all 获取用户单个或者所有symbol的open和closed订单

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
symbol false string 交易对symbol 68719476706, 4294967297, ...
since false int 获取order的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个order
limit false int order数据个数 100 [1,100]

响应数据:

order list
[
    {
        "id":                "12345-67890:09876/54321", // string
        "txid":              "42d225b12d97441e709c741e1f99b377ec3a3822"   // tx_id in bytetrade
        "datetime":          "2017-08-17 12:42:48.000", // ISO8601 datetime of "timestamp" with milliseconds
        "timestamp":          1502962946216, // order placing/opening Unix timestamp in milliseconds
        "lastTradeTimestamp": 1502962956216, // Unix timestamp of the most recent trade on this order
        "status":     "open",         // "open"
        "symbol":     "68719476706",  // symbol Id
        "name":       "ETH/BTC",      // symbol name
        "type":       "limit",        // "market", "limit"
        "side":       "buy",          // "buy", "sell"
        "price":       "0.029",       // float price in quote currency
        "average":     "0",
        "amount":      "0.000294",    // ordered amount of base currency
        "filled":      "0",           // filled amount of base currency
        "remaining":   "0.000294",    // remaining amount to fill
        "cost":       "0",            // "filled" * "price" (filling price used where available)
        "fee": {                      // fee info, if available
            "code": "32",             // which currency the fee is (usually quote)
            "name": "BTC",
            "cost": "0",             // the fee amount in that currency
            "rate": "0",             // the fee rate (if available)
        }
]

GET /orders/open 获取用户单个或者所有symbol的open订单

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
symbol false string 交易对symbol 68719476706, 4294967297, ...
since false int 获取openorder的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个openorder
limit false int openorder数据个数 100 [1,100]

响应数据:

open order list
[
    {
        "id":                "12345-67890:09876/54321", // string
        "txid":              "42d225b12d97441e709c741e1f99b377ec3a3822"   // tx_id in bytetrade
        "datetime":          "2017-08-17 12:42:48.000", // ISO8601 datetime of "timestamp" with milliseconds
        "timestamp":          1502962946216, // order placing/opening Unix timestamp in milliseconds
        "lastTradeTimestamp": 1502962956216, // Unix timestamp of the most recent trade on this order
        "status":     "open",         // "open"
        "symbol":     "68719476706",  // symbol Id
        "name":       "ETH/BTC",      // symbol name
        "type":       "limit",        // "market", "limit"
        "side":       "buy",          // "buy", "sell"
        "price":       "0.029",       // float price in quote currency
        "average":     "0",
        "amount":      "0.000294",    // ordered amount of base currency
        "filled":      "0",           // filled amount of base currency
        "remaining":   "0.000294",    // remaining amount to fill
        "cost":       "0",            // "filled" * "price" (filling price used where available)
        "fee": {                      // fee info, if available
            "code": "32",             // which currency the fee is (usually quote)
            "name": "BTC",
            "cost": "0",             // the fee amount in that currency
            "rate": "0",             // the fee rate (if available)
        }
]

GET /orders/closed 获取用户单个或者所有symbol的closed订单

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
symbol false string 交易对symbol 68719476706, 4294967297, ...
since false int 获取closedorder的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个closedorder
limit false int closedorder数据个数 100 [1,100]

响应数据:

closed order list

请求响应例子:

[
    {
        "id":                "a7922889b77005bae42b48cd15db3849a1e89d4b", // string
        "txid":              "42d225b12d97441e709c741e1f99b377ec3a3822",   // tx_id in bytetrade
        "datetime":          "2017-08-17 12:42:48.000", // ISO8601 datetime of "timestamp" with milliseconds
        "timestamp":          1502962946216, // order placing/opening Unix timestamp in milliseconds
        "lastTradeTimestamp": 1502962956216, // Unix timestamp of the most recent trade on this order
        "status":     "closed",             // "closed"
        "symbol":     "68719476706",          // symbol Id
        "name":       "ETH/BTC",            // symbol name
        "type":       "limit",              // "market", "limit"
        "side":       "buy",                // "buy", "sell"
        "price":       "0.03413801",        // float price in quote currency
        "average":     "0.03413801",        // money/filled
        "amount":      "0.001",             // ordered amount of base currency
        "filled":      "0.001",             // filled amount of base currency
        "remaining":   "0",                 // remaining amount to fill
        "cost":       "0.000034138432",     // "filled" * "price" (filling price used where available)
        "fee": {                            // fee info, if available
            "code": "32",                     // which currency the fee is (usually quote)
            "name": "BTC",
            "cost": "0",                    // the fee amount in that currency
            "rate": "0",                    // the fee rate (if available)
        }
    }
]

GET /orders/{id} 获取指定id的订单详情

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
orderid true string 订单id a7922889b77005bae42b48cd15db3849a1e89d4b, , ...

响应数据:

order info dict

请求响应例子:

{
    "id":                "a7922889b77005bae42b48cd15db3849a1e89d4b", // string
    "txid":              "909108605661dfd3e6d85ae2a9faceb524dce733",   // tx_id in bytetrade
    "datetime":          "2017-08-17 12:42:48.000", // ISO8601 datetime of "timestamp" with milliseconds
    "timestamp":          1502962946216, // order placing/opening Unix timestamp in milliseconds
    "lastTradeTimestamp": 1502962956216, // Unix timestamp of the most recent trade on this order
    "status":     "closed",             // "open", "closed",  如果一个订单没有成交,而就被取消掉,通过此接口不会查询到 
    "symbol":     "68719476706",          // symbol Id
    "name":       "ETH/BTC",            // symbol name
    "type":       "limit",              // "market", "limit"
    "side":       "buy",                // "buy", "sell"
    "price":       "0.03413801",        // float price in quote currency
    "amount":      "0.001",             // ordered amount of base currency
    "filled":      "0.001",             // filled amount of base currency
    "remaining":   "0",                 // remaining amount to fill
    "cost":       "0.000034138432",     // "filled" * "price" (filling price used where available)
    "fee": {                            // fee info, if available
        "code": "32",                     // which currency the fee is (usually quote)
        "name": "BTC",
        "cost": "0",                    // the fee amount in that currency
        "rate": "0",                    // the fee rate (if available)
    }
}

GET /orders/trades 获取用户的历史成交详情

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
symbol false string 交易对symbol 68719476706, 4294967297, ...
orderid false string 订单id a7922889b77005bae42b48cd15db3849a1e89d4b, , ...
since false int 获取用户trade的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个trade
limit false int 用户trade个数 100 [1,100]

响应数据:

matchresults info list
[
    {
        "id":           "3b185509047d385381fa1ec4d975ebb0d41c97c3",  // string trade id
        "txid":         "909108605661dfd3e6d85ae2a9faceb524dce733",  // transaction id in bytetrade
        "timestamp":    1502962946216,                               // Unix timestamp in milliseconds
        "datetime":     "2017-08-17 12:42:48.000",                   // ISO8601 datetime with milliseconds
        "symbol":       "4294967297",                                  // symbol
        "name":         "ETH/BTC",                                   // symbol name
        "order":        "d891f26f8cbc08e27434eb9ab9fb937ee1e7e438",  // string order id or undefined/None/null
        "side":         "sell",                                      // direction of the trade, "buy" or "sell"
        "takerOrMaker": "taker",                                     // string, "taker" or "maker"
        "price":        "0.00007412",                                // float price in quote currency
        "amount":       "27.29041663",                               // amount of base currency
        "cost":         "0.0020227656806156",                        // total cost (including fees), `price * amount`
        "fee":          {                                            // provided by exchange or calculated by ccxt
            "cost":  "0.0000016182125445",                           // float
            "code": "32",                                               // usually base currency for buys, quote currency for sells
            "name": "BTC",
            "rate": 0.002,                                           // the fee rate (if available)
        }
    }
]

GET /depositaddress 获取充值地址

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
code false string currency的code 2, 3, ...

响应数据:

deposit address
[
    {
        "code": "2",                                                 // currency code
        "name": "ETH",
        "chainType":"ethereum",                                    // 充值链类型,当前支持ethereum/naka/cmt/bitcoin
        "address": "0x10c03cde1395e8e1e7626b890384c9897f7f597b",   // address in terms of requested currency
        "tag": ""                                                  // tag / memo / paymentId for particular currencies (XRP, XMR, ...)
    }
]

GET /withdrawals 获取用户单个或者所有currency的提现记录

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
code false string currency的code 2, 3, ...
since false int 获取用户withdraw的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个withdraw
limit false int withdraw数据个数 100 [1,100]

响应数据:

withdrawal list
[
    {
      "id": "e523e01b778e377c9bbc3a883305409c3774efb1",                             
      "txid": "0xc42f1611d795cb5a9bda63af4a9fd28c7958a18d908bf1750ccfea9ace88d48f",                                                                   // 对应外部链上的转账信息,当前从listWithdraws没有找到这个,但是从区块浏览器中可以看到,需要确认下如何获取
      "timestamp": 1553134089103,                                                  
      "datetime": "2019-03-21T02:08:09.103Z",                                      
      "address": "0x32d74896f05204d1b6ae7b0a3cebd7fc0cd8f9c7",                   
      "tag": "",                                                                  
      "type": "withdrawal",                         
      "amount": 10,                                       
      "code": "3",     
      "name": "KCASH",                                                         
      "status": "succeed",                              
      "updated": 1553134584448,                          
      "fee": {                                   
        "code": "3",    
        "name": "KCASH",                      
        "cost": "0",                            
        "rate": "0"
      }
    }
]

GET /deposits 获取用户单个或者所有currency的充值记录

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
code false string currency的id 2, 3, ...
since false int 获取用户deposit的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个deposit 0
limit false int deposit数据个数 100 [1,100]

响应数据:

deposit list
[
    {
      "id": "7b52aeb2d8f624d16ef0473defdd8d39db057c02",                             
      "txid": "0xdfa9724b0f269a2b2eecd952c6b369320febce047938772fff6f129322bf632c",                                                             // 对应外部链上的转账信息,当前从listWithdraws没有找到这个,但是从区块浏览器中可以看到,需要确认下如何获取
      "timestamp": 1553134089103,                                                  
      "datetime": "2019-03-21T02:08:09.103Z",                       
      "address": "0x10c03cde1395e8e1e7626b890384c9897f7f597b",              
      "tag": "",                                                                  
      "type": "deposit",                         
      "amount": "0.01030928",                             
      "code": "2",   
      "name":"ETH",                                                                                               
      "status": "succeed",                              
      "updated": 1553134584448,                        
      "fee": {                                           
        "code": "2",    
        "name": "ETH",                       
        "cost": "0",                            
        "rate": "0"
      }
    }
]

GET /transfers 获取用户单个或者所有currency的在bytetrade上的转账记录

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
userid true string 用户id Aquila, , ...
code false string currency的id 2, 3, ...
since false int 获取用户transfer的开始时间(utc毫秒),如果不设置这个值,则默认获取从当前时刻向前的limit个transfer 0
limit false int transfer数据个数 100 [1,100]
transfer list

请求响应例子:

[
    {
      "id": "8dd700fde3e0f947e4b52d72950a9fb3261c59d1",                    
      "timestamp": 1553134089103,                                           
      "datetime": "2019-03-21T02:08:09.103Z",                        
      "tag": "",                                                                 
      "type": "transfer",                         
      "amount": "-5",                                                             
      "to":"fly2020",                                                           
      "from":"gogogo",                                                            
      "code": "34",                                                         
      "name": "MT",                                           
      "status": "succeed",                                                 
      "updated": 1553134584448                                               
    }
]

POST /transaction/createorder 创建订单

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
trObj true string 带有序列化后的签名信息的创建订单的transaction
事务参数名称 是否必须 类型 描述 默认值 取值范围
fee true uint128 创建transaction时需要的打包手续费BTT的数量,使用链上整数格式表示 300000000000000
creator true string 用户名
side true uint8 订单方向 1:sell, 2:buy
order_type true uint8 订单类型 1:limitOrder,2:marketOrder
market_name true string 市场名字
amount true uint128 交易的币数量,使用链上整数格式表示
price true uint128 交易的币价格,使用链上整数格式表示
now true string 当前时间,格式为 %Y-%m-%dT%H:%M:%S
expiration true string 过期时间,格式为 %Y-%m-%dT%H:%M:%S
use_btt_as_fee true bool 是否使用BTT作为交易手续费 false
freeze_btt_fee false uint128 使用BTT作为交易手续费时,需要冻结的数量
custom_no_btt_fee_rate false uint128 使用BTT作为交易手续时的交易费率
money_id true uint32 交易对的quoteid 1, 2, 3, ...
stock_id true uint32 交易对的baseid 1, 2, 3, ...

其它说明

  1. 订单被提交到链上后,会首先进行签名验证,验证无误后,返回提交成功的消息(注意,此时并不代表此订单被成功创建),如果签名验证失败,则返回验证失败的消息;
  2. 在订单真正创建成功前,会进行价格精度、数量精度、账户余额的等检查,如果检查通过,才能创建成功;
  3. 在提交订单时,此订单的orderid已经确定,可通过orders的相关接口进行查询此订单情况,若查询结果不包含此订单,则说明此订单没有创建成功。

请求响应例子:

var bytetrade_js = require('../utils/bytetrade.min.js');
var test_userid='harvey1340';
var test_privatekey='682503fc0582ff940c7fe97ef48b49d18421e5668af5811c0b3f74cf21f33f54';
var dapp_name = 'Sagittarius';

function create_order() {
    var tr = new bytetrade_js.TransactionBuilder();
    var ob = {
        fee: '300000000000000',   // 0.0003 *1000000000000000000  fee
        creator: test_userid,     // creator userid
        side: 2,                  // 1:sell, 2:buy
        order_type: 1,            // 1:limitOrder,2:marketOrder
        market_name: "KCASH/ETH",
        amount: '4310000000000000', // amount, which is represented as an integer on the chain, amount*10^basePrecision;
        price: '83210000000000',    // price, which is represented as an integer on the chain, price*10^basePrecision;
        now: Math.ceil(Date.now() / 1000),
        expiration: Math.ceil(Date.now() / 1000) + 10,
        use_btt_as_fee: false,
        freeze_btt_fee: 0,
        custom_no_btt_fee_rate: 8,
        money_id: 2,   // quote currency
        stock_id: 3    // base currency
    }

    tr.add_type_operation("order_create", ob);
    tr.timestamp = Math.ceil(Date.now() / 1000);
    tr.dapp=dapp_name;
    tr.validate_type = 0;
    tr.add_signer(bytetrade_js.PrivateKey.fromHex(test_privatekey));
    tr.finalize();
    if (!tr.signed) { tr.sign(); }
    var trObj = tr.toObject();
    console.log("id " + tr.id());
    signedTransaction = JSON.stringify(trObj);
    const request = {
        'trObj': signedTransaction,
    };
    // next step is POST request to /transaction/createorder endpoint
}

POST /transaction/cancelorder 取消订单

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
trObj true string 签名及序列化后的取消订单的transaction
事务参数名称 是否必须 类型 描述 默认值 取值范围
fee true uint128 创建transaction时需要的打包手续费BTT的数量,使用链上整数格式表示 300000000000000
creator true string 用户名
market_name true string 市场名字
order_id true uint128 订单id,对应/orders/open接口中的id
money_id true uint32 交易对的quoteid 1, 2, 3, ...
stock_id true uint32 交易对的baseid 1, 2, 3, ...

请求响应例子:

var bytetrade_js = require('../utils/bytetrade.min.js');
var test_userid='harvey1340';
var test_privatekey='682503fc0582ff940c7fe97ef48b49d18421e5668af5811c0b3f74cf21f33f54';
var dapp_name = 'Sagittarius';

function cancel_order(order_id) {
    var tr = new bytetrade_js.TransactionBuilder();
    var ob = {
        fee: '300000000000000',   
        creator: test_userid,
        market_name: 4294967297,
        order_id: order_id,
        money_id: 2,
        stock_id: 3
    }

    tr.add_type_operation("order_cancel", ob);

    tr.timestamp = Math.ceil(Date.now() / 1000);
    tr.dapp=dapp_name;
    tr.validate_type = 0;
    tr.add_signer(bytetrade_js.PrivateKey.fromHex(test_privatekey));
    tr.finalize();
    if (!tr.signed) { tr.sign(); }
    var trObj = tr.toObject();
    console.log("id " + tr.id());
    signedTransaction = JSON.stringify(trObj);
    const request = {
        'trObj': signedTransaction,
    };
    // next step is POST request to /transaction/cancelorder endpoint
}

POST /transaction/withdraw 申请提币

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
chainType true uint32 currency的链类型id,链类型名字对应currencies接口中的chainType字段 1:ethereum, 2:bitcoin, 3:cmt, 4:naka
toExternalAddress true string 用户的提币地址
trObj true string 带有序列化后的签名信息的withdraw的transaction
chainContractAddress true string currency在相应的链上的地址,对应currencies接口中的chainContractAddress字段
事务参数名称 是否必须 类型 描述 默认值 取值范围
fee true uint128 创建transaction时需要的打包手续费BTT的数量,使用链上整数格式表示 300000000000000
from true string 提币的用户名
to_external_address true string 用户对应的pixiu地址,对应depositaddress接口中的address字段
asset_type true uint32 提币的币id
amount true uint128 提的币数量,使用链上整数格式表示
asset_fee false uint128 仅在提取BTC和USDT时有效,对应currencies接口中的fee字段

请求响应例子:

var bytetrade_js = require('../utils/bytetrade.min.js');
var test_userid='harvey1340';
var test_privatekey='682503fc0582ff940c7fe97ef48b49d18421e5668af5811c0b3f74cf21f33f54';
var pixiu_middle_address = '0x4e52cb4aba1b507ed27ab046791eddee6d471b2d';
var user_real_address = '0x34aF13D89eBCdbc0548FdeB15e5FFF5c2eD93036'
var dapp_name = 'Sagittarius';
var chainType = 1; // ETH


function withdraw() {
    var tr = new bytetrade_js.TransactionBuilder();
    if (chainType !== 2) {  // not btc chain
        var ob = {
            fee: '300000000000000',
            from: test_userid,
            to_external_address: pixiu_middle_address,
            asset_type: 2,
            amount: '20000000000000000'
        };
        tr.add_type_operation("withdraw", ob);
        tr.propose({ fee: '300000000000000',
            proposaler: test_userid,
            expiration_time: Math.ceil(Date.now() / 1000),
            proposed_ops: []
        });
    } else {
        var ob = {
            fee: '300000000000000',
            from: test_userid,
            to_external_address: pixiu_middle_address,
            asset_type: 32,
            amount: '20000000000000000',
            asset_fee: '53004', // btc chain fee
        };
        tr.add_type_operation("withdraw2", ob);
    }

    tr.timestamp = Math.ceil(Date.now() / 1000);
    tr.dapp=dapp_name;
    tr.validate_type = 0;
    tr.add_signer(bytetrade_js.PrivateKey.fromHex(test_privatekey));
    tr.finalize();
    if (!tr.signed) { tr.sign(); }
    var trObj = tr.toObject();
    console.log("id " + tr.id());
    signedTransaction = JSON.stringify(trObj);
    const request = {};
    request['chainType'] = chainType;
    request['toExternalAddress'] = user_real_address;
    request['trObj'] = signedTransaction;
    request['chainContractAddress'] = '0x0000000000000000000000000000000000000000';
    // next step is POST request to /transaction/withdraw endpoint
}

POST /transaction/transfer 申请转账

请求参数:

参数名称 是否必须 类型 描述 默认值 取值范围
trObj true string 带有序列化后的签名信息的transfer的transaction
事务参数名称 是否必须 类型 描述 默认值 取值范围
fee true uint128 创建transaction时需要的打包手续费BTT的数量,使用链上整数格式表示 300000000000000
from true string 转出币的用户名
to true string 接收币的用户名
asset_type true uint32 转出的币的id
amount true uint128 转出的币数量,使用链上整数格式表示

请求响应例子:

var bytetrade_js = require('../utils/bytetrade.min.js');
var test_userid='harvey1340';
var test_privatekey='682503fc0582ff940c7fe97ef48b49d18421e5668af5811c0b3f74cf21f33f54';

function transfer(to,asset,amount,message) {
    var tr = new bytetrade_js.TransactionBuilder();
    var ob = {
        fee: '300000000000000',
        from: test_userid,
        to: to,
        asset_type: asset,
        amount: amount
    }

    tr.add_type_operation("transfer", ob);

    tr.timestamp = Math.ceil(Date.now() / 1000);
    tr.dapp=dapp_name;
    tr.validate_type = 0;
    tr.add_signer(bytetrade_js.PrivateKey.fromHex(test_privatekey));
    tr.finalize();
    if (!tr.signed) { tr.sign(); }
    var trObj = tr.toObject();
    console.log("id " + tr.id());
    signedTransaction = JSON.stringify(trObj);
    const request = {
        'trObj': signedTransaction,
    };
    // next step is POST request to /transaction/transfer endpoint
}