ProxioDocs
Integrations

Python

Route requests, httpx, and aiohttp through Proxio over HTTP or SOCKS5, hold a sticky session with the username grammar, and verify rotation with a script that prints the exit IP twice.

Proxio doesn't need a Python SDK. Any HTTP client that supports a proxy URL works, because the whole integration surface is the proxy protocol itself. This guide covers the three most common clients: requests, httpx, and aiohttp. Each section shows HTTP and SOCKS5, a sticky-session example built from the username grammar, and a script that proves rotation and sticky sessions actually behave differently.

requests

pip install requests
# SOCKS5 needs the PySocks extra:
pip install "requests[socks]"

requests takes the proxy as a proxies dict with both an http and https key. Set both, even for an https:// target, since that key is what requests uses to pick the proxy for HTTPS URLs.

import requests

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"

proxy_url = f"http://{USERNAME}:{PASSWORD}@{HOST}:{PORT}"
proxies = {"http": proxy_url, "https": proxy_url}

response = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=15)
print(response.json())
import requests

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"

# socks5h:// resolves the destination hostname through the proxy instead of
# locally. It only works once python-socks/PySocks is installed via requests[socks].
proxy_url = f"socks5h://{USERNAME}:{PASSWORD}@{HOST}:{PORT}"
proxies = {"http": proxy_url, "https": proxy_url}

response = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=15)
print(response.json())

Sticky session, and proving rotation vs. sticky

Append a -sessid- prefix and a -sesstime- value in minutes to the username to pin one IP. This script requests twice with a plain username (auto rotation) and twice with a sticky username, so you can see the difference directly:

import requests

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "abcxyz123def", "PASSWORD"


def exit_ip(username: str) -> str:
    proxy_url = f"http://{username}:{PASSWORD}@{HOST}:{PORT}"
    proxies = {"http": proxy_url, "https": proxy_url}
    return requests.get("https://ipinfo.io/json", proxies=proxies, timeout=15).json()["ip"]


# No session segments, so a fresh IP on every request.
print("auto #1:  ", exit_ip(USERNAME))
print("auto #2:  ", exit_ip(USERNAME))

# -sessid-...-sesstime-10 holds the same IP for up to 10 minutes.
sticky_user = f"{USERNAME}-sessid-myapp_9k2p7qz1m4vb1-sesstime-10"
print("sticky #1:", exit_ip(sticky_user))
print("sticky #2:", exit_ip(sticky_user))

Verify: the two auto lines print different IPs; the two sticky lines print the same one.

httpx

pip install httpx
# SOCKS5 needs the socksio extra:
pip install "httpx[socks]"

httpx.Client takes a single proxy argument that applies to both http:// and https:// targets. Use mounts instead only when different schemes need different proxies.

import httpx

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"

proxy_url = f"http://{USERNAME}:{PASSWORD}@{HOST}:{PORT}"

with httpx.Client(proxy=proxy_url, timeout=15) as client:
    print(client.get("https://ipinfo.io/json").json())
import httpx

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"

# pip install "httpx[socks]"
proxy_url = f"socks5h://{USERNAME}:{PASSWORD}@{HOST}:{PORT}"

with httpx.Client(proxy=proxy_url, timeout=15) as client:
    print(client.get("https://ipinfo.io/json").json())

To mount a proxy per scheme instead of one proxy for everything:

import httpx

proxy_url = "http://USERNAME:[email protected]:16666"

mounts = {
    "http://": httpx.HTTPTransport(proxy=proxy_url),
    "https://": httpx.HTTPTransport(proxy=proxy_url),
}

with httpx.Client(mounts=mounts, timeout=15) as client:
    print(client.get("https://ipinfo.io/json").json())

Sticky session, and proving rotation vs. sticky

import httpx

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "abcxyz123def", "PASSWORD"


def exit_ip(username: str) -> str:
    proxy_url = f"http://{username}:{PASSWORD}@{HOST}:{PORT}"
    with httpx.Client(proxy=proxy_url, timeout=15) as client:
        return client.get("https://ipinfo.io/json").json()["ip"]


print("auto #1:  ", exit_ip(USERNAME))
print("auto #2:  ", exit_ip(USERNAME))

sticky_user = f"{USERNAME}-sessid-myapp_9k2p7qz1m4vb1-sesstime-10"
print("sticky #1:", exit_ip(sticky_user))
print("sticky #2:", exit_ip(sticky_user))

Verify: same result as above. auto prints two different IPs, sticky prints the same IP twice.

aiohttp

pip install aiohttp
# aiohttp has no built-in SOCKS5 support, so add:
pip install aiohttp-socks

aiohttp's proxy= parameter on session.get() supports http:// directly, credentials and all. For SOCKS5, use the aiohttp-socks connector.

import asyncio
import aiohttp

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"


async def main():
    proxy_url = f"http://{USERNAME}:{PASSWORD}@{HOST}:{PORT}"
    async with aiohttp.ClientSession() as session:
        async with session.get("https://ipinfo.io/json", proxy=proxy_url) as resp:
            print(await resp.json())


asyncio.run(main())
import asyncio
import aiohttp
from aiohttp_socks import ProxyConnector

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "USERNAME", "PASSWORD"


async def main():
    # aiohttp-socks defaults rdns=True for SOCKS5, so hostnames already resolve
    # on the proxy side (the socks5h:// behavior) with no extra flag needed.
    connector = ProxyConnector.from_url(f"socks5://{USERNAME}:{PASSWORD}@{HOST}:{PORT}")
    async with aiohttp.ClientSession(connector=connector) as session:
        async with session.get("https://ipinfo.io/json") as resp:
            print(await resp.json())


asyncio.run(main())

Sticky session, and proving rotation vs. sticky

import asyncio
import aiohttp

HOST, PORT = "geo.proxio.cc", 16666
USERNAME, PASSWORD = "abcxyz123def", "PASSWORD"


async def exit_ip(session: aiohttp.ClientSession, username: str) -> str:
    proxy_url = f"http://{username}:{PASSWORD}@{HOST}:{PORT}"
    async with session.get("https://ipinfo.io/json", proxy=proxy_url) as resp:
        data = await resp.json()
        return data["ip"]


async def main():
    async with aiohttp.ClientSession() as session:
        print("auto #1:  ", await exit_ip(session, USERNAME))
        print("auto #2:  ", await exit_ip(session, USERNAME))

        sticky_user = f"{USERNAME}-sessid-myapp_9k2p7qz1m4vb1-sesstime-10"
        print("sticky #1:", await exit_ip(session, sticky_user))
        print("sticky #2:", await exit_ip(session, sticky_user))


asyncio.run(main())

Verify: run the script. auto #1/auto #2 print different IPs, and sticky #1/sticky #2 print the same one, confirming the session held.

On this page