Short answer
In Python requests, pass a proxies dictionary with the same proxy URL for http and https, built from your username, password, gate.hiproxy.shop and port 6100. For SOCKS5, install requests[socks] and use socks5h with port 6200. Leave out -sid- for a new IP per request, or add -sid- and -ttl- to keep one IP for up to 60 minutes.
Python requests proxy: the basic example
Setting a Python requests proxy takes one dictionary. Put the same proxy URL under both the http and https keys. The https key covers https:// addresses, and those requests still go through the HTTP port as a tunnel.
The address it prints is the IP your request used. Replace hpexample1 and your_password with the proxy username and password from your dashboard. Always set a timeout so one slow request cannot hang your script.
import requests
proxy = "http://hpexample1-zone-res-cc-us:your_password@gate.hiproxy.shop:6100"
proxies = {"http": proxy, "https": proxy}
r = requests.get("https://api.ipify.org", proxies=proxies, timeout=30)
print(r.text)Using SOCKS5 in Python
SOCKS support in requests needs one extra package: pip install requests[socks]. After that, change the scheme to socks5h and the port to 6200. Everything else stays the same.
socks5h means the proxy resolves host names. With plain socks5 your machine does the DNS lookup first, and that lookup leaves from your own network.
# pip install requests[socks]
import requests
proxy = "socks5h://hpexample1-zone-res-cc-us:your_password@gate.hiproxy.shop:6200"
proxies = {"http": proxy, "https": proxy}
r = requests.get("https://api.ipify.org", proxies=proxies, timeout=30)
print(r.text)Rotating and sticky sessions
By default each request gets a new IP. That fits scraping, where requests do not depend on each other. To keep one IP across several requests, such as a login and the pages after it, add -sid- with any ID and -ttl- with the minutes, up to 60. Every request with the same ID uses the same IP.
| Option | Example | What it does |
|---|---|---|
| -zone- | -zone-res | Product: res, unl, isp or dc |
| -cc- | -cc-us | Exit country, two lowercase letters |
| -city- | -city-new_york | City, with underscores for spaces |
| -sid- | -sid-a1b2c3d4 | Same IP for every request with this ID |
| -ttl- | -ttl-30 | Minutes the session keeps its IP, 1 to 60 |
import uuid
import requests
sid = uuid.uuid4().hex[:8]
user = f"hpexample1-zone-res-cc-us-sid-{sid}-ttl-30"
proxy = f"http://{user}:your_password@gate.hiproxy.shop:6100"
s = requests.Session()
s.proxies = {"http": proxy, "https": proxy}
print(s.get("https://api.ipify.org", timeout=30).text)
print(s.get("https://api.ipify.org", timeout=30).text) # same IPNode.js and cURL examples
In Node.js, the undici package gives fetch a proxy through ProxyAgent. For SOCKS5, the socks-proxy-agent package does the same job with a socks5h:// URL on port 6200.
With cURL, pass the proxy with -x and the login with -U: curl -x http://gate.hiproxy.shop:6100 -U "USERNAME:PASSWORD" https://api.ipify.org. For SOCKS5, use socks5h://gate.hiproxy.shop:6200 instead. Run it twice without -sid- and you should see two different IPs.
import { ProxyAgent, fetch } from "undici";
const agent = new ProxyAgent(
"http://hpexample1-zone-res-cc-us:your_password@gate.hiproxy.shop:6100"
);
const res = await fetch("https://api.ipify.org", { dispatcher: agent });
console.log(await res.text());Fixing 407 errors and timeouts
Log the status code and the exit IP for failed requests. It makes it much easier to tell a proxy login problem from a block by the target site.
| Error | Likely cause | Fix |
|---|---|---|
| 407 Proxy Authentication Required | Wrong proxy username or password, or a typo in the options | Copy both again from the dashboard. If you issued a new proxy password, update the script. |
| Connection timed out | The port does not match the scheme, or a firewall blocks outgoing connections | Use 6100 with http:// and 6200 with socks5h://. Allow outgoing traffic to gate.hiproxy.shop. |
| Missing dependencies for SOCKS support | requests[socks] is not installed | Run pip install requests[socks]. |
| IP in the wrong country | -cc- is not a lowercase two-letter code | Write the code in lowercase, such as -cc-us. |
| Read timed out on some requests | A slow target site or route | Catch the exception and retry. Without -sid- the retry gets a new IP. |
Running scripts on a server with Allowed IPs
If your script runs on a server with a fixed IPv4 address, add that address to Allowed IPs in the dashboard. Up to 10 addresses fit. Requests from those servers connect without the proxy password.
Either way, keep the proxy password out of code you share or commit. Read it from an environment variable instead, and issue a new one in the dashboard if it ever leaks.