Integration guide
Use a proxy with Python requests
The requests library takes a proxies mapping. Setting it on a Session applies it to every call.
Get your details
Copy the host, port, username and password for your proxy from the dashboard. Where this page writes <host>, <port>, <username> or <password>, paste your own values.
Configure a session
Read the credentials from environment variables so they stay out of source control.
import os
import requests
proxy = "http://{u}:{p}@{h}:{port}".format(
u=os.environ["PROXY_USER"],
p=os.environ["PROXY_PASS"],
h=os.environ["PROXY_HOST"],
port=os.environ["PROXY_PORT"],
)
session = requests.Session()
session.proxies = {"http": proxy, "https": proxy}
print(session.get("https://api.ipify.org", timeout=30).text)Handle failures
Always pass a timeout, and catch requests.exceptions.ProxyError and requests.exceptions.ConnectTimeout so one bad connection does not end a long job.
Keep reading
Ready to connect?
Create an account and copy your proxy details from the dashboard.