Budget Proxies logo
Node.js

Send your first Node.js request through a proxy

Install axios and https-proxy-agent with npm, then save the file with a .mjs ending so its import lines run.

Three steps to see it working

First, buy a plan. Datacenter costs less than the other types, so it suits a first test. Second, copy four details from your dashboard: the host (the proxy server's name or IP address), the port (a number written after the host, with a colon in between), your username and your password. Third, paste them into the sample below. Your login replaces USERNAME and PASSWORD, while gateway.proxy:8080 stands in for your host and port, so swap yours in wherever those appear. Then run it. The sample asks a website which IP address it can see, and if the answer isn't your own IP, the proxy is doing its job. It relies on a library (ready-made code that sends web requests for you); the libraries listed further down need the same details, though each has its own place to put them. Keep in mind that a proxy only changes the address a site sees, so your script must still follow that site's terms and the law where you live.

Node.js
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";

const agent = new HttpsProxyAgent("http://USERNAME:[email protected]:8080");

const { data } = await axios.get("https://api.ipify.org?format=json", {
  httpAgent: agent,
  httpsAgent: agent,
});
console.log(data); // the proxy's exit IP

These libraries need the same four details

axios got node-fetch Puppeteer Playwright

Writing in a different language?