I’m trying to make any api call in test network but i’m unable to connect to do so.
Generated keys from https://testnet.binance.vision/.
Error: Invalid API-key, IP, or permissions for action.
at\bot\node_modules\binance-api-node\dist\http-client.js:102:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: -2015,
url: ‘https://api.binance.com/api/v3/order?type=MARKET&symbol=BTCUSDT&side=BUY&quantity=1×tamp=1684499433895&signature=5c264b5942fe36767977d8d591e558da894fa3640ba86a3464517c3e230ac2cd’}
const Binance = require('binance-api-node').default;
// Replace with your Binance API key
const client = Binance({
apiKey: 'key from testnet.binance.vision',
apiSecret: 'secret from testnet.binance.vision',
test: true, // Use the Binance Testnet
verbose: true,
urls: {
base: 'https://testnet.binance.vision/api/',
combineStream: 'wss://testnet.binance.vision/stream?streams=',
stream: 'wss://testnet.binance.vision/ws/'
}
})
// Replace with the symbol of the spot market you want to buy
const symbol = 'BTCUSDT';
// Replace with the quantity of the spot market you want to buy
const quantity = 1;
client.order({
symbol: symbol,
side: 'BUY',
type: 'MARKET',
quantity: quantity
})
.then((response) => {
console.log(response);
// Handle success
})
.catch((error) => {
console.error(error);
// Handle error
});