# Use US Proxies in Python: requests, httpx, Scrapy and Playwright

> Python US proxies guide: working requests, httpx, Scrapy and Playwright code for gateway port 7777, from $0.52/GB. No KYC, pay in crypto.

- URL: https://statesideip.com/guides/python-us-proxies/
- Last updated: 2026-10-05
- Publisher: StatesideIP (https://statesideip.com)

Working code for the four Python tools most scrapers use, with US state, city and ZIP targeting, rotation, sticky sessions, retries and rate limits.

**Quick answer — How do I use US proxies in Python?**

**StatesideIP**, a no-KYC US residential and mobile proxy provider, serves Python US proxies through one gateway: `gw.statesideip.com`, port 7777 for HTTP/HTTPS or 7778 for SOCKS5. Location goes in the username, such as `USERNAME-country-us-state-ny`. Residential traffic starts at $0.52/GB, as of October 2026. No KYC — no ID, no selfie, no documents. Pay in crypto.

## Connection details for Python

| Attribute | Value |
| --- | --- |
| Gateway host | `gw.statesideip.com` |
| HTTP/HTTPS port | 7777 |
| SOCKS5 port | 7778 |
| Username format | `USERNAME-country-{cc}-state-{state}-city-{city}-zip-{zip}-asn-{asn}-session-{id}-ttl-{minutes}` |
| Protocols | HTTP, HTTPS (CONNECT) and SOCKS5 |
| Rotation | A new IP on every request, or a sticky session that keeps the same IP |
| Sticky sessions | 1 to 120 minutes, set per session with the ttl parameter |
| Test endpoint used here | `https://api.ipify.org?format=json` |
| Price | From $0.52/GB; $1.50 for 1 GB |
| KYC and payment | No KYC — no ID, no selfie, no documents. Pay in crypto. |

## What do I need before using US proxies in Python?

You need Python 3, pip, and a StatesideIP username and password. Setup takes five steps.

1. **Buy a small plan** — The 1 GB plan costs $1.50 on the pricing page, paid in BTC, USDT, USDC, ETH, LTC or SOL.
2. **Copy your credentials** — Credentials appear in your dashboard as soon as you buy a plan from your confirmed crypto balance. The code below writes them as USERNAME and PASSWORD.
3. **Install the libraries** — Run pip install requests httpx scrapy playwright, then playwright install chromium for the browser example.
4. **Build the username** — Add only the targeting segments you need, for example USERNAME-country-us-state-tx-city-houston. Values are lowercase, with underscores for spaces.
5. **Check the exit IP** — Request https://api.ipify.org?format=json through the proxy. The IP it returns is the US IP that target sites see.

## How do I use a US proxy with Python requests?

Pass one proxy URL for both `http` and `https` in the `proxies` argument. Keep the `http://` scheme in the proxy URL even for HTTPS targets: the gateway opens an HTTPS tunnel with CONNECT. For SOCKS5, install `requests[socks]` and use `socks5h://`, so DNS lookups also happen on the US side.

*requests: a rotating New York IP, then SOCKS5*

```python
import requests

HOST = "gw.statesideip.com"
USER = "USERNAME-country-us-state-ny"  # rotating New York State IP
PASSWORD = "PASSWORD"

proxy = f"http://{USER}:{PASSWORD}@{HOST}:7777"
r = requests.get("https://api.ipify.org?format=json",
                 proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.json())

# SOCKS5 (pip install "requests[socks]"); socks5h resolves DNS through the proxy
socks = f"socks5h://{USER}:{PASSWORD}@{HOST}:7778"
r = requests.get("https://api.ipify.org?format=json",
                 proxies={"http": socks, "https": socks}, timeout=30)
print(r.json())
```

## Should I rotate IPs per request or keep a sticky session?

Rotate per request for independent page fetches, and use a sticky session for any task that must keep one IP. A username without a `session` segment gets a new IP on every request. Adding `session-{id}` and `ttl-{minutes}` keeps one IP for 1 to 120 minutes, set per session with the ttl parameter.

- **Rotating:** search result checks or catalog price checks spread across many US IPs.
- **Sticky:** a multi-page flow on your own site, such as a cart-to-checkout QA test.

Rotating gateways usually assign the exit IP per connection. If several requests share one IP, your client is reusing a connection; a new `requests.get()` call without a `Session` opens a fresh one.

*Build rotating and sticky proxy URLs*

```python
import uuid

def proxy_url(state=None, city=None, zip_code=None, session=None, ttl=10):
    parts = ["USERNAME", "country-us"]
    if state:
        parts.append(f"state-{state}")
    if city:
        parts.append(f"city-{city}")
    if zip_code:
        parts.append(f"zip-{zip_code}")
    if session:
        parts += [f"session-{session}", f"ttl-{ttl}"]
    user = "-".join(parts)
    return f"http://{user}:PASSWORD@gw.statesideip.com:7777"

rotating = proxy_url(state="tx", city="houston")  # new IP per request
sticky = proxy_url(zip_code="10001", session=uuid.uuid4().hex[:8], ttl=30)  # one IP, 30 min
```

## How do I send many requests at once with httpx async?

Use one `httpx.AsyncClient` with the `proxy` argument, and cap the requests in flight with an `asyncio.Semaphore`. Start with about 5 requests in flight per target site. Raise the cap only while error rates stay low.

The example below disables keep-alive, so each request opens a new connection and can get a new IP. Remove that line when you use a sticky session. Recent httpx versions take `proxy=`; the older `proxies=` argument was removed in httpx 0.28.

*httpx: 20 requests, at most 5 in flight, California IPs*

```python
import asyncio
import httpx

PROXY = "http://USERNAME-country-us-state-ca:PASSWORD@gw.statesideip.com:7777"
URLS = ["https://api.ipify.org?format=json"] * 20

async def fetch(client, sem, url):
    async with sem:  # caps requests in flight
        r = await client.get(url)
        r.raise_for_status()
        return r.json()

async def main():
    sem = asyncio.Semaphore(5)
    limits = httpx.Limits(max_keepalive_connections=0)  # new connection, new IP
    async with httpx.AsyncClient(proxy=PROXY, limits=limits, timeout=30) as client:
        results = await asyncio.gather(*(fetch(client, sem, u) for u in URLS),
                                       return_exceptions=True)
    for res in results:
        print(res)

asyncio.run(main())
```

## How do I handle retries, backoff and rate limits?

Retry only temporary failures, wait longer after each attempt, and add random jitter. Retry on timeouts, connection errors and status codes 429, 500, 502, 503 and 504. Honor a `Retry-After` header when the site sends one. Never retry a 407: it means the username or password is wrong.

Respect each site's robots.txt and terms, and keep request rates close to normal browsing. StatesideIP blocks banking, government and payment portals, plus SMTP ports, under its [Acceptable Use Policy](https://statesideip.com/acceptable-use/).

*Exponential backoff with jitter for requests*

```python
import random
import time
import requests

RETRY_STATUS = {429, 500, 502, 503, 504}

def get_with_retries(url, proxies, attempts=5):
    for attempt in range(attempts):
        try:
            r = requests.get(url, proxies=proxies, timeout=30)
            if r.status_code == 407:
                raise RuntimeError("407: check USERNAME and PASSWORD")  # do not retry
            if r.status_code not in RETRY_STATUS:
                return r
            ra = r.headers.get("Retry-After", "")
            wait = int(ra) if ra.isdigit() else 2 ** attempt
        except (requests.ConnectionError, requests.Timeout):
            wait = 2 ** attempt
        time.sleep(wait + random.uniform(0, 1))  # backoff plus jitter
    raise RuntimeError(f"gave up on {url}")
```

## How do I use US proxies in Scrapy?

Set the proxy per request in `meta["proxy"]`, with the username and password inside the URL. Scrapy's built-in proxy middleware turns them into a `Proxy-Authorization` header. Keep `ROBOTSTXT_OBEY = True`, and let AutoThrottle slow the crawl when a site responds slowly.

*Scrapy: settings and a spider on Miami IPs*

```python
# settings.py
ROBOTSTXT_OBEY = True
CONCURRENT_REQUESTS_PER_DOMAIN = 4
AUTOTHROTTLE_ENABLED = True
RETRY_TIMES = 3
RETRY_HTTP_CODES = [429, 500, 502, 503, 504]

# spiders/ip_check.py
import scrapy

PROXY = "http://USERNAME-country-us-state-fl-city-miami:PASSWORD@gw.statesideip.com:7777"

class IpCheckSpider(scrapy.Spider):
    name = "ip_check"
    start_urls = ["https://api.ipify.org?format=json"]

    def start_requests(self):
        for url in self.start_urls:
            yield scrapy.Request(url, meta={"proxy": PROXY}, dont_filter=True)

    def parse(self, response):
        yield {"ip": response.json()["ip"]}
```

## How do I use US proxies with Playwright?

Pass a `proxy` dictionary with server, username and password when you launch the browser. A browser loads many files per page, so use a sticky session: one page view then keeps one US IP. Use a new session ID for each new task.

*Playwright: a sticky Chicago IP for 15 minutes*

```python
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(proxy={
            "server": "http://gw.statesideip.com:7777",
            "username": "USERNAME-country-us-state-il-city-chicago-session-pw1-ttl-15",
            "password": "PASSWORD",
        })
        page = await browser.new_page()
        await page.goto("https://api.ipify.org?format=json")
        print(await page.text_content("body"))
        await browser.close()

asyncio.run(main())
```

## Why does my Python proxy request fail?

Most failures come from credentials, targeting that is too narrow, or a client that reuses connections.

- **407 Proxy Authentication Required:** the username or password is wrong, or a segment is misspelled. Compare it with `USERNAME-country-{cc}-state-{state}-city-{city}-zip-{zip}-asn-{asn}-session-{id}-ttl-{minutes}`.
- **Timeouts on ZIP or ASN targets:** a narrow filter draws on fewer IPs. Widen to the city or state, or raise the timeout.
- **The same IP on every request:** your client keeps the connection open. Disable keep-alive, or drop the `session` segment.
- **SSL errors:** use `http://` for the proxy URL, not `https://`.

The [getting-started guide](https://statesideip.com/guides/getting-started/) covers curl and Node.

## Python US proxies: FAQ

### Which Python library should I use with US proxies?

Use requests for simple scripts, httpx for many requests at once, Scrapy for full crawls, and Playwright for pages that need JavaScript. All four work with the StatesideIP gateway at `gw.statesideip.com` on port 7777. The same username format sets the US state, city or ZIP code in each of them.

### How do I get a new US IP on every request in Python?

Leave the `session` segment out of the username, for example `USERNAME-country-us-state-ga`. StatesideIP then gives a new IP on every request. Make sure your client opens a new connection each time: call `requests.get()` without a Session, or disable keep-alive in httpx. Otherwise several requests may share one IP.

### How do I keep the same US IP for a whole task?

Add `session-{id}` and `ttl-{minutes}` to the username, for example `USERNAME-country-us-zip-10001-session-job42-ttl-30`. All requests with that session ID keep one IP for up to the ttl you set. StatesideIP sticky sessions last 1 to 120 minutes, set per session with the ttl parameter. A home connection can still drop early, so keep retries in your code.

### Can I use SOCKS5 proxies in Python?

Yes. Install `requests[socks]`, or `httpx[socks]` for httpx, and use a `socks5h://` URL on port 7778. The `h` makes DNS lookups go through the proxy, so a US site resolves as it would for a US visitor. HTTP and HTTPS work on port 7777 with no extra package.

### How many requests can I send at once through StatesideIP?

Start with about 5 requests in flight per target site, then raise the cap while errors stay low. Most limits come from the target site, so watch for status 429 and back off. Residential IPs sit on home connections, so expect slower responses than a datacenter. Keep concurrency lower on ZIP or ASN targets.

### Do I need KYC to get credentials for my Python scripts?

No. Credentials come with the account, not with an identity check: Account-number login; email is optional. Pay in crypto (BTC, USDT, USDC, ETH, LTC or SOL). Then paste the username and password into the `USERNAME` and `PASSWORD` placeholders in the code above. No free trial — test with the 1 GB plan, paid from the minimum top-up; the rest stays on your balance (never expires, non-refundable).

**Get US proxy credentials for your Python code** Residential traffic from $0.52/GB, with state, city, ZIP and ASN targeting. No KYC — no ID, no selfie, no documents. Pay in crypto. [Get US residential proxies — from $0.52/GB](https://statesideip.com/pricing/) · [US residential proxies](https://statesideip.com/residential-proxies/united-states/)

---

StatesideIP: StatesideIP is a US and Canada proxy provider: residential IPs with state, city, ZIP and ASN targeting, plus dedicated T-Mobile, AT&T and Verizon 4G/5G mobile ports. No KYC — no ID, no selfie, no documents. Pay in crypto.
