API Reference

NAV Navbar
json

更新日志

版本 时间 内容
V1.0.2
2021 DEC 9
* GET /um/v1/transactions 添加 instrument_id 参数, 返回数据添加 cash_flow
V1.0.1
2021 NOV 11
上线
V1.0.0
2021 SEP 1
统一保证金初始版本

介绍

统一交易账户以下简写为UM(Unified margin trade account)账户。
统一保证金模式以下简写为UM(Unified margin account mode)模式。

统一保证金模式API使用指引

查询自己的账户类型及相关配置

统一保证金模式下的钱包功能

统一保证金模式下的交易功能

统一保证金模式下的订阅功能

测试环境访问地址

生产环境访问地址

跟衍生品 Api hosts 相同

访问限制

为了保证系统运行效率,bit.com实施API访问限流措施。公有接口按IP进行频率限制,私有接口按UID进行频率限制。当请求频率超限时,会返加“429 too many requests” 提示。每个UID的API限制参数可在bit.com网站的交易中心页面进行查看。如需提高限制参数,请联系我们的用户支持([email protected])。

鉴权

私有接口必填字段


如果鉴权失败,会返回错误码412“AkID is valid”。

签名算法

    #########
    # Python code to calc BIT.COM API signature
    #########
    import hashlib
    import hmac

    def encode_list(self, item_list):
        list_val = []
        for item in item_list:
            obj_val = self.encode_object(item)
            list_val.append(obj_val)
        sorted_list = sorted(list_val)
        output = '&'.join(sorted_list)
        output = '[' + output + ']'
        return output

    def encode_object(self, param_map):
        sorted_keys = sorted(param_map.keys())
        ret_list = []
        for key in sorted_keys:
            val = param_map[key]
            if isinstance(val, list):
                list_val = self.encode_list(val)
                ret_list.append(f'{key}={list_val}')
            elif isinstance(val, dict):
                # call encode_object recursively
                dict_val = self.encode_object(val)
                ret_list.append(f'{key}={dict_val}')
            elif isinstance(val, bool):
                bool_val = str(val).lower()
                ret_list.append(f'{key}={bool_val}')
            else:
                general_val = str(val)
                ret_list.append(f'{key}={general_val}')

        sorted_list = sorted(ret_list)
        output = '&'.join(sorted_list)
        return output

    def get_signature(self, http_method, api_path, param_map):
        str_to_sign = api_path + '&' + self.encode_object(param_map)
        print('str_to_sign = ' + str_to_sign)
        sig = hmac.new(self.secret_key.encode('utf-8'), str_to_sign.encode('utf-8'), digestmod=hashlib.sha256).hexdigest()
        return sig

    #########
    # END
    #########

  1. 请求参数:POST为JSON,其余部分为查询字符串
  2. 对签名进行编码,对于简单的json对象,请按字母顺序对参数进行排序,并把他们用“&”连接,如'param1=value1&param2=value2', then get str_to_sign = api_path + '&' + 'param1=value1&param2=value2'
  3. 对嵌套数组对象,对每个对象进行编码,并按字母顺序进行排序,使用“&”符号连接,并用[ ]括起来,如 str_to_sign = api_path + '&' + 'param1=value1&array_key1=[array_item1&array_item2]', 参见下面的例子
  4. 签名使用哈希算法,hex(hmac_sha256(str_to_sign, secret_key))
  5. 在请求参数中添加签名字段:对查询字符串,添加“&signature=YOUR_SIGNATURE”, 对JOSN请求体, 添加 {'signature':YOUR_SIGNATURE}


































GET 请求示例:

*Secret Key: eabc3108-dd2b-43df-a98d-3e2054049b73
*HTTP method: GET
*API Path: /v1/margins
*Query string: price=8000&qty=30&instrument_id=BTC-PERPETUAL&timestamp=1588242614000
*得到 str_to_sign = /v1/margins&instrument_id=BTC-PERPETUAL&price=8000&qty=30&timestamp=1588242614000

> echo -n "/v1/margins&instrument_id=BTC-PERPETUAL&price=8000&qty=30&timestamp=1588242614000" | openssl dgst -sha256 -hmac "eabc3108-dd2b-43df-a98d-3e2054049b73"

> e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d

