Hi there!
Im trying to make convert like in this page: https://www.binance.com/ru/convert/USDT/USDC
.
import 'dotenv/config';
import * as ccxt from 'ccxt';
const { API_KEY = '', SECRET_KEY = '' } = process.env;
async function convertAssets() {
const exchange = new ccxt.binance({
apiKey: API_KEY,
secret: SECRET_KEY,
});
const fromAsset = 'USDT';
const toAsset = 'USDC';
const amount = 5;
try {
const quote = await exchange.fetchConvertQuote(fromAsset, toAsset, amount);
console.log('Quote:', quote);
const trade = await exchange.createConvertTrade(quote.id, fromAsset, toAsset, amount);
console.log('Exchange result:', trade);
} catch (error) {
console.error('Error:', error);
}
}
convertAssets();
But i got an error:
Ошибка: PermissionDenied: binance You are not authorized to execute this request.
at binance.throwExactlyMatchedException (file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/base/Exchange.js:4907:19)
at binance.handleErrors (file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/binance.js:12183:18)
at file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/base/Exchange.js:747:51
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async binance.fetch2 (file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/base/Exchange.js:4427:24)
at async binance.request (file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/binance.js:12254:26)
at async binance.fetchConvertQuote (file:///home/mvsolovyev/Desktop/Work/binance-api/node_modules/ccxt/js/src/binance.js:13924:26)
at async convertAssets (file:///home/mvsolovyev/Desktop/Work/binance-api/src/simple-convert.ts:19:19)
I checked all the boxes in the API key settings and added the IP address, but there is still no access. Is it issued separately? And if so, how can I get it?