feat(v4.0.2): Add full support for P2P trading
This commit is contained in:
18
examples/apidoc/V5/P2P/get-account-information.js
Normal file
18
examples/apidoc/V5/P2P/get-account-information.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2PUserInfo()
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
23
examples/apidoc/V5/P2P/get-ad-detail.js
Normal file
23
examples/apidoc/V5/P2P/get-ad-detail.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
itemId: '1898988222063644672', // Replace with your ad ID
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2PAdDetail(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
29
examples/apidoc/V5/P2P/get-all-orders.js
Normal file
29
examples/apidoc/V5/P2P/get-all-orders.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
status: null, // Optional: filter by order status
|
||||
beginTime: null, // Optional: filter by start time
|
||||
endTime: null, // Optional: filter by end time
|
||||
tokenId: null, // Optional: filter by token ID
|
||||
side: null, // Optional: filter by side (0: Buy, 1: Sell)
|
||||
page: 1, // Required: page number
|
||||
size: 1, // Required: rows per page
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2POrders(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
25
examples/apidoc/V5/P2P/get-chat-message.js
Normal file
25
examples/apidoc/V5/P2P/get-chat-message.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
orderId: '1898976123321221120', // Replace with your order ID
|
||||
size: '1', // Number of messages per page
|
||||
currentPage: '1', // Optional: current page number
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2POrderMessages(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
21
examples/apidoc/V5/P2P/get-coin-balance.js
Normal file
21
examples/apidoc/V5/P2P/get-coin-balance.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Create a client
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'XXXXX',
|
||||
secret: 'XXXXX',
|
||||
});
|
||||
|
||||
// Get account coins balance
|
||||
client
|
||||
.getP2PAccountCoinsBalance({
|
||||
accountType: 'FUND',
|
||||
coin: 'USDC',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
24
examples/apidoc/V5/P2P/get-counterparty-user-info.js
Normal file
24
examples/apidoc/V5/P2P/get-counterparty-user-info.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
originalUid: '290118', // Replace with the counterparty user ID
|
||||
orderId: '1900004704665923584', // Replace with your order ID
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2PCounterpartyUserInfo(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
22
examples/apidoc/V5/P2P/get-market-online-ads-list.js
Normal file
22
examples/apidoc/V5/P2P/get-market-online-ads-list.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Create a client
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'XXXXX',
|
||||
secret: 'XXXXX',
|
||||
});
|
||||
|
||||
// Get market online ads list
|
||||
client
|
||||
.getP2POnlineAds({
|
||||
tokenId: 'USDT',
|
||||
currencyId: 'USD',
|
||||
side: '0', // 0: buy; 1: sell
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
28
examples/apidoc/V5/P2P/get-my-ads-list.js
Normal file
28
examples/apidoc/V5/P2P/get-my-ads-list.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET'
|
||||
});
|
||||
|
||||
// Example parameters for getting personal P2P ads
|
||||
const params = {
|
||||
itemId: '123456789', // Optional: Specific advertisement ID
|
||||
status: 1, // Optional: Advertisement status (1: active, 2: completed, 3: cancelled)
|
||||
side: 1, // Optional: 0: buy; 1: sell
|
||||
tokenId: 'USDT', // Optional: Token ID
|
||||
page: 1, // Optional: Page number
|
||||
size: 20, // Optional: Page size
|
||||
currencyId: 'USD' // Optional: Currency ID
|
||||
};
|
||||
|
||||
// Get personal P2P ads
|
||||
client.getP2PPersonalAds(params)
|
||||
.then(response => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
23
examples/apidoc/V5/P2P/get-order-detail.js
Normal file
23
examples/apidoc/V5/P2P/get-order-detail.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
orderId: '1900004704665923584', // Replace with your order ID
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2POrderDetail(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
29
examples/apidoc/V5/P2P/get-pending-orders.js
Normal file
29
examples/apidoc/V5/P2P/get-pending-orders.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
status: 10, // waiting for buy pay
|
||||
beginTime: '1741831397000', // Optional: filter by start time
|
||||
endTime: '1741831424861', // Optional: filter by end time
|
||||
tokenId: 'USDT', // Optional: filter by token
|
||||
side: [0, 1], // Optional: filter by side (0: Buy, 1: Sell)
|
||||
page: 1,
|
||||
size: 3,
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2PPendingOrders(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
18
examples/apidoc/V5/P2P/get-user-payment.js
Normal file
18
examples/apidoc/V5/P2P/get-user-payment.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.getP2PUserPayments()
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
25
examples/apidoc/V5/P2P/mark-order-as-paid.js
Normal file
25
examples/apidoc/V5/P2P/mark-order-as-paid.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
orderId: '1899736339155943424', // Replace with your order ID
|
||||
paymentType: '14', // Payment method used
|
||||
paymentId: '7110', // Payment method ID used
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.markP2POrderAsPaid(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
47
examples/apidoc/V5/P2P/post-new-ad.js
Normal file
47
examples/apidoc/V5/P2P/post-new-ad.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Create a client
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'XXXXX',
|
||||
secret: 'XXXXX',
|
||||
});
|
||||
|
||||
// Create new P2P advertisement
|
||||
client
|
||||
.createP2PAd({
|
||||
tokenId: 'USDT',
|
||||
currencyId: 'EUR',
|
||||
side: '0',
|
||||
priceType: '0',
|
||||
premium: '',
|
||||
price: '0.92',
|
||||
minAmount: '20',
|
||||
maxAmount: '45000',
|
||||
paymentIds: ['7110'],
|
||||
remark: 'test',
|
||||
tradingPreferenceSet: {
|
||||
isKyc: 1,
|
||||
hasCompleteRateDay30: 1,
|
||||
completeRateDay30: '95',
|
||||
hasOrderFinishNumberDay30: 1,
|
||||
hasRegisterTime: 0,
|
||||
hasUnPostAd: 0,
|
||||
isEmail: 0,
|
||||
isMobile: 0,
|
||||
nationalLimit: '',
|
||||
orderFinishNumberDay30: 60,
|
||||
registerTimeThreshold: 0,
|
||||
verificationOrderLabels: [],
|
||||
verificationOrderSwitch: false,
|
||||
},
|
||||
quantity: '20000',
|
||||
paymentPeriod: '15',
|
||||
itemType: 'ORIGIN',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
23
examples/apidoc/V5/P2P/release-digital-asset.js
Normal file
23
examples/apidoc/V5/P2P/release-digital-asset.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
orderId: '1899736339155943424', // Replace with your order ID
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.releaseP2POrder(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
20
examples/apidoc/V5/P2P/remove-my-ad.js
Normal file
20
examples/apidoc/V5/P2P/remove-my-ad.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Create a client
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'XXXXX',
|
||||
secret: 'XXXXX',
|
||||
});
|
||||
|
||||
// Cancel P2P advertisement
|
||||
client
|
||||
.cancelP2PAd({
|
||||
itemId: '1899667660027793408',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
28
examples/apidoc/V5/P2P/send-chat-message.js
Normal file
28
examples/apidoc/V5/P2P/send-chat-message.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Example parameters
|
||||
const params = {
|
||||
message: 'hi, test',
|
||||
contentType: 'text',
|
||||
orderId: '1898976123321221120', // Replace with your order ID
|
||||
// Optional parameters:
|
||||
// msgUuid: 'your-message-uuid',
|
||||
// fileName: 'example.pdf'
|
||||
};
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.sendP2POrderMessage(params)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
34
examples/apidoc/V5/P2P/update-relist-my-ad.js
Normal file
34
examples/apidoc/V5/P2P/update-relist-my-ad.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
|
||||
// Create a client
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'XXXXX',
|
||||
secret: 'XXXXX',
|
||||
});
|
||||
|
||||
// Update P2P advertisement
|
||||
client
|
||||
.updateP2PAd({
|
||||
id: '1898988222063644672',
|
||||
priceType: '0',
|
||||
premium: '',
|
||||
price: '0.914',
|
||||
minAmount: '25',
|
||||
maxAmount: '5000',
|
||||
remark: '',
|
||||
paymentIds: ['-1'],
|
||||
tradingPreferenceSet: {},
|
||||
actionType: 'ACTIVE',
|
||||
quantity: '1000',
|
||||
paymentPeriod: '15',
|
||||
itemType: 'ORIGIN',
|
||||
subsidyAd: false,
|
||||
securityRiskToken: '',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
24
examples/apidoc/V5/P2P/upload-chat-file.js
Normal file
24
examples/apidoc/V5/P2P/upload-chat-file.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { RestClientV5 } = require('bybit-api');
|
||||
const fs = require('fs');
|
||||
const FormData = require('form-data');
|
||||
|
||||
// Initialize the client with testnet mode
|
||||
const client = new RestClientV5({
|
||||
testnet: true,
|
||||
key: 'YOUR_API_KEY',
|
||||
secret: 'YOUR_API_SECRET',
|
||||
});
|
||||
|
||||
// Create form data
|
||||
const formData = new FormData();
|
||||
formData.append('upload_file', fs.createReadStream('path/to/your/file.jpg')); // Replace with your file path
|
||||
|
||||
// Call the function
|
||||
client
|
||||
.uploadP2PChatFile(formData)
|
||||
.then((response) => {
|
||||
console.log('Response:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
Reference in New Issue
Block a user