Integrate · Code examples
Working examples for the clients people actually use.
Every snippet fetches https://api.ipify.org through a United States residential exit and prints the IP. Swap the username parameters and the target, nothing else changes.
Command line#
# HTTP(S) proxy
curl -x http://USER-cc-us:[email protected]:9000 https://api.ipify.org
# SOCKS5 with remote DNS
curl --proxy socks5h://USER-cc-us:[email protected]:9001 https://api.ipify.org
# Sticky session for 30 minutes, verbose to see the CONNECT
curl -v -x http://USER-cc-us-sid-a1b2c3-ttl-30m:[email protected]:9000 https://api.ipify.orghttps_proxy=http://USER-cc-us:[email protected]:9000 \
http_proxy=http://USER-cc-us:[email protected]:9000 \
wget -qO- https://api.ipify.org# Most CLI tools and many libraries honour these
export HTTP_PROXY=http://USER-cc-us:[email protected]:9000
export HTTPS_PROXY=http://USER-cc-us:[email protected]:9000
export NO_PROXY=localhost,127.0.0.1
curl https://api.ipify.orgPython#
import requests
proxy = "http://USER-cc-us:[email protected]:9000"
session = requests.Session()
session.proxies = {"http": proxy, "https": proxy}
r = session.get("https://api.ipify.org", timeout=30)
print(r.text)
# Sticky: build the username per session id
def proxy_for(sid: str, cc: str = "us", ttl: str = "10m") -> str:
return f"http://USER-cc-{cc}-sid-{sid}-ttl-{ttl}:[email protected]:9000"import httpx
proxy = "http://USER-cc-us:[email protected]:9000"
with httpx.Client(proxy=proxy, timeout=30) as client:
print(client.get("https://api.ipify.org").text)
# async
# async with httpx.AsyncClient(proxy=proxy) as client: ...import asyncio
import aiohttp
async def main():
auth = aiohttp.BasicAuth("USER-cc-us", "PASS")
async with aiohttp.ClientSession() as session:
async with session.get("https://api.ipify.org",
proxy="http://res.proxshift.com:9000",
proxy_auth=auth, timeout=30) as r:
print(await r.text())
asyncio.run(main())import scrapy
class IpSpider(scrapy.Spider):
name = "ip"
def start_requests(self):
# HttpProxyMiddleware (enabled by default) reads credentials from the URL
yield scrapy.Request(
"https://api.ipify.org",
meta={"proxy": "http://USER-cc-us:[email protected]:9000"},
)
def parse(self, response):
yield {"ip": response.text}Node.js#
import { fetch, ProxyAgent } from "undici";
const dispatcher = new ProxyAgent("http://USER-cc-us:[email protected]:9000");
const res = await fetch("https://api.ipify.org", { dispatcher });
console.log(await res.text());import axios from "axios";
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent("http://USER-cc-us:[email protected]:9000");
const { data } = await axios.get("https://api.ipify.org", {
httpsAgent: agent,
proxy: false, // let the agent handle it
});
console.log(data);import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: {
server: "http://res.proxshift.com:9000",
username: "USER-cc-us-sid-a1b2c3-ttl-30m",
password: "PASS",
},
});
const page = await browser.newPage();
await page.goto("https://api.ipify.org");
console.log(await page.textContent("body"));
await browser.close();import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=res.proxshift.com:9000"],
});
const page = await browser.newPage();
await page.authenticate({ username: "USER-cc-us-sid-a1b2c3", password: "PASS" });
await page.goto("https://api.ipify.org");
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();PHP#
$ch = curl_init("https://api.ipify.org");
curl_setopt_array($ch, [
CURLOPT_PROXY => "http://res.proxshift.com:9000",
CURLOPT_PROXYUSERPWD => "USER-cc-us:PASS",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
echo curl_exec($ch);$client = new \GuzzleHttp\Client();
$response = $client->get('https://api.ipify.org', [
'proxy' => 'http://USER-cc-us:[email protected]:9000',
'timeout' => 30,
]);
echo $response->getBody();Go, Java and C##
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
proxyURL, _ := url.Parse("http://USER-cc-us:[email protected]:9000")
client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
resp, err := client.Get("https://api.ipify.org")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}import okhttp3.*;
import java.net.InetSocketAddress;
import java.net.Proxy;
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("res.proxshift.com", 9000));
OkHttpClient client = new OkHttpClient.Builder()
.proxy(proxy)
.proxyAuthenticator((route, response) -> response.request().newBuilder()
.header("Proxy-Authorization", Credentials.basic("USER-cc-us", "PASS"))
.build())
.build();
try (Response res = client.newCall(new Request.Builder().url("https://api.ipify.org").build()).execute()) {
System.out.println(res.body().string());
}
// java.net.http.HttpClient: Basic auth on CONNECT is disabled by default since Java 8u111.
// Start the JVM with -Djdk.http.auth.tunneling.disabledSchemes= to enable it.using System.Net;
var handler = new HttpClientHandler
{
Proxy = new WebProxy("http://res.proxshift.com:9000")
{
Credentials = new NetworkCredential("USER-cc-us", "PASS")
},
UseProxy = true,
};
using var http = new HttpClient(handler);
Console.WriteLine(await http.GetStringAsync("https://api.ipify.org"));Browsers and anti-detect tools#
- Chrome's
--proxy-serverflag takes no credentials. Use Playwright or Puppeteer (they answer the auth challenge for you), or whitelist the machine and use the flag alone. - Selenium has no built-in proxy authentication either; the whitelist is the reliable route.
- Anti-detect browsers (Multilogin, GoLogin, AdsPower, Dolphin and the like) accept a
host:port:user:passline per profile. Paste the dedicated address line, or the gateway with a unique-sid-per profile. - Firefox and Chrome ask for the proxy password once per session when configured manually; automation should not rely on that prompt.