Integration · Python
Use RoProxy with Python
Every RoProxy session comes with its own username, password, gateway host and HTTP port, and Pro and Business sessions add a SOCKS5 port. Python needs nothing else. This guide plugs those values into requests and httpx, explains when the SOCKS5 port is the better fit, shows how the session type decides whether your IP stays or changes, and calls the API for a new IP when a site starts answering 403 or 429.
What you need
Open the dashboard, pick a session and copy its connection string. It comes as GATEWAY_HOST:HTTP_PORT:USERNAME:PASSWORD; the examples below split it into those parts.
Credentials belong to one session. With several sessions you get several username and password pairs, so separate jobs can run side by side without sharing an IP.
requests and httpx over HTTP and HTTPS
HTTPS sites go through the HTTP port too: the client opens a CONNECT tunnel, so both keys use the http:// scheme and TLS stays between your script and the site.
import requests
PROXY = "http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT"
proxies = {"http": PROXY, "https": PROXY}
r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
print(r.json())SOCKS5
On Pro and Business sessions, use the SOCKS5 port for tools that only speak SOCKS. It carries TCP connections (CONNECT) only, no UDP. The socks5h:// scheme resolves hostnames on the proxy side.
# pip install "requests[socks]"
import requests
PROXY = "socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT"
proxies = {"http": PROXY, "https": PROXY}
r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
print(r.json())Sticky or rotating
Whether the IP stays or changes is a setting of the session, not of your code. Change it in the dashboard or with the API.
Sticky (bind)
Keeps the same IP until you rotate it, the session expires or the upstream proxy fails. Use it for logins, carts and anything that relies on cookies.
Timed rotation (time)
Moves to a new IP on the interval you set for the session in the dashboard, with a minimum that depends on your plan.
Per request (request)
Every request leaves from a new IP. Available on the Business plan.
Rotate the IP from your script
Create an API key in the dashboard, then ask for a new IP when a target starts blocking you. Free and Standard sessions have a short cooldown between manual rotations; calling earlier returns 429.
import requests
API = "https://backend-api.ro-proxy.com"
HEADERS = {"Authorization": "Bearer API_KEY"}
def rotate(session_id: int) -> str:
r = requests.post(f"{API}/api/session/{session_id}/rotate", headers=HEADERS, timeout=30)
r.raise_for_status()
return r.json()["data"]["proxy_ip"]
print(rotate(SESSION_ID))Errors and retries
407 Proxy Authentication Required
The username or password is wrong, or the session has expired. Copy the connection string again from the dashboard.
Timeouts
Retry with exponential backoff. On a sticky session, rotate the IP after a few consecutive failures.
503 from the API
The pool for the requested country is temporarily empty. Wait about 30 seconds and try again, or pick a region instead of a country.
Frequently asked questions
Do I need a different port for HTTPS websites?
No. Use the HTTP port with an http:// proxy URL. Python opens a CONNECT tunnel and the TLS session stays between your script and the website.
Can I use the SOCKS5 port with requests?
Yes, on a Pro or Business session, after installing requests[socks]. Use socks5h:// so DNS lookups happen on the proxy side. SOCKS5 carries TCP connections only.
How do I get a new IP without restarting my script?
Call POST /api/session/SESSION_ID/rotate with your API key, or switch the session to per-request or timed rotation in the dashboard.
Can I try this without paying?
Every verified account gets free sessions with random global IPs, which is enough to run the HTTP examples on this page. SOCKS5 and choosing a country start with the Pro plan.