sig = hex(hmac_sha256(str_to_sign, secret_key)) = e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d

*最后JSON请求体为: { "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000, "signature": "e3be96fdd18b5178b30711e16d13db406e0bfba089f418cf5a2cdef94f4fb57d" }

POST 请求示例:

Secret Key: eabc3108-dd2b-43df-a98d-3e2054049b73
HTTP method: POST
API Path: /v1/orders
JSON body:
{ "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000 }

得到 str_to_sign = /v1/orders&auto_price=&auto_price_type=&instrument_id=BTC-27MAR20-9000-C&order_type=limit&price=0.021&qty=3.14&side=buy&stop_price=&stop_price_trigger=&time_in_force=gtc&timestamp=1588242614000

> echo -n "/v1/orders&auto_price=&auto_price_type=&instrument_id=BTC-27MAR20-9000-C&order_type=limit&price=0.021&qty=3.14&side=buy&stop_price=&stop_price_trigger=&time_in_force=gtc&timestamp=1588242614000" | openssl dgst -sha256 -hmac "eabc3108-dd2b-43df-a98d-3e2054049b73"

> 34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817

sig = hex(hmac_sha256(str_to_sign, secret_key)) = 34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817

最后JSON请求体为: { "instrument_id": "BTC-27MAR20-9000-C", "order_type": "limit", "price": "0.021", "qty": "3.14", "side": "buy", "time_in_force": "gtc", "stop_price": "", "stop_price_trigger": "", "auto_price": "", "auto_price_type": "", "timestamp": 1588242614000, "signature": "34d9afa68830a4b09c275f405d8833cd1c3af3e94a9572da75f7a563af1ca817" }

POST 请求带 boolean 字段

例如以POST /v1/orders 为例 (post_only 字段),

例子

request

得到 string to sign

POST 请求带 array 字段

for item in object_array:
    str_list.add(encode(item))
str_list.sorted()
str_to_sign = '&'.join(str_list)

以 POST /v1/blocktrades 为例:

私钥是 eabc3108-dd2b-43df-a98d-3e2054049b73

例子

request

得到 string to sign

Please refer to authentication section of derivative/spot API

接口目录

Path Method Description Scope Rate Limit Type Permission
/um/v1/index_price GET 查询指数 public public /
/um/v1/loan_rates GET 查询借币利率 public public /
/um/v1/account_mode GET 查询账户类型 private others read
/um/v1/accounts GET 查询统一账户数据 private others read
/um/v1/transactions GET 查询统一账户交易日志 private others read
/um/v1/interest_records GET 查询统账户计息记录 private. others read
/v1/wallet/um-withdraw POST 统一账户提现 private wallet wallet
/v1/wallet/um-withdrawals GET 查询统一账户提现记录 private wallet read
/v1/wallet/um-deposits GET 查询统一账户充值记录 private wallet read
/v1/wallet/transfer POST 转账 private wallet wallet
/v1/wallet/transfer GET 转账记录查询 private wallet read
/v1/wallet/sub-user-transfer POST 子母账户转账 private wallet wallet
/v1/wallet/sub-user-transfer GET 子母账户转账记录查询 private wallet read

公共市场数据

获取指数

GET /um/v1/index_price

curl "https://betaapi.bitexch.dev/um/v1/index_price?currency=BTC&quote_currency=USDT"

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "index_name": "BTC-USDT",
            "index_price": "50000"
        }
    ]
}

获取以USD或USDT为计价币种的指数。 币种参数为非必填,如果币种传入为空,则返回某计价币种下的所有币对指数。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string false "" 币种
quote_currency string true "" 计价币种(目前支持USD和USDT)

返回数据

参数名称 数据类型 说明
index_name string 指数名称
index_price string 指数价格

查询借币利率

GET /um/v1/loan_rates

curl "https://betaapi.bitexch.dev/um/v1/loan_rates?currency=ETH"

返回数据

{
    "code": 0,
    "message": "",
    "data": {
        "currency": "ETH",
        "last_hour_rate": "0.03000000"
    }
}

获取过去最近一小时的借币利率。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string false "" 币种

返回数据

参数名称 数据类型 说明
currency string 币种
last_hour_rate string 过去一小时的平均借币利率

账户信息

查询账户模式

GET /um/v1/account_mode


curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/um/v1/account_mode?timestamp=1589521383462&signature=30f7cf5c8018f5dfee515533e25a1813e9120be7898b62fb85a2f4129f3e9528"

返回数据


// account_mode = Um
{
    "code": 0,
    "message": "",
    "data": {
        "user_id": 1,
        "account_mode": "um",
        "auto_borrow": true,
        "um_risk_mode": "regular",
        "classic_accounts": []
    }
}

// account_mode = classic
{
    "code": 0,
    "message": "",
    "data": {
        "user_id": 1,
        "account_mode": "classic",
        "auto_borrow": false,
        "um_risk_mode": "",
        "classic_accounts": [
            {
                "currency": "BCH",
                "classic_risk_mode": "portfolio_margin"
            },
            {
                "currency": "BTC",
                "classic_risk_mode": "portfolio_margin"
            },
            {
                "currency": "ETH",
                "classic_risk_mode": "portfolio_margin"
            }
        ]
    }
}

查询账户类型。账户类型有两类:经典模式和统一模式。另外还有迁移中的临时状态。

查询参数

None

返回数据

字段名称 数据类型 说明
user_id int 用户ID
account_mode string 账户模式
auto_borrow bool 是否自动借币
um_risk_mode string 统一模式下的风险类型:普通/PM (当账户类型为统一模式时有效)
classic_accounts array 经典模式下分币种的风险类型(当账户类型为经典模式时有效)
字段名称 数据类型 说明
currency string 币种
classic_risk_mode string regular/um

获取统一交易账户信息

GET /um/v1/accounts


curl -H "X-Bit-Access-Key: ak-ba3bd026-29e6-443b-8eb6-d2ea3b607113" "https://betaapi.bitexch.dev/um/v1/accounts?timestamp=1589521383462&signature=30f7cf5c8018f5dfee515533e25a1813e9120be7898b62fb85a2f4129f3e9528"

返回数据


{
    "code": 0,
    "message": "",
    "data": {
        "user_id": 481554,
        "created_at": 1649923879505,
        "total_collateral": "3170125.05978108",
        "total_margin_balance": "3170125.05978108",
        "total_available": "3169721.64891398",
        "total_initial_margin": "403.41086710",
        "total_maintenance_margin": "303.16627631",
        "total_initial_margin_ratio": "0.00012725",
        "total_maintenance_margin_ratio": "0.00009563",
        "total_liability": "0.00000000",
        "total_unsettled_amount": "-0.84400340",
        "spot_orders_hc_loss": "0.00000000",
        "details": [
            {
                "currency": "BTC",
                "equity": "78.13359310",
                "liability": "0.00000000",
                "index_price": "41311.20615385",
                "cash_balance": "78.13360190",
                "margin_balance": "78.13359310",
                "available_balance": "78.12382795",
                "initial_margin": "0.00976516",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00733859",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.02966586",
                "total_delta": "0.48532539",
                "session_rpl": "0.00001552",
                "session_upl": "-0.00003595",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_pnl": "0.02966586",
                "future_session_rpl": "0.00001552",
                "future_session_upl": "-0.00003595",
                "future_session_funding": "0.00001552",
                "future_delta": "0.48532539",
                "future_available_balance": "76.72788921",
                "option_available_balance": "76.72788921",
                "unsettled_amount": "-0.00002043",
                "usdt_index_price": "41311.20615385"
            },
            {
                "currency": "ETH",
                "equity": "1.99960000",
                "liability": "0.00000000",
                "index_price": "3119.01923077",
                "cash_balance": "1.99960000",
                "margin_balance": "1.99960000",
                "available_balance": "1.99960000",
                "initial_margin": "0.00000000",
                "spot_margin": "0.00000000",
                "maintenance_margin": "0.00000000",
                "potential_liability": "0.00000000",
                "interest": "0.00000000",
                "interest_rate": "0.07000000",
                "pnl": "0.00000000",
                "total_delta": "0.00000000",
                "session_rpl": "0.00000000",
                "session_upl": "0.00000000",
                "option_value": "0.00000000",
                "option_pnl": "0.00000000",
                "option_session_rpl": "0.00000000",
                "option_session_upl": "0.00000000",
                "option_delta": "0.00000000",
                "option_gamma": "0.00000000",
                "option_vega": "0.00000000",
                "option_theta": "0.00000000",
                "future_pnl": "0.00000000",
                "future_session_rpl": "0.00000000",
                "future_session_upl": "0.00000000",
                "future_session_funding": "0.00000000",
                "future_delta": "0.00000000",
                "future_available_balance": "1.99960000",
                "option_available_balance": "1.99960000",
                "unsettled_amount": "0.00000000",
                "usdt_index_price": "3119.01923077"
            }
        ],
        "usdt_total_collateral": "3170125.05978108",
        "usdt_total_margin_balance": "3170125.05978108",
        "usdt_total_available": "3169721.64891398",
        "usdt_total_initial_margin": "403.41086710",
        "usdt_total_maintenance_margin": "303.16627631",
        "usdt_total_initial_margin_ratio": "0.00012725",
        "usdt_total_maintenance_margin_ratio": "0.00009563",
        "usdt_total_liability": "0.00000000",
        "usdt_total_unsettled_amount": "-0.84400340"
    }
}



