修改子帳戶的API Key設置
修改子帳戶API key的設置, 支持母帳戶管理子帳戶key的設置, 或者子帳戶key直接修改本身。
提示
在調用接口時,使用的API key至少需要擁有以下其中一種權限
- 子API key: "Account Transfer(資產帳戶劃轉)", "Subaccount Transfer(母子帳戶劃轉)"
- 母API key: "Account Transfer(資產帳戶劃轉)", "Subaccount Transfer(母子帳戶劃轉)", "Withdrawal(提幣)"
HTTP 請求
POST /v5/user/update-sub-api
請求參數
參數 | 是否必須 | 類型 | 說明 |
---|---|---|---|
apikey | false | string | 子帳戶的api key
|
readOnly | false | integer | 0 (默認):可讀可寫. 1 :只讀 |
ips | false | string | 綁定IP. 比如: "192.168.0.1,192.168.0.2"注意:
|
permissions | false | 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 | 總是 "" |
permissions | Object | 權限類型 |
> ContractTrade | array | 合約交易的權限e |
> Spot | array | 現貨交易的權限 |
> Wallet | array | 錢包的權限 |
> Options | array | USDC合約的權限. 該權限支持USDC合約下的期權和永續交易 |
> Derivatives | array | 統一帳戶權限 |
> CopyTrading | array | 跟單交易的權限 |
> BlockTrade | array | 大宗交易的權限. 子帳戶暫不支持,總是[] |
> Exchange | array | 兌換的權限 |
> NFT | array | NFT的權限. 子帳戶暫不支持, 總是[] |
ips | array | IP綁定 |
請求示例
- HTTP
- Python
- Node.js
POST /v5/user/update-sub-api HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXXX
X-BAPI-API-KEY: XXXXXX
X-BAPI-TIMESTAMP: 1676431795752
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"readOnly": 0,
"ips": "*",
"permissions": {
"ContractTrade": [],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer"
],
"Options": [],
"CopyTrading": [],
"BlockTrade": [],
"Exchange": [],
"NFT": []
}
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.modify_sub_api_key(
readOnly=0,
ips=["*"],
permissions={
"ContractTrade": [],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer"
],
"Options": [],
"Derivatives": [],
"CopyTrading": [],
"BlockTrade": [],
"Exchange": [],
"NFT": []
}
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.updateSubApiKey({
readOnly: 0,
ips: ['*'],
permissions: {
ContractTrade: [],
Spot: ['SpotTrade'],
Wallet: ['AccountTransfer'],
Options: [],
Derivatives: [],
CopyTrading: [],
BlockTrade: [],
Exchange: [],
NFT: [],
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "",
"result": {
"id": "16651472",
"note": "testxxx",
"apiKey": "xxxxxx",
"readOnly": 0,
"secret": "",
"permissions": {
"ContractTrade": [],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer"
],
"Options": [],
"Derivatives": [],
"CopyTrading": [],
"BlockTrade": [],
"Exchange": [],
"NFT": []
},
"ips": [
"*"
]
},
"retExtInfo": {},
"time": 1676431796263
}