Python requests with a UK home IP

requests supports HTTP proxies out of the box and SOCKS5 with one extra package.

Before you start

You need a ProxyPi login. The free 100 MB trial is enough to test this guide. Copy HOST, PORT, USERNAME and PASSWORD from your dashboard. Examples that read PROXYPI_HTTP expect http://USERNAME:PASSWORD@HOST:PORT in that environment variable.

HTTP port

Python
import os
import requests

proxy = os.environ["PROXYPI_HTTP"]   # http://USERNAME:PASSWORD@HOST:PORT
proxies = {"http": proxy, "https": proxy}

r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
print(r.json())

SOCKS5 port

Python
# pip install "requests[socks]"
import os
import requests

proxy = os.environ["PROXYPI_SOCKS"]  # socks5h://USERNAME:PASSWORD@HOST:PORT
r = requests.get("https://api.ipify.org?format=json",
                 proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.json())

Good to know

  • Note that the https key still uses an http:// proxy URL. The proxy tunnels HTTPS for you.
  • Reuse a requests.Session() for many calls. It keeps connections open and saves data.

Official documentation

Third-party APIs change. We checked these against the official docs on 23 November 2026. If something has moved, the linked docs win.

Try it on a real UK home line

The trial is 100 MB of UK residential data. No card needed. Your host, port and login are in your dashboard once you have signed up.

Use ProxyPi within the acceptable use policy and the terms of the sites and tools you use.