feat(): add new v5 user endpoints. add user examples.

This commit is contained in:
tiagosiebler
2023-06-09 14:21:36 +01:00
parent f739ec8550
commit 987b3f81d0
13 changed files with 239 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# V5 - REST - User
https://bybit-exchange.github.io/docs/v5/user/create-subuid

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View File

@@ -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.
*

View File

@@ -172,6 +172,8 @@ export interface PermissionsV5 {
Wallet?: string[];
Options?: string[];
Derivatives?: string[];
CopyTrading?: string[];
BlockTrade?: string[];
Exchange?: string[];
NFT?: string[];
}