Hello,
I need to get the wallet balance of the Binnace testnet account. I already registered and generated API and secret key from https://testnet.binance.vision/
Get balance wallet API endpoint: Binance API Documentation
My Code:
import crypto from 'crypto'
import axios from 'axios'
export const getbalance = () => {
const apiKey = process.env.BINANCE_API_KEY
const secretKey = process.env.BINANCE_SECRET_KEY
const apiUrl = 'https://testnet.binance.vision/sapi/v1/asset/wallet/balance'
const getwalletInfo = async () => {
try {
const timestamp = Date.now().toString()
const params = `recvWindow=5000×tamp=${timestamp}`
const signature = crypto
.createHmac('sha256', secretKey)
.update(params)
.digest('hex')
const config = {
headers: {
'X-MBX-APIKEY': apiKey,
},
}
console.log(`${apiUrl}?${params}&signature=${signature}`)
const response = await axios.get(
`${apiUrl}?${params}&signature=${signature}`,
{
params: config,
}
)
console.log('Account Info:', response.data)
} catch (error) {
console.log(error.message)
}
}
getwalletInfo()
}
Output:
Request failed with status code 404
Can I know what’s going on and how do I fix it?. Thank you.