UM用户,用此接口获取统一交易账户信息。

PM total_initial_margin_ratio 公式
true (total_im + spot_haircut_loss) / collateral
false (total_im + spot_haircut_loss) / margin_balance

1)如果分子和分母都为0,返回0。
2)否则如果分母 <=0, 返回 "infinity".
3)返回分子/分母

PM total_maintenance_margin_ratio 公式
true total_maintenance_margin / collateral
false total_maintenance_margin / margin_balance

1)如果分子和分母都为0,返回0。
2)否则如果分母 <=0, 返回 "infinity".
3)返回分子/分母

请求参数

None

返回数据

参数名称 数据类型 说明
user_id int 用户ID
created_at int 时间戳(查询时刻)
total_collateral string 账户维度USD总担保品金额
total_margin_balance string 账户维度USD总保证金余额
total_available string 账户维度USD总可用余额
total_initial_margin string 账户维度USD总初始保证金
total_maintenance_margin string 账户维度USD总维持保证金
total_initial_margin_ratio string 账户维度USD总初始保证金率,可能会返回"infinity"
total_maintenance_margin_ratio string 账户维度USD总维持保证金率,可能会返回"infinity"
total_liability string 账户维度USD总负债
total_unsettled_amount string 账户维度USD总待结金额
spot_orders_hc_loss string 现货挂单损失
details array 分币种账户信息
usdt_total_collateral string (兼容旧字段) 等于 total_collateral
usdt_total_margin_balance string (兼容旧字段) 等于 total_margin_balance
usdt_total_available string (兼容旧字段) 等于 total_available
usdt_total_initial_margin string (兼容旧字段) 等于 total_initial_margin
usdt_total_maintenance_margin string (兼容旧字段) 等于 total_maintenance_margin
usdt_total_initial_margin_ratio string (兼容旧字段) 等于 total_initial_margin_ratio
usdt_total_maintenance_margin_ratio string (兼容旧字段) 等于 total_maintenance_margin_ratio
usdt_total_liability string (兼容旧字段) 等于 total_liability
usdt_total_unsettled_amount string (兼容旧字段) 等于 total_unsettled_amount
参数名称 数据类型 说明
currency string 币种
equity string 权益
liability string 负债
index_price string USD指数价格
usdt_index_price string (兼容旧字段) 等于 index_price
cash_balance string 现金余额
margin_balance string 保证金余额
available_balance string 可用余额
initial_margin string 初始保证金
spot_margin string 现货冻结金额
maintenance_margin string 维持保证金
potential_liability string 潜在负债
interest string 借币利息
interest_rate string 借币利率
pnl string 总损益
total_delta string 账户delta总值
session_rpl string 已实现损益
session_upl string 未实现损益
option_value string 期权市值
option_pnl string 期权损益
option_session_rpl string 期权已实现损益
option_session_upl string 期权未实现损益
option_delta string 期权delta
option_gamma string 期权gamma
option_vega string 期权vega
option_theta string 期权theta
future_pnl string 期货损益
future_session_rpl string 期货已实现损益
future_session_upl string 期货未实现损益
future_session_funding string 期货funding
future_delta string 期货delta
future_available_balance string 期货最大可用余额
option_available_balance string 期权最大可用余额
unsettled_amount string 待结金额

