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.0.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: proxy11-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ca7f046800d79d018dbaacad32d79546e672f8abc6ef08d473cbe9e16277245d
MD5 004eba67a88f95db08101eb4e58b5174
BLAKE2b-256 c887f2e916380f76726d580b2c8f1ce885b19283659c617c55cc516b9e500971

See more details on using hashes here.

File details

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

File metadata

  • Download URL: proxy11-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 697e66f60bc5f3545410910955edee1c781069b24219856d9e526ef7e154ec8f
MD5 94f2d1f4c884fb976e71ada5ca4d4cf3
BLAKE2b-256 e80fceef23a604636a86d443c2dd155afadc5fab7b194290f0d9325a4cc4dfe5

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