Scripts and development
Use the proxy in Node.js
In Node.js 18+ fetch is built on undici: with its ProxyAgent you pass the HTTP proxy to every request. Install undici with npm install undici.
Step by step
- 1
Set the proxy protocol to HTTP in the client area.
- 2
Install undici and create a ProxyAgent with the proxy URL, username and password included.
- 3
Pass the agent to fetch with the dispatcher option.
- 4
For a new IP, call the rotation link and wait about 20 seconds.
JavaScript
import { fetch, ProxyAgent } from "undici";
const dispatcher = new ProxyAgent("http://USER:PASSWORD@HOST:PORT");
const ip = await (await fetch("https://api.ipify.org", { dispatcher })).text();
console.log(ip);
// New IP
await fetch("ROTATION_LINK");
await new Promise((r) => setTimeout(r, 20_000));Replace USER, PASSWORD, HOST and PORT with your proxy's data (client area › proxy › Connection).
Tips
- For SOCKS5 in Node.js you can use the socks-proxy-agent library with https or axios.
- Reuse the same ProxyAgent for all requests: it keeps connections open.
