Use a residential proxy in Python: requests setup and a first check

Put console host, port, protocol, and auth into Python requests. Use environment variables, verify the exit, then add rotation or sticky. Fake placeholders only. Console and Docs win. Not for mainland China.

Put console host, port, protocol, and auth into Python requests. Use environment variables, verify the exit, then add rotation or sticky. Fake placeholders only. Console and Docs win. Not for mainland China.

Copy protocol, host, port, and auth from the console, then put them in the client—do not guess a hostname or port. This page shows a first check with Python `requests`. String shapes: Proxy format. Protocol choice: HTTP / SOCKS5 setup. Step-by-step commands follow Docs EN quickstart.

ZTProxy sells rotating residential (per GB) and static residential (per IP·month). Every example uses fake placeholders—not production hosts. Lawful, authorized targets only. Not for mainland China.

What to have ready

  1. An order or extract entry in the console, with rotating or static already chosen (if not, read rotating vs static).
  2. The protocol, host, port, username, and password (or equivalent) the console returns.
  3. Python 3 and `requests` installed.
  4. An HTTPS check URL you are allowed to call. Do not load-test sites you do not have rights to.
Ready itemSource
Protocol, host, port, authConsole values only (not the fake placeholders)
Python 3 and requestsYour local environment
Check URLAn HTTPS target you may access
Rotating or static orderRotating vs static

Placeholders (not production): host `proxy.example.invalid`, port `10000`, user `USER_EXAMPLE`, password `PASS_EXAMPLE_NOT_REAL`.

requests with an HTTP proxy

HTTPS sites usually go through an HTTP proxy via `CONNECT`. Set both `http` and `https` keys in `proxies` to the same proxy URL, or some requests will leave from your own IP. Keep credentials in environment variables, not in git.

```python import os from urllib.parse import quote

import requests

user = quote(os.environ["ZT_PROXY_USER"], safe="") password = quote(os.environ["ZT_PROXY_PASS"], safe="") # Host and port come from the console—not from these fake defaults host = os.environ.get("ZT_PROXY_HOST", "proxy.example.invalid") port = os.environ.get("ZT_PROXY_PORT", "10000") proxy_url = f"http://{user}:{password}@{host}:{port}" proxies = {"http": proxy_url, "https": proxy_url}

session = requests.Session() session.trust_env = False # do not let HTTPS_PROXY override this resp = session.get("https://example.com", proxies=proxies, timeout=(10, 30)) print(resp.status_code) ```

Always set `timeout`. URL-encode the username and password if they contain `@` or `:`. More string variants: Proxy format.

Optional: SOCKS5 and socks5h

Switch only if the console returns SOCKS5 and your client needs SOCKS. Install `requests[socks]` first. If the library supports `socks5h://`, DNS goes through the proxy, which helps the resolved address match the exit region; `socks5://` may resolve on your machine first. Do not assume UDP is available; follow the console and docs.

```python # Example only: protocol and port must match the console proxy_url = f"socks5h://{user}:{password}@{host}:{port}" proxies = {"http": proxy_url, "https": proxy_url} ```

Rotation, sessions, and sticky

`requests.Session()` reuses the connection to the gateway. That is not a static IP, and it is not automatically a console sticky parameter. To keep an exit for a window, use the session controls the console documents, and read sticky vs static. For a term-long fixed exit, buy static.

Common issues

SymptomCheck first
407 / auth failedUsername and password match the console; special characters are encoded
Hang / timeoutProtocol and port match the order; you are not using the fake host
HTTPS still shows your IPBoth `http` and `https` keys are set; env vars are not overriding
Wrong regionOrder region is correct; SOCKS is not resolving DNS locally
Exit changed mid-flowA plain Session is not sticky or static

If it still fails, keep the non-secret console fields (protocol/host/port) before opening a ticket. Programmatic ordering: API integration.

Limits

Use the samples only against targets you may access. This is not a guide to bypassing logins, CAPTCHAs, or platform rules. Prices and inventory follow the console (about $0.40/GB rotating, about $0.20/GB for the 100 TB bundle; shared static about $1.50 and dedicated about $5 per IP·month). USDT/USDC available; Visa/Mastercard applying. Not for mainland China.

FAQ

Can I use the sample hostname as-is?

No. `proxy.example.invalid` is a fake placeholder. Use the host and port the console returns.

Why set both the http and https keys?

If you omit one, that class of requests may skip the proxy. Pointing both keys at the same proxy URL is the usual requests pattern.

Do I need SOCKS5?

Only if the console returns SOCKS and your library requires it. Many HTTPS clients work with an HTTP proxy. See HTTP / SOCKS5 setup.

What if the password has special characters?

URL-encode the username and password separately, then build the proxy URL. See Proxy format.

Does a Session keep the same IP?

Not necessarily. Connection reuse is not a static IP and not automatically a sticky session. Use static or console session parameters when you need a held exit.

May I use this to access other people’s accounts or bypass limits?

No. Lawful, authorized targets only.

What changes in code between rotating and static?

The client fields look similar. The difference is the product you bought. Choose the product first, then paste that order’s credentials.

Where are prices confirmed?

In the console. Published list: Pricing.

Next steps

  1. Copy real fields from the console (not the placeholders).
  2. Run the script against an authorized target.
  3. Open rotating or static when you still need to pick a plan.