From f739ec85503f158d9a089866f67186ad7e10f5a4 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Fri, 9 Jun 2023 12:07:10 +0100 Subject: [PATCH] feat(): add asset samples --- examples/apidoc/V5/Asset/README.md | 3 +++ examples/apidoc/V5/Asset/cancel-withdrawal.js | 16 +++++++++++++ .../V5/Asset/create-internal-transfer.js | 22 +++++++++++++++++ .../V5/Asset/create-universal-transfer.js | 24 +++++++++++++++++++ .../enable-universal-transfer-for-sub-uid.js | 16 +++++++++++++ .../apidoc/V5/Asset/get-all-coins-balance.js | 16 +++++++++++++ .../V5/Asset/get-allowed-deposit-coin-info.js | 19 +++++++++++++++ .../apidoc/V5/Asset/get-asset-info-spot.js | 16 +++++++++++++ .../V5/Asset/get-coin-exchange-records.js | 16 +++++++++++++ examples/apidoc/V5/Asset/get-coin-info.js | 16 +++++++++++++ .../apidoc/V5/Asset/get-delivery-record.js | 16 +++++++++++++ .../apidoc/V5/Asset/get-deposit-records.js | 18 ++++++++++++++ .../V5/Asset/get-internal-deposit-records.js | 19 +++++++++++++++ .../V5/Asset/get-internal-transfer-records.js | 19 +++++++++++++++ .../V5/Asset/get-master-deposit-address.js | 16 +++++++++++++ .../V5/Asset/get-single-coin-balance.js | 16 +++++++++++++ .../V5/Asset/get-sub-deposit-address.js | 16 +++++++++++++ .../V5/Asset/get-sub-deposit-records.js | 20 ++++++++++++++++ examples/apidoc/V5/Asset/get-sub-uid.js | 16 +++++++++++++ .../apidoc/V5/Asset/get-transferable-coin.js | 16 +++++++++++++ .../Asset/get-universal-transfer-records.js | 19 +++++++++++++++ .../V5/Asset/get-usdc-session-settlement.js | 16 +++++++++++++ .../V5/Asset/get-withdrawable-amount.js | 18 ++++++++++++++ .../apidoc/V5/Asset/get-withdrawal-records.js | 20 ++++++++++++++++ .../apidoc/V5/Asset/set-deposit-account.js | 18 ++++++++++++++ examples/apidoc/V5/Asset/withdraw.js | 24 +++++++++++++++++++ 26 files changed, 451 insertions(+) create mode 100644 examples/apidoc/V5/Asset/README.md create mode 100644 examples/apidoc/V5/Asset/cancel-withdrawal.js create mode 100644 examples/apidoc/V5/Asset/create-internal-transfer.js create mode 100644 examples/apidoc/V5/Asset/create-universal-transfer.js create mode 100644 examples/apidoc/V5/Asset/enable-universal-transfer-for-sub-uid.js create mode 100644 examples/apidoc/V5/Asset/get-all-coins-balance.js create mode 100644 examples/apidoc/V5/Asset/get-allowed-deposit-coin-info.js create mode 100644 examples/apidoc/V5/Asset/get-asset-info-spot.js create mode 100644 examples/apidoc/V5/Asset/get-coin-exchange-records.js create mode 100644 examples/apidoc/V5/Asset/get-coin-info.js create mode 100644 examples/apidoc/V5/Asset/get-delivery-record.js create mode 100644 examples/apidoc/V5/Asset/get-deposit-records.js create mode 100644 examples/apidoc/V5/Asset/get-internal-deposit-records.js create mode 100644 examples/apidoc/V5/Asset/get-internal-transfer-records.js create mode 100644 examples/apidoc/V5/Asset/get-master-deposit-address.js create mode 100644 examples/apidoc/V5/Asset/get-single-coin-balance.js create mode 100644 examples/apidoc/V5/Asset/get-sub-deposit-address.js create mode 100644 examples/apidoc/V5/Asset/get-sub-deposit-records.js create mode 100644 examples/apidoc/V5/Asset/get-sub-uid.js create mode 100644 examples/apidoc/V5/Asset/get-transferable-coin.js create mode 100644 examples/apidoc/V5/Asset/get-universal-transfer-records.js create mode 100644 examples/apidoc/V5/Asset/get-usdc-session-settlement.js create mode 100644 examples/apidoc/V5/Asset/get-withdrawable-amount.js create mode 100644 examples/apidoc/V5/Asset/get-withdrawal-records.js create mode 100644 examples/apidoc/V5/Asset/set-deposit-account.js create mode 100644 examples/apidoc/V5/Asset/withdraw.js diff --git a/examples/apidoc/V5/Asset/README.md b/examples/apidoc/V5/Asset/README.md new file mode 100644 index 0000000..0db2dd7 --- /dev/null +++ b/examples/apidoc/V5/Asset/README.md @@ -0,0 +1,3 @@ +# V5 - REST - Asset + +https://bybit-exchange.github.io/docs/v5/asset/exchange diff --git a/examples/apidoc/V5/Asset/cancel-withdrawal.js b/examples/apidoc/V5/Asset/cancel-withdrawal.js new file mode 100644 index 0000000..96fbdc4 --- /dev/null +++ b/examples/apidoc/V5/Asset/cancel-withdrawal.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .cancelWithdrawal('10197') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/create-internal-transfer.js b/examples/apidoc/V5/Asset/create-internal-transfer.js new file mode 100644 index 0000000..57aacda --- /dev/null +++ b/examples/apidoc/V5/Asset/create-internal-transfer.js @@ -0,0 +1,22 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .createInternalTransfer( + '42c0cfb0-6bca-c242-bc76-4e6df6cbcb16', + 'BTC', + '0.05', + 'UNIFIED', + 'CONTRACT', + ) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/create-universal-transfer.js b/examples/apidoc/V5/Asset/create-universal-transfer.js new file mode 100644 index 0000000..ba994cd --- /dev/null +++ b/examples/apidoc/V5/Asset/create-universal-transfer.js @@ -0,0 +1,24 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .createUniversalTransfer({ + transferId: 'be7a2462-1138-4e27-80b1-62653f24925e', + coin: 'ETH', + amount: '0.5', + fromMemberId: 592334, + toMemberId: 691355, + fromAccountType: 'CONTRACT', + toAccountType: 'UNIFIED', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/enable-universal-transfer-for-sub-uid.js b/examples/apidoc/V5/Asset/enable-universal-transfer-for-sub-uid.js new file mode 100644 index 0000000..d6f4f4b --- /dev/null +++ b/examples/apidoc/V5/Asset/enable-universal-transfer-for-sub-uid.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .enableUniversalTransferForSubUIDs(['554117', '592324', '592334']) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-all-coins-balance.js b/examples/apidoc/V5/Asset/get-all-coins-balance.js new file mode 100644 index 0000000..455595d --- /dev/null +++ b/examples/apidoc/V5/Asset/get-all-coins-balance.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getAllCoinsBalance({ accountType: 'FUND', coin: 'USDC' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-allowed-deposit-coin-info.js b/examples/apidoc/V5/Asset/get-allowed-deposit-coin-info.js new file mode 100644 index 0000000..808469d --- /dev/null +++ b/examples/apidoc/V5/Asset/get-allowed-deposit-coin-info.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getAllowedDepositCoinInfo({ + coin:"ETH", + chain:"ETH", + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-asset-info-spot.js b/examples/apidoc/V5/Asset/get-asset-info-spot.js new file mode 100644 index 0000000..adc216f --- /dev/null +++ b/examples/apidoc/V5/Asset/get-asset-info-spot.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getAssetInfo({ accountType: 'FUND', coin: 'USDC' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-coin-exchange-records.js b/examples/apidoc/V5/Asset/get-coin-exchange-records.js new file mode 100644 index 0000000..015df21 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-coin-exchange-records.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getCoinExchangeRecords({ limit: 10 }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-coin-info.js b/examples/apidoc/V5/Asset/get-coin-info.js new file mode 100644 index 0000000..b90423c --- /dev/null +++ b/examples/apidoc/V5/Asset/get-coin-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getCoinInfo('ETH') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-delivery-record.js b/examples/apidoc/V5/Asset/get-delivery-record.js new file mode 100644 index 0000000..a89a185 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-delivery-record.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getDeliveryRecord({ category: 'option', expDate: '29DEC22' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-deposit-records.js b/examples/apidoc/V5/Asset/get-deposit-records.js new file mode 100644 index 0000000..808ed02 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-deposit-records.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getDepositRecords({ + coin: 'USDT' + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-internal-deposit-records.js b/examples/apidoc/V5/Asset/get-internal-deposit-records.js new file mode 100644 index 0000000..f02005c --- /dev/null +++ b/examples/apidoc/V5/Asset/get-internal-deposit-records.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInternalDepositRecords({ + startTime: 1667260800000, + endTime: 1667347200000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-internal-transfer-records.js b/examples/apidoc/V5/Asset/get-internal-transfer-records.js new file mode 100644 index 0000000..31fddcd --- /dev/null +++ b/examples/apidoc/V5/Asset/get-internal-transfer-records.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInternalTransferRecords({ + coin: 'USDT', + limit: 1, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-master-deposit-address.js b/examples/apidoc/V5/Asset/get-master-deposit-address.js new file mode 100644 index 0000000..99fb6d0 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-master-deposit-address.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getMasterDepositAddress('USDT', 'ETH') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-single-coin-balance.js b/examples/apidoc/V5/Asset/get-single-coin-balance.js new file mode 100644 index 0000000..455595d --- /dev/null +++ b/examples/apidoc/V5/Asset/get-single-coin-balance.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getAllCoinsBalance({ accountType: 'FUND', coin: 'USDC' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-sub-deposit-address.js b/examples/apidoc/V5/Asset/get-sub-deposit-address.js new file mode 100644 index 0000000..a2df206 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-sub-deposit-address.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSubDepositAddress('USDT', 'TRX', '592334') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-sub-deposit-records.js b/examples/apidoc/V5/Asset/get-sub-deposit-records.js new file mode 100644 index 0000000..b474286 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-sub-deposit-records.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSubAccountDepositRecords({ + coin: 'USDT', + limit: 1, + subMemberId: '592334', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-sub-uid.js b/examples/apidoc/V5/Asset/get-sub-uid.js new file mode 100644 index 0000000..7a42c8f --- /dev/null +++ b/examples/apidoc/V5/Asset/get-sub-uid.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSubUID() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-transferable-coin.js b/examples/apidoc/V5/Asset/get-transferable-coin.js new file mode 100644 index 0000000..224a9cf --- /dev/null +++ b/examples/apidoc/V5/Asset/get-transferable-coin.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getTransferableCoinList('UNIFIED', 'CONTRACT') + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-universal-transfer-records.js b/examples/apidoc/V5/Asset/get-universal-transfer-records.js new file mode 100644 index 0000000..8d2f3fc --- /dev/null +++ b/examples/apidoc/V5/Asset/get-universal-transfer-records.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getUniversalTransferRecords({ + limit: 1, + cursor: 'eyJtaW5JRCI6MTc5NjU3OCwibWF4SUQiOjE3OTY1Nzh9', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-usdc-session-settlement.js b/examples/apidoc/V5/Asset/get-usdc-session-settlement.js new file mode 100644 index 0000000..d97ea87 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-usdc-session-settlement.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSettlementRecords({ category: 'linear' }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-withdrawable-amount.js b/examples/apidoc/V5/Asset/get-withdrawable-amount.js new file mode 100644 index 0000000..50bd142 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-withdrawable-amount.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getWithdrawableAmount({ + coin: 'USDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-withdrawal-records.js b/examples/apidoc/V5/Asset/get-withdrawal-records.js new file mode 100644 index 0000000..06d8a04 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-withdrawal-records.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getWithdrawalRecords({ + coin: 'USDT', + withdrawType: 2, + limit: 2, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/set-deposit-account.js b/examples/apidoc/V5/Asset/set-deposit-account.js new file mode 100644 index 0000000..def8454 --- /dev/null +++ b/examples/apidoc/V5/Asset/set-deposit-account.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .setDepositAccount({ + accountType: 'CONTRACT' + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/withdraw.js b/examples/apidoc/V5/Asset/withdraw.js new file mode 100644 index 0000000..49ddeb7 --- /dev/null +++ b/examples/apidoc/V5/Asset/withdraw.js @@ -0,0 +1,24 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .submitWithdrawal({ + coin: 'USDT', + chain: 'ETH', + address: '0x99ced129603abc771c0dabe935c326ff6c86645d', + amount: '24', + timestamp: 1672196561407, + forceChain: 0, + accountType: 'FUND', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + });