Python requests with AeonProxy proxies

Send Python requests through residential or mobile IPs. The login and password go into the proxy URL, and keys in the login choose the country and hold an IP.

Protocols
HTTP and HTTPS sites over an HTTP proxy, or SOCKS5 with requests[socks]
Authentication
Login and password in the proxy URL
Rotation
A new IP per connection, or one IP per -sid- key for up to 60 minutes
Works with
Residential and mobile proxies

Before you start

  • Python 3.10 or newer and pip install requests.
  • Your proxy login and password from the Residential or Mobile page of the dashboard.
  • Traffic on the product you use: a login without traffic gets 402.
Connection details
Host
gate.aeonproxy.com
Port (HTTP / HTTPS)
7000
Port (SOCKS5)
7001
Login
your proxy login, with targeting keys if you need them: LOGIN-cc-us-sid-abc123
Password
your proxy password

Copy the login and password from the Residential or Mobile page of the dashboard; the generator there also writes ready lines. Key syntax: targeting and sessions.

Rotating proxy: a new IP for every connection

Put the login and password into the proxy URL and pass the same URL for http and https. The scheme stays http:// for HTTPS sites too: requests opens a CONNECT tunnel through the proxy and runs TLS with the site inside it.

import requests

proxy = "http://LOGIN-cc-us:[email protected]:7000"
proxies = {"http": proxy, "https": proxy}

for _ in range(3):
    r = requests.get("https://api.ipify.org", proxies=proxies, timeout=30)
    print(r.text)  # a different IP each time

Each requests.get() call opens its own connection, so each gets a new IP. A requests.Session keeps its connection open and sends the next request down it: in our test, three requests in one Session went through one tunnel, so a rotating login printed one IP three times. To rotate inside a Session, set s.headers["Connection"] = "close" or give each request its own -sid- key.

-cc-us asks for United States exits; leave it out for any country. Region, city and ISP keys are listed in targeting.

Sticky session: the same IP for several minutes

Add -sid- with a key of letters and digits, and -ttl- with the minutes to keep the IP (1–60, 10 if you leave it out). Every connection with that key leaves from the same IP until the time runs out; then the same login gets a new IP. The key also holds the IP when a Session's connection closes and a new one opens.

import secrets
import requests

sid = secrets.token_hex(4)  # one key per session you want to keep
proxy = f"http://LOGIN-cc-gb-sid-{sid}-ttl-30:[email protected]:7000"

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)  # the same IP

SOCKS5

Install the SOCKS extra with pip install "requests[socks]", use port 7001 and the socks5h:// scheme: requests then sends the host name to the proxy, which resolves it. With socks5://, requests looks the name up on your machine and sends only the IP address, so the DNS query goes out from your own connection. Over port 7000 the name always goes to the proxy in the CONNECT request.

import requests

proxy = "socks5h://LOGIN-cc-de:[email protected]:7001"
r = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.text)

Need hundreds of sticky lines at once? The proxy list API returns them ready, with a fresh session key on each line.

If it does not work

What you seeWhat to check
ProxyError with Tunnel connection failed: 407 Proxy Authentication RequiredThe login, the password, or a key in the login that is not in the lists (a misspelled city, for example). For an http:// site there is no exception: the response comes back with status_code 407.
The same with 402 Payment RequiredNo traffic left on the product, or the sub-user reached its limit.
The same with 502 Bad GatewayThe exit failed. Retry: a rotating login takes a new IP, a sticky one keeps its key.
ProxyError with Your proxy appears to only use HTTP and not HTTPSThe proxy URL starts with https://. Write http://: port 7000 is a plain HTTP proxy and carries HTTPS sites through CONNECT.
SOCKS5 authentication failedThe login or password on port 7001: the same checks as for 407.
InvalidSchema: Missing dependencies for SOCKS supportInstall requests[socks].
ReadTimeoutThe site or the exit did not answer within timeout. Retry, or raise it: 30 seconds is a safe start. Without timeout=, requests can wait forever.
Every request prints the same IPA Session reuses its connection. Send Connection: close or use a -sid- key per request.

What every gateway code means: gateway errors.

Questions

No. The country, region, city and session go into the login as keys (LOGIN-cc-us-sid-abc123), so one login and password cover every location.

Yes. Without proxies=, requests uses HTTPS_PROXY and HTTP_PROXY, so export HTTPS_PROXY="http://LOGIN-cc-us:[email protected]:7000" sends an existing script through the gateway without code changes.

As many as you need: bought traffic has no thread limit on the gateway, and it is counted in GB whatever the number of connections.

Proxy questions? Ask support in the live chat.