Skip to main content

crawl4ai-proxyhat

Route Crawl4AI crawls through ProxyHat residential proxies — rotating IPs, geo-targeting, and sticky sessions mapped to Crawl4AI's own proxy rotation strategy.

CI Compatible with Crawl4AI 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

Crawling at scale from datacenter IPs gets you blocked and rate-limited. This package plugs ProxyHat's residential IPs (50M+ across 148+ countries) into Crawl4AI through its first-class ProxyConfig and ProxyRotationStrategy APIs — a fresh IP per browser context by default, and one pinned IP per Crawl4AI proxy session when you want it. No fork, no boilerplate.

Install

pip install crawl4ai-proxyhat

Crawl4AI itself is an optional dependency — bring your own version (crawl4ai>=0.5), or install it alongside:

pip install "crawl4ai-proxyhat[crawl4ai]"

Quick start

import asyncio
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
from crawl4ai_proxyhat import ProxyHatRotationStrategy

async def main():
    # An API key auto-selects an active residential sub-user:
    strategy = ProxyHatRotationStrategy.from_credentials(
        api_key="ph_your_api_key",
        country="us",
    )
    run_config = CrawlerRunConfig(proxy_rotation_strategy=strategy)

    async with AsyncWebCrawler() as crawler:
        result = await crawler.arun("https://httpbin.org/ip", config=run_config)
        print(result.html)

asyncio.run(main())

Get an API key at proxyhat.com.

Prefer a single fixed proxy? Use the convenience helper and hand it to BrowserConfig or CrawlerRunConfig:

from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig
from crawl4ai_proxyhat import proxyhat_proxy_config

proxy = proxyhat_proxy_config(api_key="ph_your_api_key", country="us")

async with AsyncWebCrawler(config=BrowserConfig(proxy_config=proxy)) as crawler:
    result = await crawler.arun("https://example.com", config=CrawlerRunConfig())

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

strategy = ProxyHatRotationStrategy.from_credentials(
    api_key="ph_your_api_key",
    protocol="http",       # or "socks5"
    country="us",          # ISO code or "any" (default)
    region="california",
    city="new_york",
    filter="high",         # AI IP-quality tier
    sticky_ttl="30m",      # sticky-session lifetime (default "30m")
)

The same knobs (country, region, city, filter, plus sticky) are accepted by proxyhat_proxy_config(...).

How it works

Crawl4AI picks a proxy per request from the CrawlerRunConfig you pass to arun / arun_many:

  • Rotating (default). With no proxy_session_id, Crawl4AI calls get_next_proxy(). We return a ProxyHat gateway ProxyConfig with a stable targeting username and no sticky token, so the gateway hands out a fresh residential IP for each new browser context.
  • Sticky (pinned IP). Set a proxy_session_id and Crawl4AI calls get_proxy_for_session(session_id, ttl). The first call mints one ProxyHat sticky session (a -sid-…-ttl-… gateway username) and caches it, so every request sharing that session id exits from the same IP until the TTL lapses or you release the session. Crawl4AI's proxy_session_ttl (seconds) maps to ProxyHat's sticky TTL; without one, sticky_ttl applies.
# Pin one residential IP for a logical user session:
run_config = CrawlerRunConfig(
    proxy_rotation_strategy=strategy,
    proxy_session_id="user-42",
    proxy_session_ttl=1800,   # 30 minutes
)

Targeting and stickiness are both expressed in the gateway username using ProxyHat's targeting grammar (built by the official proxyhat SDK); the sub-user password and gateway host/port stay constant. A single ProxyHat gateway fronts the whole residential pool, so there is no external proxy list to round-robin over — add_proxies() is a no-op kept for interface compatibility.

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

crawl4ai_proxyhat-0.1.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

crawl4ai_proxyhat-0.1.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for crawl4ai_proxyhat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5d81e118c19e91129b96e388ff4d3734b7b4a19076015491537bcab15b2df051
MD5 cd9ef557263570c7b6c3da331fd88c0f
BLAKE2b-256 41f150d8fb10394a3fb3ee9d9fd1ca5b7e0d72b3987b3e880df79cad6eb235da

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on ProxyHatCom/crawl4ai-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 crawl4ai_proxyhat-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crawl4ai_proxyhat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 014994b625c30ccb43b0dc4bed7517371bcd05977cabb8a556ef88786c1d985f
MD5 ebe84ef948e1229cb54376ab2462f0b7
BLAKE2b-256 3d7b464287f4a678537c26ef24a919f8f56d2d71082bf766c1850e9197168b18

See more details on using hashes here.

Provenance

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

Publisher: ci.yml on ProxyHatCom/crawl4ai-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