Skip to main content

Lightweight Python client for the Proxy11 free proxy API

Project description

proxy11

Lightweight Python client for the Proxy11 free proxy API.

Install

pip install proxy11

Quick Start

from proxy11 import ProxyClient

client = ProxyClient(api_key="YOUR_API_KEY")

Proxy11Error, APIError, and NoProxiesError are exported if you want to catch client-specific errors.

Get proxies

# all proxies as dicts
proxies = client.get()

# with filters
proxies = client.get(limit=50, country="us", proxy_type="anonymous", speed=1.0)

Get as ip:port list

proxies = client.as_list()
# ["103.152.112.166:8080", "45.77.56.114:4145", ...]

Random proxy

# one random ip:port string
proxy = client.random()
# "103.152.112.166:8080"

# random with filters
proxy = client.random(country="us", proxy_type="anonymous")

# random with full details
proxy = client.random_proxy()
# {"ip": "103.152.112.166", "port": "8080", "country": "Indonesia", ...}

Save to file

count = client.save("proxies.txt", country="us")
print(f"saved {count} proxies")

Rotator

Cycle through proxies with auto-refresh and dead-proxy removal.

rotator = client.rotator(country="us", proxy_type="anonymous",
                         auto_refresh=True, refresh_after=50)

for _ in range(100):
    proxy = rotator.next()
    print(proxy)
    # if proxy fails:
    # rotator.mark_dead(proxy)

print(f"{rotator.remaining} proxies left in pool")

Options:

Option Default Description
auto_refresh False Re-fetch from API when pool is empty
refresh_after 0 Re-fetch after N rotations (0 = never)
on_fail None Callback fn(proxy_str) called by mark_dead()

Session (auto-rotating proxy)

Get a requests.Session that uses a different proxy on every request. Dead proxies are automatically removed.

session = client.session(country="us", proxy_type="anonymous")

# each request goes through a different proxy
resp = session.get("https://httpbin.org/ip")
print(resp.json())

resp = session.get("https://httpbin.org/headers")
print(resp.json())

Pass an on_fail callback to log dead proxies:

session = client.session(on_fail=lambda p: print(f"dead: {p}"))

Parameters

Parameter Type Description
limit int Max proxies to return (free: 50, ultimate: 5000)
country string Filter by country name or code
port int Filter by port number
speed float Max response time in seconds
proxy_type string anonymous or transparent

API Key

Get a free API key at proxy11.com.

  • Free plan: 50 proxies per request
  • Ultimate plan: 5,000 proxies per request — from $12

License

MIT

Project details


Download files

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

Source Distribution

proxy11-1.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

proxy11-1.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file proxy11-1.0.1.tar.gz.

File metadata

  • Download URL: proxy11-1.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for proxy11-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c08ac4dc378001fa9dd4253008aedd7b58429573ebdc83a557d768e5dcb47132
MD5 a5be1901e4a3b1e408b30c96f85cf3da
BLAKE2b-256 6db77b86ff808b8f9d1753c37baf3946784cc76ed89d617ba2f9cddf8d84ef2b

See more details on using hashes here.

File details

Details for the file proxy11-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: proxy11-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for proxy11-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d9669188c1f4d2dbdaa6af15c0a7c6bbc75bb46b7a3b8d3a19e198d56c03275
MD5 2a8a09a65f6111c9302d9511eb4e8e68
BLAKE2b-256 d9a51a59d96c67d28264bb3a21be9fd24feeb494ee9de1d5336b02aa81e00d66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page