Skip to content

Python Integration

Overview

TrueProxies works with standard Python HTTP clients over HTTP CONNECT and SOCKS5. You can authenticate with your proxy username and password or with IP allowlisting when enabled for your account.

Installation

Install the common client libraries:

Terminal window
pip install requests "requests[socks]" aiohttp aiohttp-socks

You will need:

  • proxy host: connect.trueproxies.com
  • HTTP port: 8080
  • SOCKS5 port: 1080
  • proxy username
  • proxy password

For country targeting or sticky sessions, append the required parameters to the proxy username before using it in code.

HTTP Proxy

import requests
username = "your_username"
password = "your_password"
proxy_url = f"http://{username}:{password}@connect.trueproxies.com:8080"
response = requests.get(
"https://httpbin.org/ip",
proxies={
"http": proxy_url,
"https": proxy_url,
},
timeout=30,
)
print(response.status_code)
print(response.text)

SOCKS5 Proxy

import requests
username = "your_username"
password = "your_password"
proxy_url = f"socks5h://{username}:{password}@connect.trueproxies.com:1080"
response = requests.get(
"https://httpbin.org/ip",
proxies={
"http": proxy_url,
"https": proxy_url,
},
timeout=30,
)
print(response.json())

Async with aiohttp

import asyncio
from aiohttp import ClientSession
from aiohttp_socks import ProxyConnector
username = "your_username"
password = "your_password"
connector = ProxyConnector.from_url(
f"http://{username}:{password}@connect.trueproxies.com:8080"
)
async def main() -> None:
async with ClientSession(connector=connector) as session:
async with session.get("https://httpbin.org/ip", timeout=30) as response:
print(response.status)
print(await response.text())
asyncio.run(main())

Error Handling

  • Set explicit request timeouts so failed proxy handshakes do not hang workers.
  • If you receive authentication failures, re-check your proxy username, password, and any required IP allowlisting.
  • If you use username parameters for targeting or sticky sessions, log the final username string you send so you can reproduce failures.
  • For payment or account-state issues, check the dashboard for billing alerts or suspended-account notices before assuming the proxy endpoint is unhealthy.