I'm trying to request Binance API https://api.binance.com/api/v3/ping in a NodeJS app in order to make some trades. I'm using axios to request the API
const testBinanceAPIResponseTime = async () => {
try {
await axios.get("https://api.binance.com/api/v3/ping");
} catch (err) {
throw new Error(err);
}
};
I added an interceptor to measure response time
axios.interceptors.request.use((x) => {
x.meta = x.meta || {};
x.meta.requestStartedAt = new Date().getTime();
return x;
});
axios.interceptors.response.use((x) => {
console.log(
`Execution time for: ${x.config.url} - ${
new Date().getTime() - x.config.meta.requestStartedAt
} ms`
);
return x;
});
My issue is the response time is always around 220 ms wether I deploy my code on Heroku EU or Heroku US. According to "documentation", requests from US should be a way faster (~ 10 ms) than EU since there is some Binance servers there. Is there a way to improve that response time by using another lib or another pattern?