feat(): add new v5 user endpoints. add user examples.
This commit is contained in:
3
examples/apidoc/V5/User/README.md
Normal file
3
examples/apidoc/V5/User/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# V5 - REST - User
|
||||
|
||||
https://bybit-exchange.github.io/docs/v5/user/create-subuid
|
||||
23
examples/apidoc/V5/User/create-sub-uid-api-key.js
Normal file
23
examples/apidoc/V5/User/create-sub-uid-api-key.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
});
|
||||
21
examples/apidoc/V5/User/create-sub-uid.js
Normal file
21
examples/apidoc/V5/User/create-sub-uid.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.createSubMember({
|
||||
username: 'xxxxx',
|
||||
memberType: 1,
|
||||
switch: 1,
|
||||
note: 'test',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/delete-master-api-key.js
Normal file
16
examples/apidoc/V5/User/delete-master-api-key.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.deleteMasterApiKey()
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/delete-sub-api-key.js
Normal file
16
examples/apidoc/V5/User/delete-sub-api-key.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.deleteSubApiKey()
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/freeze-sub-uid.js
Normal file
16
examples/apidoc/V5/User/freeze-sub-uid.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.setSubUIDFrozenState(53888001, 1)
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/get-affiliate-user-info.js
Normal file
16
examples/apidoc/V5/User/get-affiliate-user-info.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.deleteSubApiKey()
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/get-api-key-info.js
Normal file
16
examples/apidoc/V5/User/get-api-key-info.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.getQueryApiKey()
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
16
examples/apidoc/V5/User/get-sub-uid-list.js
Normal file
16
examples/apidoc/V5/User/get-sub-uid-list.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'apikey',
|
||||
secret: 'apisecret',
|
||||
});
|
||||
|
||||
client
|
||||
.getSubUIDList()
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
29
examples/apidoc/V5/User/modify-master-api-key.js
Normal file
29
examples/apidoc/V5/User/modify-master-api-key.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
});
|
||||
30
examples/apidoc/V5/User/modify-sub-api-key.js
Normal file
30
examples/apidoc/V5/User/modify-sub-api-key.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
});
|
||||
@@ -1030,6 +1030,17 @@ export class RestClientV5 extends BaseRestClient {
|
||||
return this.get('/v5/asset/deposit/query-allowed-list', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto transfer account after deposit. The same function as the setting for Deposit on web GUI
|
||||
*/
|
||||
setDepositAccount(params: { accountType: AccountTypeV5 }): Promise<
|
||||
APIResponseV3WithTime<{
|
||||
status: 0 | 1;
|
||||
}>
|
||||
> {
|
||||
return this.postPrivate('/v5/asset/deposit/deposit-to-account', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query deposit records.
|
||||
*
|
||||
@@ -1091,6 +1102,21 @@ export class RestClientV5 extends BaseRestClient {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the deposit address information of SUB account.
|
||||
*/
|
||||
getSubDepositAddress(
|
||||
coin: string,
|
||||
chainType: string,
|
||||
subMemberId: string,
|
||||
): Promise<APIResponseV3WithTime<DepositAddressResultV5>> {
|
||||
return this.getPrivate('/v5/asset/deposit/query-sub-member-address', {
|
||||
coin,
|
||||
chainType,
|
||||
subMemberId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the deposit address information of SUB account.
|
||||
*
|
||||
@@ -1130,6 +1156,15 @@ export class RestClientV5 extends BaseRestClient {
|
||||
return this.getPrivate('/v5/asset/withdraw/query-record', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query withdrawable amount.
|
||||
*/
|
||||
getWithdrawableAmount(params: {
|
||||
coin: string;
|
||||
}): Promise<APIResponseV3<{ rows: WithdrawalRecordV5[] }>> {
|
||||
return this.getPrivate('/v5/asset/withdraw/withdrawable-amount', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraw assets from the SPOT account.
|
||||
*
|
||||
|
||||
@@ -172,6 +172,8 @@ export interface PermissionsV5 {
|
||||
Wallet?: string[];
|
||||
Options?: string[];
|
||||
Derivatives?: string[];
|
||||
CopyTrading?: string[];
|
||||
BlockTrade?: string[];
|
||||
Exchange?: string[];
|
||||
NFT?: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user