Python Requests proxy
A Python Requests proxy is a Requests session that tunnels every HTTP and HTTPS call through an upstream proxy instead of the machine's public IP. Pass the Aethyn URL in username:password@host:port form on the proxies argument and each request exits from a real residential address.
Why a residential Python Requests proxy
Most of the web now scores datacenter ranges on sight: a script running from AWS, or from a single home connection in one country, either gets blocked or sees the wrong catalog, currency, and search results. Routing Requests through a residential proxy substitutes an ISP-assigned exit, so the destination treats the call as a consumer visit. Aethyn encodes country, city, and sticky-session targeting in the username, so the same proxies dict works for a one-off fetch and for a multi-step login. Rotation is the default — omit a session id and each requests.get() exits from a fresh IP. Add -session-<id>-lifetime-<minutes> when cookies or a cart must survive across calls. HTTPS needs no second endpoint: port 2099 tunnels CONNECT, so one URL covers both schemes. Timeouts belong on every call; residential paths are slower than datacenter, and an unbounded wait hides a dead exit as a hung worker.
Setup steps
- 1Install Requests with pip install requests.
- 2Grab your Aethyn username (aethyn-XXXXX) and password from the dashboard.
- 3Build the proxy URL and pass it to the proxies argument.
- 4Add targeting suffixes (e.g. -country-us) to the username as needed.
Code
import requests
proxy = "http://aethyn-XXXXX:PASSWORD@proxy.aethyn.io:2099"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
print(resp.json()) # each call exits from a fresh residential IPimport requests
# US exit held for ~10 minutes via a sticky session id
user = "aethyn-XXXXX-country-us-session-abc123-lifetime-10"
proxy = f"http://{user}:PASSWORD@proxy.aethyn.io:2099"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://example.com", proxies=proxies, timeout=30)
print(resp.status_code)# pip install requests[socks]
import requests
proxy = "socks5h://aethyn-XXXXX:PASSWORD@proxy.aethyn.io:1099"
proxies = {"http": proxy, "https": proxy}
resp = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
print(resp.json()) # socks5h = remote DNS, no local leakimport requests
from requests.exceptions import ProxyError, Timeout
proxy = "http://aethyn-XXXXX:PASSWORD@proxy.aethyn.io:2099"
session = requests.Session()
session.proxies = {"http": proxy, "https": proxy}
session.timeout = 30
try:
resp = session.get("https://httpbin.org/ip")
resp.raise_for_status()
print(resp.json())
except ProxyError as e:
# 407 = bad username/password or targeting suffix on the wrong field
print("proxy auth or tunnel failed:", e)
except Timeout:
print("exit did not respond in 30s — retry on a fresh IP")Replace aethyn-XXXXX and PASSWORD with your dashboard credentials. See the full targeting reference and protocol/port list. Or use the official proxy-builder-sdk to build targeting strings without hand-assembling usernames.
Troubleshooting
The three failures that show up first with a Python Requests proxy are 407 Proxy Authentication Required, hanging connects, and HTTPS errors that look like SSL problems. A 407 means the username or password is wrong, or a targeting suffix was pasted into the password field — rebuild the URL from the dashboard and confirm the -country- / -session- tokens sit on the username. Hanging connects almost always mean a missing timeout; set timeout=30 on the call or on the Session so a dead exit fails instead of blocking the worker. If HTTP works but HTTPS raises ProxyError or SSLError, the client is not sending CONNECT through the HTTP proxy port: use the same http:// URL for both keys in the proxies dict, not an https:// proxy URL. SOCKS5 (port 1099) needs requests[socks] installed; without PySocks, Requests will ignore a socks5:// URL or throw immediately.
Tips
- Always set a timeout — residential routes are slower than datacenter.
- Reuse a requests.Session() for connection pooling across many requests.
- Use a sticky session when a flow spans multiple requests (login, checkout).
- Prefer socks5h:// over socks5:// so DNS resolves at the proxy, not locally.