Axios
Axios is one of the most popular HTTP client libraries for JavaScript. It works in both Node.js and browsers, making it a common choice for web scraping, API integration, and automation tasks with proxy support.
Setting Up HypeProxy.io with Axios
HTTP Proxy
const axios = require('axios');
const response = await axios.get('https://api.ipify.org?format=json', {
proxy: {
host: 'fr.hypeproxy.host',
port: YOUR_PORT,
auth: {
username: 'your_username',
password: 'your_password'
}
}
});
console.log(response.data);
SOCKS5 Proxy (with socks-proxy-agent)
const axios = require('axios');
const { SocksProxyAgent } = require('socks-proxy-agent');
const agent = new SocksProxyAgent(
'socks5://username:password@fr.hypeproxy.host:port'
);
const response = await axios.get('https://api.ipify.org?format=json', {
httpAgent: agent,
httpsAgent: agent
});
console.log(response.data);
With IP Rotation via API
const axios = require('axios');
const API_TOKEN = 'YOUR_API_TOKEN';
const PROXY_ID = 'YOUR_PROXY_ID';
// Rotate IP
await axios.get(
`https://api.hypeproxy.io/Utils/DirectRenewIp/${PROXY_ID}`,
{ headers: { 'Authorization': `Bearer ${API_TOKEN}` } }
);
// Wait for rotation
await new Promise(r => setTimeout(r, 5000));
// Make request through proxy
const response = await axios.get('https://example.com', {
proxy: {
host: 'fr.hypeproxy.host',
port: YOUR_PORT,
auth: { username: 'user', password: 'pass' }
}
});
Tips
- Use
axios.create()with proxy config to create a reusable client instance. - For SOCKS5 support, install the
socks-proxy-agentpackage. - Add retry logic with
axios-retryfor resilient scraping through proxies.
