ByBit API: Internal Subaccount Transfers
planned
This post was marked as
planned
S
Sienna Llama
Here's a simple code example to test this. You must specify a date range that captures the example transaction. You will get the type
"type": "TRANSFER_OUT"
or "type": "TRANSFER_IN"
require('dotenv').config()
const { RestClientV5 } = require('bybit-api')
const fs = require('fs')
const path = require('path')
const client = new RestClientV5({
testnet: false,
key: process.env.BYBIT_API_KEY,
secret: process.env.BYBIT_API_SECRET,
})
// Create output directory if it doesn't exist
const outputDir = 'bybit_transactions'
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir)
}
client
.getTransactionLog({
// These parameters are not required for the transaction log endpoint
// accountType: 'UNIFIED',
// category: 'inverse',
startTime: new Date('2025-06-05T00:00:00Z').getTime(),
endTime: new Date('2025-06-11T00:00:00Z').getTime(),
})
.then((response) => {
console.log(response)
// Write to file
const timestamp = Date.now()
const filename = path.join(outputDir, `transactions_${timestamp}.json`)
fs.writeFileSync(filename, JSON.stringify(response, null, 2), 'utf8')
console.log(`\nTransaction log saved to: ${filename}`)
if (response.retCode === 0 && response.result && response.result.list) {
console.log(`Found ${response.result.list.length} transactions`)
}
})
.catch((error) => {
console.error(error)
})