Python and Node.js Proxy Examples

When integrating MaskProxy, start with a minimal runnable example. Confirm host, port, auth, and egress IP before production code.

Python requests example

import requests

proxy = "http://username:password@host:port"
proxies = {
    "http": proxy,
    "https": proxy,
}

resp = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=20)
print(resp.status_code)
print(resp.text)

Add retries, timeouts, and exception handling for stability. Do not commit proxy passwords to git — read them from environment variables.

Node.js example

Native fetch does not cover every proxy case; use a mature proxy agent. Basic idea:

import fetch from "node-fetch";
import { HttpsProxyAgent } from "https-proxy-agent";

const proxyUrl = "http://username:password@host:port";
const agent = new HttpsProxyAgent(proxyUrl);

const res = await fetch("https://api.ipify.org?format=json", { agent });
console.log(await res.text());

Example host/port shape: gw.maskproxy.io / 1288 (always follow My Proxy).

Security tips

  • Keep host, username, and password in env vars or a secure store.
  • Set sensible request timeouts so jobs do not hang forever.
  • Start with a small request batch, then raise concurrency.

Once the minimal example returns a stable egress IP, reuse the same config in scrapers, automation, or data pipelines.

Powered by MaskProxy