修改母帳戶的API Key設置
修改母帳戶API key的設置。使用待修改的api key調用接口。需使用母帳戶的API key。
提示
在調用接口時,使用的API key至少需要擁有以下其中一種權限
- 母API key: "Account Transfer(資產帳戶劃轉)", "Subaccount Transfer(母子帳戶劃轉)", "Withdrawal(提幣)"
信息
只能修改調用該接口的api key
HTTP 請求
POST /v5/user/update-api
請求參數
參數 | 是否必須 | 類型 | 說明 |
---|---|---|---|
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","SubMemberTransfer"] |
> Options | false | array | USDC合約. ["OptionsTrade"] |
> Derivatives | false | array | 統一帳戶權限. 該字段失效, 因為系統將會自動根據您的帳戶類型(經典帳戶和統一帳戶)來決定是否增加該權限 |
> CopyTrading | false | array | 跟單交易. ["CopyTrading"] |
> BlockTrade | false | array | 大宗商品交易. ["BlockTrade"] |
> Exchange | false | array | 兌換. ["ExchangeHistory"] |
> NFT | false | array | NFT. ["NFTQueryProductList"] |
> Affiliate | false | array | 代理商查詢權限. ["Affiliate"]
|
返回參數
參數 | 類型 | 說明 |
---|---|---|
id | string | 唯一id. 內部使用 |
note | string | 備註 |
apiKey | string | Api key |
readOnly | integer | 0 :可讀可寫. 1 :只讀 |
secret | string | 總是 "" |
permissions | Object | 權限類型 |
> ContractTrade | array | 合約交易的權限 |
> 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-api HTTP/1.1
Host: api.bybit.com
X-BAPI-API-KEY: XXXXXX
X-BAPI-TIMESTAMP: 1676431264739
X-BAPI-RECV-WINDOW: 5000
X-BAPI-SIGN: XXXXXX
Content-Type: application/json
{
"readOnly": null,
"ips": "*",
"permissions": {
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
}
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.modify_master_api_key(
ips=["*"],
permissions={
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
}
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.updateMasterApiKey({
ips: ['*'],
permissions: {
ContractTrade: ['Order', 'Position'],
Spot: ['SpotTrade'],
Wallet: ['AccountTransfer', 'SubMemberTransfer'],
Options: ['OptionsTrade'],
Derivatives: ['DerivativesTrade'],
CopyTrading: ['CopyTrading'],
BlockTrade: [],
Exchange: ['ExchangeHistory'],
NFT: ['NFTQueryProductList'],
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "",
"result": {
"id": "13770661",
"note": "xxxxx",
"apiKey": "xxxxx",
"readOnly": 0,
"secret": "",
"permissions": {
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"Derivatives": [
"DerivativesTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
},
"ips": [
"*"
]
},
"retExtInfo": {},
"time": 1676431265427
}