By GlobalProxyIP Editorial Team
To configure a residential proxy in Python, use the endpoint protocol and authentication supplied by the service. “Residential” describes the resource category, not a special Requests option or an automatic rotation rule.
An integration should separately verify resource documentation, target location, session behavior, and usable data. A changing exit alone does not prove residential origin or source authorization.
Configure location and session settings
Gleam's published guide describes a residential proxy generator with location, session, gateway, and output settings. It documents -A-, -T-, and -C- components for generated location and sticky-session usernames. Its Sticky wording retains the condition “when available.”
Keep the generated username intact instead of translating it into an invented cross-provider parameter.
Its FAQ states that services are unavailable to users in Mainland China and restricts government, financial, social media, and other sensitive targets. The example applies only to eligible users and permitted targets.
Observe a generated configuration
Use Python 3 and requests==2.34.2. For a documented HTTP username/password endpoint, set PROXY_HOST and PROXY_PORT, then enter the generated username. ECHO_URL must be a controlled endpoint returning exit_ip; this JSON field is our test contract.
import os
from getpass import getpass
from urllib.parse import quote
import requestshost, port = os.environ["PROXY_HOST"], int(os.environ["PROXY_PORT"])
user, password = input("Proxy username: "), getpass("Proxy password: ")
proxy = f"http://{quote(user, safe='')}:{quote(password, safe='')}@{host}:{port}"
proxies = {"http": proxy, "https": proxy}
with requests.Session() as session:
session.trust_env = False
for sample in range(3):
with session.get(os.environ["ECHO_URL"], proxies=proxies,
timeout=(5, 20), allow_redirects=False) as response:
response.raise_for_status()
if not 200 <= response.status_code < 300:
raise ValueError("Unexpected redirect")
data = response.json()
print(sample, data["exit_ip"])
Ambient proxy and CA settings are isolated; configure an approved CA bundle explicitly if required. Three samples are a connection observation, not a resource-quality study.
Give every observation a limited meaning
An echo response identifies the source observed at that endpoint. A network database label is evidence from that database, not conclusive proof of an actual household device or a lawful supply chain. Product sourcing and authorization documentation need separate review.
Location settings also need target-level validation. A gateway's region does not define the exit region, and a country code does not guarantee that every target or database will identify the address identically. For market data, inspect the actual language, currency, and region context.
Fit persistence to the workflow
Independent permitted reads may tolerate rotation. Multi-page workflows may need consistent cookies and an appropriate provider session. A Requests Session maintains client state, while exit availability remains a separate dependency.
If persistence breaks, pause the affected unit, inspect the generated configuration and intended duration, and recover through a permitted workflow boundary. Do not describe a short sticky observation as a static-IP guarantee. Select resources on demonstrated task fit rather than the residential label alone.
Frequently asked questions
Does residential mean per-request rotation?
No. Resource origin and rotation policy are separate properties.
Does a geo database prove household sourcing?
No. It provides a classification that needs context and does not independently establish sourcing authorization.
Is a sticky session a fixed-IP contract?
Not automatically. Apply the documented availability conditions and validate the intended workflow.
Related reading
- HTTP Cookies — Distinguish website session state from proxy exit selection.
- Proxy Authentication — Check access credentials independently of resource type.
- HTTP Connection Pooling — Understand why connection reuse and exit persistence are separate questions.
Sources
- Requests Advanced Usage — Proxies, Session Objects, Timeouts
- Requests Quickstart — JSON, status codes and errors
- Gleam Residential Proxy User Guide
- Gleam Help Center / FAQs
Sources reviewed on November 20, 2026.