Skip to main content

requests-proxyhat

Route Python requests through ProxyHat residential proxies — a drop-in Session that pins one residential IP for the whole session by default, plus rotation, geo-targeting and socks5.

CI Compatible with requests latest PyPI License: MIT

[!TIP] Recommended proxies — ProxyHat residential IPs. Every feature in this package is tested end-to-end against ProxyHat and works great. First-class integration; also works with any proxy, or none.

Why

Scraping or calling APIs from a datacenter IP gets you rate-limited, CAPTCHA-walled and blocked. requests already speaks proxies through its proxies={"http": ..., "https": ...} dict — this package fills that dict with ProxyHat's residential IPs (50M+ across 148+ countries) and wires it into a Session subclass, so session.get(url) just works through a residential IP. No fork, no boilerplate.

Install

pip install requests-proxyhat

Quick start

from requests_proxyhat import ProxyHatSession

# An API key auto-selects an active residential sub-user:
with ProxyHatSession(country="us") as session:   # sticky US IP for the whole session
    print(session.get("https://api.ipify.org").text)
    print(session.get("https://api.ipify.org").text)  # same IP — cookies stay coherent

Get an API key at proxyhat.com.

Just want the proxies dict for plain requests or your own Session?

import requests
from requests_proxyhat import proxyhat_proxies

proxies = proxyhat_proxies(country="de")   # {"http": "http://…@gate.proxyhat.com:8080", "https": …}
requests.get("https://api.ipify.org", proxies=proxies)

Credentials

Pass them explicitly or via environment variables — options win over env:

Option Env var Notes
api_key PROXYHAT_API_KEY Auto-selects an active sub-user with remaining traffic
sub_user PROXYHAT_SUBUSER Pick a specific sub-user by uuid or name (with an API key)
username PROXYHAT_USERNAME Explicit gateway proxy_username (skips the API)
password PROXYHAT_PASSWORD Explicit gateway proxy_password

Targeting

ProxyHatSession(
    protocol="http",   # or "socks5"
    country="us",      # ISO code or "any" (default)
    region="california",
    city="new_york",
    filter="high",     # AI IP-quality tier
    sticky="30m",      # session lifetime (default); sticky=False rotates every request
)

Sticky session vs rotation

A Session usually means "keep talking to this site as one visitor" — logging in, paging, keeping cookies. If the exit IP changed mid-session the site would see a user teleporting between cities and block it. So ProxyHatSession is sticky by default: one residential IP is pinned for the session (sticky="30m", set on session.proxies), keeping cookies and fingerprint coherent.

Want a fresh IP on every request instead (e.g. many independent one-shot fetches)? Turn stickiness off:

with ProxyHatSession(country="us", sticky=False) as session:   # rotating residential IP per request
    for url in urls:
        session.get(url)   # each request exits from a new IP

Set a custom lifetime with sticky="2h".

The standalone proxyhat_proxies(...) dict is stateless, so it rotates by default (sticky=None); pass sticky="30m" to pin one IP in that dict too.

How it works

ProxyHatSession resolves your gateway credentials (via the official proxyhat SDK — an API key auto-picks an active sub-user, or pass username/password), then builds a proxy URL where the username carries ProxyHat's targeting grammar (<user>-country-us-sid-<id>-ttl-30m) and points at the gateway (http://gate.proxyhat.com:8080, or socks5://…:1080). Sticky mode sets that URL on session.proxies once, so every request reuses one pinned residential IP. Rotating mode overrides Session.request() to mint a fresh gateway session per call — so each request exits from a new IP, and requests' connection pool can't pin you to one, since the proxy URL itself changes.

License

MIT © ProxyHat

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_proxyhat-0.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_proxyhat-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file requests_proxyhat-0.1.1.tar.gz.

File metadata

  • Download URL: requests_proxyhat-0.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for requests_proxyhat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f1e86bb7b623c410630e43bd81f68f0d12d1cb27fd1a6b69ea20d0eed2acc1a0
MD5 3f0988c858663bbd4338e5fd74da8d79
BLAKE2b-256 1f58ef711901c10d47e99d753abd5877b4c904e7be3305ce28fc512cf375bfc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for requests_proxyhat-0.1.1.tar.gz:

Publisher: ci.yml on ProxyHatCom/requests-proxyhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file requests_proxyhat-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for requests_proxyhat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 980703b5d5ce4fa6060228e180a8c52b9addea537538a759c73430321c5f31ab
MD5 821fff708c8c5e86dbca107de9c3bcc3
BLAKE2b-256 75bb635b79cd1c8bc06e16afcd34bb7d9ae8950ea0a858b7210d656c31f96830

See more details on using hashes here.

Provenance

The following attestation bundles were made for requests_proxyhat-0.1.1-py3-none-any.whl:

Publisher: ci.yml on ProxyHatCom/requests-proxyhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page