新建子帳戶的API Key
給新建好的子帳戶創建新的API key。需使用母帳戶的API key。
提示
在調用接口時,使用的API key至少需要擁有以下其中一種權限
- 母API key: "Account Transfer(資產帳戶劃轉)", "Subaccount Transfer(母子帳戶劃轉)", "Withdrawal(提幣)"
HTTP 請求
POST /v5/user/create-sub-api
請求參數
參數 | 是否必須 | 類型 | 說明 |
---|---|---|---|
subuid | true | integer | 子帳戶userId |
note | false | string | 設置備註 |
readOnly | true | integer | 0 :可讀可寫. 1 :只讀 |
ips | false | string | 綁定IP. 比如: "192.168.0.1,192.168.0.2"注意:
|
permissions | true | Object | 勾選api key權限.
|
> ContractTrade | false | array | 合約. ["Order","Position"] |
> Spot | false | array | 現貨. ["SpotTrade"] |
> Wallet | false | array | 錢包. ["AccountTransfer","SubMemberTransferList"] |
> Options | false | array | USDC合約. ["OptionsTrade"] |
> Derivatives | false | array | 統一帳戶權限. 該字段失效, 因為系統將會自動根據您的帳戶類型(經典帳戶和統一帳戶)來決定是否增加該權限 |
> Exchange | false | array | 兌換. ["ExchangeHistory"] |
> CopyTrading | false | array | 跟單交易. ["CopyTrading"] |
返回參數
參數 | 類型 | 說明 |
---|---|---|
id | string | 唯一id. 內部使用 |
note | string | 備註 |
apiKey | string | Api key |
readOnly | integer | 0 :可讀可寫. 1 :只讀 |
secret | string | Api密鑰密碼.
|
permissions | Object | 權限類型 |
> ContractTrade | array | 合約交易的權限 |
> Spot | array | 現貨交易的權限 |
> Wallet | array | 錢包的權限 |
> Options | array | USDC合約的權限. 該權限支持USDC合約下的期權和永續交易 |
> Derivatives | array | 統一帳戶權限 |
> CopyTrading | array | 跟單交易的權限 |
> BlockTrade | array | 大宗交易的權限. 子帳戶暫不支持,總是[] |
> Exchange | array | 兌換的權限 |
> NFT | array | NFT的權限. 子帳戶暫不支持, 總是[] |
請求示例
- HTTP
- Python
- Node.js
POST /v5/user/create-sub-api HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1676430005459
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"subuid": 53888000,
"note": "testxxx",
"readOnly": 0,
"permissions": {
"Wallet": [
"AccountTransfer"
]
}
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.create_sub_api_key(
subuid=53888000,
note="testxxx",
readOnly=0,
permissions={
"Wallet": [
"AccountTransfer"
]
},
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.createSubUIDAPIKey({
subuid: 53888000,
note: 'testxxx',
readOnly: 0,
permissions: {
Wallet: ['AccountTransfer'],
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "",
"result": {
"id": "16651283",
"note": "testxxx",
"apiKey": "xxxxx",
"readOnly": 0,
"secret": "xxxxxxxx",
"permissions": {
"ContractTrade": [],
"Spot": [],
"Wallet": [
"AccountTransfer"
],
"Options": [],
"Derivatives": [],
"CopyTrading": [],
"BlockTrade": [],
"Exchange": [],
"NFT": []
}
},
"retExtInfo": {},
"time": 1676430007643
}