Integrations
Using proxies in code
Working examples for the common HTTP clients. Replace USER, PASS, HOST and PORT with the values from your order, or with a residential line from the generator.
Updated 16 October 2026
HTTP and HTTPS#
curl -x http://USER:PASS@HOST:PORT https://api.ipify.orgSOCKS5#
On ISP and datacenter the SOCKS5 port is the HTTP port plus one. On residential use a SOCKS5 port such as 1080.
curl -x socks5h://USER:PASS@HOST:PORT https://api.ipify.orgPython#
requests with a session
A session reuses connections, so through a login or a checkout the target keeps seeing the same IP and the same TLS handshake.
import requests
proxy = "http://USER:PASS@HOST:PORT"
s = requests.Session()
s.proxies = {"http": proxy, "https": proxy}
for url in urls:
r = s.get(url, timeout=30)
print(r.status_code, len(r.content))httpx
# pip install httpx (SOCKS5: pip install "httpx[socks]")
import httpx
with httpx.Client(proxy="http://USER:PASS@HOST:PORT", timeout=30) as client:
print(client.get("https://api.ipify.org?format=json").json())aiohttp
import asyncio
import aiohttp
PROXY = "http://USER:PASS@HOST:PORT"
async def main():
async with aiohttp.ClientSession() as session:
async with session.get("https://api.ipify.org?format=json", proxy=PROXY) as r:
print(await r.json())
asyncio.run(main())aiohttp speaks only HTTP proxies by itself. For SOCKS5 add aiohttp-socks:
# pip install aiohttp-socks
import asyncio
import aiohttp
from aiohttp_socks import ProxyConnector
async def main():
connector = ProxyConnector.from_url("socks5://USER:PASS@HOST:PORT", rdns=True)
async with aiohttp.ClientSession(connector=connector) as session:
async with session.get("https://api.ipify.org?format=json") as r:
print(await r.json())
asyncio.run(main())Scrapy
Scrapy's built-in proxy middleware reads the proxy from meta and sends the credentials from the URL. With a rotating residential line every request leaves from a new address on its own.
# spider.py
import scrapy
class IpSpider(scrapy.Spider):
name = "ip"
def start_requests(self):
for _ in range(3):
yield scrapy.Request(
"https://api.ipify.org?format=json",
meta={"proxy": "http://USER:PASS@HOST:PORT"},
dont_filter=True,
)
def parse(self, response):
yield response.json()Node.js#
axios
axios has its own proxy option, but it does not tunnel HTTPS reliably. Give it an agent instead and switch its own proxying off:
// npm install axios https-proxy-agent
import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent("http://USER:PASS@HOST:PORT");
const { data } = await axios.get("https://api.ipify.org?format=json", {
httpsAgent: agent,
proxy: false, // let the agent do the proxying
});
console.log(data);Timeouts and retries#
- Always set a timeout. 30 seconds suits most targets.
- Retry on connection errors, timeouts and
502,503,504, with a growing pause. Do not retry407: wrong credentials do not fix themselves. - On residential, a retry with a new sticky session lands on a new device. See sessions in code.
- Cap the attempts. An endless retry loop on a blocked target only burns traffic.
import time
import requests
def fetch(url: str, proxy: str, attempts: int = 3) -> requests.Response:
for i in range(attempts):
try:
r = requests.get(url, proxies={"http": proxy, "https": proxy}, timeout=30)
if r.status_code in (502, 503, 504):
raise requests.HTTPError(r.status_code)
return r
except (requests.ConnectionError, requests.Timeout, requests.HTTPError):
if i == attempts - 1:
raise
time.sleep(2 ** i) # 1 s, 2 s, 4 sDidn't find the answer?
Support answers in the chat on this site around the clock. On Telegram the reply usually comes fastest, and a ticket gets an answer by email.