Iām trying to create a Telegram buy bot where if there is a purchase of a token on DEXtools.io it will send a message in Telegram. Iām getting a 404 error even though I have the right API keys and end point URL
The output should be like this:
"New VEXT Buy!
Order size:
Current price:
Market Cap: $
Fully Diluted Market Cap: $"
const axios = require('axios');
const AxiosRateLimit = require('axios-rate-limit');
// DEXtools API key
const DEX_API_KEY = '';
// DEXtools API endpoint base URL
const DEX_API_BASE_URL = 'https://api.dextools.io/v1/pair/';
const PAIR_ADDRESS = '';
// Create an axios instance with rate limiting (1 request per minute)
const axiosInstance = AxiosRateLimit(axios.create(), { maxRequests: 1, perMilliseconds: 60000 });
axiosInstance.defaults.headers.common['X-API-Key'] = DEX_API_KEY;
// Function to retrieve pair data from DEXtools API
async function getPairData() {
try {
const response = await axiosInstance.get(`${DEX_API_BASE_URL}${PAIR_ADDRESS}`);
if (response.status === 200) {
return response.data;
} else {
console.error('Error: Unable to fetch pair data - Status:', response.status);
return null;
}
} catch (error) {
console.error('Error:', error.message);
return null;
}
}
// Main function to execute the workflow
async function main() {
const pairData = await getPairData();
if (pairData) {
// Extract relevant data from pairData and format the message
const order_size = pairData.metrics.reserve;
const current_price = pairData.metrics.reserveRef;
const market_cap = pairData.metrics.liquidity;
const fully_diluted_market_cap = pairData.dextScore.total;
// Create the message template
const message = `New VEXT Buy!
šššš
šµ Order size: ${order_size} VEXT
šŖ Current price: $${current_price}
š¼ Market Cap: $${market_cap}
ā« Fully Diluted Market Cap: $${fully_diluted_market_cap}`;
// Log the message
console.log('Message:', message);
// Send the message to your Telegram group (you should implement this part)
}
}
// Execute the main function
main();