查询统一交易账户交易日志

GET /um/v1/transactions

curl -H "X-Bit-Access-Key: ak-8e97ac6c-8075-4a94-b2bb-38bd537619fa" "https://betaapi.bitexch.dev/um/v1/transactions?currency=BTC&type=trade-recv&limit=2&timestamp=1620369292928&signature=35d76033f6e251ce85524ec4310417fd555953fff00cd33f3a94e3d27d062965" 


返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "tx_time": 1631240595162,
            "tx_type": "deposit",
            "ccy": "BTC",
            "instrument_id": "",
            "direction": "",
            "qty": "3.20000000",
            "price": "",
            "position": "",
            "fee_paid": "0.00000000",
            "fee_rate": "",
            "funding": "",
            "change": "3.20000000",
            "balance": "107.00000000",
            "order_id": "",
            "trade_id": "",
            "remark": ""
        },
        {
            "tx_time": 1630722195162,
            "tx_type": "spot-trade-recv",
            "ccy": "BTC",
            "instrument_id": "BTC-USDT",
            "direction": "buy",
            "qty": "2.00000000",
            "price": "60000.00000000",
            "position": "",
            "fee_paid": "0.00030000",
            "fee_rate": "0.00000000",
            "funding": "",
            "change": "2.00000000",
            "balance": "102.00000000",
            "order_id": "9001",
            "trade_id": "3001",
            "remark": ""
        }
    ],
    "page_info": {
        "has_more": false
    }
}

查询统一交易账户的交易日志。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string false "" 币种
instrument_id string false "" 产品名称
start_time integer false One month ago 起始时间戳
end_time integer false Now 结束时间戳
type string false "" 交易日志类型
offset int false 1 分页偏移(第一页为1)
limit int false 100 分页大小

返回数据

参数名称 数据类型 说明
tx_time integer 时间戳
tx_type string 交易日志类型
ccy string 币种
instrument_id string 产品名称
direction string 方向: buy/sell
qty string 数量
price string 交易价格 (针对trade交易类型有效)
position string 期权/期货仓位
fee_paid string 手续费
fee_rate string 手续费率
funding string 资金费用
change string 账户变动
cash_flow string 现金流(现货cash_flow=change, 期权/期货请参考期权/期货的transactions文档)
balance string 变动后的余额
order_id string 订单ID
trade_id string 交易ID
remark string 备注

查询计息记录

GET /um/v1/interest_records


curl -H "X-Bit-Access-Key: ak-8e97ac6c-8075-4a94-b2bb-38bd537619fa" "https://betaapi.bitexch.dev/um/v1/interest_records?currency=BTC&timestamp=1631669478618&signature=3d4685f07751cd51f42ee631938f189cbe6e9712cc6d559881e5b3b6d1ba1224" 

返回数据

{
    "code": 0,
    "message": "",
    "data": [
        {
            "currency": "BTC",
            "time": 1631559600000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.05000000"
        },
        {
            "currency": "BTC",
            "time": 1631556000000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.06000000"
        },
        {
            "currency": "BTC",
            "time": 1631552400000,
            "loan_rate": "0.00300000",
            "liability": "100.00000000",
            "interest": "1.07000000"
        }
    ],
    "page_info": {
        "has_more": true
    }
}

获取统一保证金账户的计息记录。

查询参数

参数名称 数据类型 是否必填 默认值 说明
currency string true "" 币种
start_time integer false One month ago 起始时间戳
end_time integer false Now 结束时间戳
offset int false 1 分页偏移(第一页为1)
limit int false 100 分页大小

返回数据

参数名称 数据类型 说明
currency string 币种
time integer 计息时间戳
loan_rate string 计息利率
liability string 计息负债
interest string 利息

钱包

Bit.com有3种类型的账户:现货账户,合约账户,统一交易账户。

统一交易账户提现

POST /v1/wallet/um-withdraw

curl -X POST "https://betaapi.bitexch.dev/v1/wallet/um-withdraw" -H "Content-Type: application/json" -H "X-Bit-Access-Key: Your Access Key" -d '{"currency": "BTC", "address": "Your address", "amount": "1.2", "pwd": "Your password", "timestamp": 1589523989378, "signature": "signature"}'

返回数据


