Code Examples
Replace YOUR_PROXY_HOST, YOUR_PROXY_PORT and PASS with the endpoint and password returned by Generate access. Choose the endpoint for the protocol you are using, and use a routing username supported by your generated credentials.
Python
import requests
# Basic connection
proxy = {
"http": "http://res-us:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT",
"https": "http://res-us:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT"
}
response = requests.get("https://httpbin.org/ip", proxies=proxy)
print(response.json())
# With country targeting (US)
proxy_us = {
"http": "http://res-us:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT",
"https": "http://res-us:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT"
}
response = requests.get("https://httpbin.org/ip", proxies=proxy_us)
print(response.json())
# Sticky session
proxy_sticky = {
"http": "http://res-us-sid-myapp01:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT",
"https": "http://res-us-sid-myapp01:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT"
}
response = requests.get("https://httpbin.org/ip", proxies=proxy_sticky)
print(response.json())
# Async with aiohttp
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.get(
"https://httpbin.org/ip",
proxy="http://res-us:PASS@YOUR_PROXY_HOST:YOUR_PROXY_PORT"
) as response:
print(await response.json())
asyncio.run(main())