{
    "code": 0,
    "message": "",
    "data": {
        "withdraw_id": "b61c2b93-8a25-44d4-9715-023cce61dc50"
    }
}

从统一交易账户向外提取资金。提现地址首先要在bit.com网站的提现页面 设置为白名单地址。资金密码pwd字段需要通过base64(sha256(pwd))进行编码。例如,假设密码是123456,编码后的密码为“jZae727K08KaOmKSgOaGzww/XVqGr/PKEgIMkjrcbJI=”

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency string true "" 币种, BTC
address string true "" 提现的目标地址
amount string true "" 提现金额
pwd string true "" 资金密码
chain string false "" 链名 提现USDT时,要提到USDTERC应填ETH,要提到USDTTRE应填TRX

返回数据

字段名称 数据类型 说明
withdraw_id string 提现订单ID, 可用于后续的查询

查询统一交易账户提现记录

GET /v1/wallet/um-withdrawals

curl -H "X-Bit-Access-Key: Your Access Key" "https://betaapi.bitexch.dev/v1/wallet/um-withdrawals?currency=BTC&limit=10&offset=0&timestamp=1589522687689&signature=signature"

返回数据


{
    "code": 0,
    "data": {
        "count": 2,
        "items": [{
            "address": "mfaFpdVCb6UFS5AXUhC8VGXgj9dnJ37nLP",
            "amount": "0.001",
            "code": 0,
            "confirmations": 0,
            "currency": "BTC",
            "fee": "0.00001",
            "state": "confirmed",
            "transaction_id": "52e1537002f51acbf5f52b9dfeab6a9e7cc185a669cda2573e768420b0839523",
            "created_at": 1608606000000,
            "updated_at": 1608606000000,
            "is_onchain": true
        }, {
            "address": "mfaFpdVCb6UFS5AXUhC8VGXgj9dnJ37nLP",
            "amount": "0.11",
            "code": 13100100,
            "confirmations": 0,
            "currency": "BTC",
            "fee": "0.00001",
            "state": "rejected",
            "transaction_id": "",
            "created_at": 1608606000000,
            "updated_at": 1608606000000,
            "is_onchain": false
        }]
    }
}

指定币种,查询统一交易账户的提现记录。

请求参数

字段名称 数据类型 是否必填 默认值 说明
currency String true "" 币种名称
limit int false 10 分页大小,最大50
offset int false 0 分页偏移
withdraw_id string false "" 提现订单ID

返回数据

字段名称 数据类型 说明
code int 错误码,0代表正常,其他值代表失败
state string 提现状态
address string 提现目标地址
amount string 提现金额
confirmations int 确认数,如果是内部地址,由于不会上链,一直为0
currency string 币种
fee string 提现手续费
transaction_id string 链上交易哈希
created_at int 订单创建时间戳
updated_at int 订单更新时间戳
is_onchain bool 订单是否上链(内部地址提现不上链)

查询统一交易账户充值记录

GET /v1/wallet/um-deposits

curl -H "X-Bit-Access-Key: Your Access Key" "https://betaapi.bitexch.dev/v1/wallet/um-deposits?currency=BTC&limit=10&offset=0&timestamp=1589522687689&signature=signature"

返回数据


{
    "code": 0,
    "data": {
        "count": 1,
        "items": [{
            "address": "mfaFpdVCb6UFS5AXUhC8VGXgj9dnJ37nLP",
            "amount": "0.001",
            "code": 0,
            "confirmations": 0,
            "currency": "BTC",
            "state": "confirmed",
            "transaction_id": "52e1537002f51acbf5f52b9dfeab6a9e7cc185a669cda2573e768420b0839523",
            "created_at": 1608606000000,
            "updated_at": 1608606000000,
            "is_onchain": true
        }]
    }
}

指定币种,查询统一交易账户的充值记录。

请求参数

字段名 类型 是否必填 默认值 说明
currency String true "" 币种名称
limit int false 10 分页大小,最大50
offset int false 0 分页偏移

返回数据

字段名称 数据类型 说明
code int 错误码,0代表正常,其他值代表失败
state string 充值状态
address string 充值来源地址
amount string 充值金额
confirmations int 确认数,如果是内部地址,由于不会上链,一直为0
currency string 币种
transaction_id string 链上交易哈希
created_at int 订单创建时间戳
updated_at int 订单更新时间戳
is_onchain bool 订单是否上链(内部地址充值不上链)

转账

POST /v1/wallet/transfer

curl -X POST "https://betaapi.bitexch.dev/v1/wallet/transfer" -H "Content-Type: application/json" -H "X-Bit-Access-Key: Your Access Key" -d '{"currency": "BTC", "amount": "1.2", "type": 1, "timestamp": 1589523989378, "signature": "signature"}'

返回数据


{
    "code": 0,
    "message": ""
}

Bit.com有3种类型的账户:现货账户,合约账户,统一交易账户。 Bit的账户都支持和Matrixport账户之间的互相划转。

请求参数

字段名 类型 是否必填 默认值 说明
currency string true 币种名称
amount string true 转账金额
type int true 转账类型 1.现货到合约,2.合约到现货,3.现货到Matrixport账户, 4.Matrixport账户到现货,5.合约到Matrixport账户,6.Matrixport账户到合约,7.统一账户到Matrixport账户,8.Matrixport账户到统一账户

转账记录查询

GET /v1/wallet/transfer

curl -H "X-Bit-Access-Key: Your Access Key" "https://betaapi.bitexch.dev/v1/wallet/transfer?currency=BTC&count=10&offset=0&timestamp=1589522687689&signature=signature"

返回数据


{
    "code": 0,
    "data": {
        "count": 2,
        "items": [{
            "status": "done",
            "currency": "BTC",
            "amount": "1.2",
            "type": 1,
            "created_at": 1608606000000,
            "id": "123"
        }, {
            "status": "done",
            "currency": "ETH",
            "amount": "1.2",
            "type": 2,
            "created_at": 1608606000000,
            "id": "124"
        }]
    }
}

请求参数

字段名 类型 是否必填 默认值 说明
currency string false 币种名称
limit int false 10 分页大小,最大50
offset int false 1 分页偏移

返回数据

字段名称 数据类型 说明
status string 转账状态 失败/成功/处理中
type int 转账类型
currency string 币种名称
amount string 转账金额
created_at int 转账创建时间戳
order_id string 转账订单ID

子母账号转账

POST /v1/wallet/sub-user-transfer

curl -X POST "https://betaapi.bitexch.dev/v1/wallet/sub-user-transfer" -H "Content-Type: application/json" -H "X-Bit-Access-Key: Your Access Key" -d '{"currency": "BTC", "amount": "1.2", "type": 1, "from_user": "123", "to_user": "124", "timestamp": 1589523989378, "signature": "signature"}'

返回数据

{
    "code": 0,
    "message": ""
}

请求参数

参数名 类型 是否必填 说明
from int 转出用户ID
to int 转入用户ID
currency string 币种, BTC, BCH, ETH
amount string 划转金额,单位个,例如1.23
type int 转账类型,1.现货到现货,2.合约到合约,3.现货到合约,4.合约到现货,5.统一账户到统一账户,6.统一账户到合约,7.合约到统一账户,8.统一账户到现货,9.现货到统一账户

注意


子母账号转账记录查询

GET /v1/wallet/sub-user-transfer

curl -H "X-Bit-Access-Key: Your Access Key" "https://betaapi.bitexch.dev/v1/wallet/sub-user-transfer?currency=BTC&count=10&offset=0&timestamp=1589522687689&signature=signature"

返回数据

{
    "code": 0,
    "data": {
        "count": 2,
        "items": [{
            "status": "done",
            "currency": "BTC",
            "amount": "1.2",
            "type": 1,
            "created_at": 1608606000000,
            "id": "123"
        }, {
            "status": "done",
            "currency": "ETH",
            "amount": "1.2",
            "type": 2,
            "created_at": 1608606000000,
            "id": "124"
        }]
    }
}

请求参数

参数名 类型 是否必填 说明
sub_user_id int
currency string
page int 默认1
limit int 默认50

返回

字段 类型 说明
type int 1.现货到现货,2.合约到合约,3.现货到合约,4.合约到现货,5.统一账户到统一账户,6.统一账户到合约,7.合约到统一账户,8.统一账户到现货,9.现货到统一账户
from int
to int
currency string
amount string
order_id string
created_at int 创建时间戳,单位秒