Skip to main content

Pubproxpy

An easy to use Python wrapper for pubproxy's public proxy API.

Installation

NOTE: The minimum python version for this library is 3.6, check with python -V or python3 -V if you're unsure about your current version.

Install the pubproxpy package using your standard Python package manager e.g.

$ pip install pubproxpy

As always you are recommended to install into a virtual environment.

Keyless API Limitations

API Daily Limits

At the time of writing this without an API key the pubproxy API limits users to 5 proxies per request and 50 requests per day. The maximum proxies per request is always used to minimize rate limiting along with getting the most proxies possible within the request limit meaning you should get 250 proxies per day without needing an API key.

API Rate Limiting

Without an API key pubproxy limits users to one request per second so a ProxyFetcher will try to ensure that at most only one request per second is done without an API key. This is synchronized between ProxyFetchers, but this is not thread safe so make sure all ProxyFetchers are on one thread in one program if you have no API key. The rate limiting is quite severe, so upon being hit the API seems to deny requests for several minutes/hours.

Quickstart Example

from pubproxpy import ProxyFetcher

# ProxyFetcher for proxies that use the socks5 protocol, are located in
# the US or Canada and support POST requests
socks_pf = ProxyFetcher(protocol="socks5", countries=["US", "CA"], post=True)

# ProxyFetcher for proxies that support https, are elite anonymity level,
# and connected in 15 seconds or less
http_pf = ProxyFetcher(protocol="http", https=True, level="elite",
                       time_to_connect=15)

# Get one socks proxy, followed by 10 https proxies
# NOTE: even though there are multiple `ProxyFetcher`s the delays are
#       coordinated between them to prevent rate limiting
socks_proxy = socks_pf.get_proxy()      # Returns a single proxy as a string
https_proxy = https_pf.get_proxies(10)  # Returns a list of proxies as strings

# Do something with the proxies, like spawn worker threads that use them

Documentation

Getting proxies is handled by the ProxyFetcher class. There are several parameters you can pass on initialization to narrow down the proxies to a suitable type. From there you can just call get_proxy to receive a proxy in the form of {ip-address}:{port-number} or call get_proxies(amount) to receive a list of amount proxies. There is an internal blacklist to ensure that the same proxy ip and port combo will not be used more than once by any ProxyFetcher, unless exclude_used is False.

ProxyFetcher Parameters

Since the API doesn't check pretty much anything for correctness, we do our best in the ProxyFetcher to ensure nothing is wrong. As far as I know the only thing that isn't checked is that the countries or not_countries actually use the correct codes.

Parameter Type Description
exclude_used bool If the ProxyFetcher should prevent re-returning proxies
api_key str API key for a paid account, you can also set $PUBPROXY_API_KEY to pass your key, passing the api_key parameter will override the env-var
level str [Options: anonymous, elite] Proxy anonymity level
protocol str [Options: http, socks4, socks5] Desired communication protocol
countries str or list<str> Locations of the proxy using the ISO-3166 alpha-2 country code, Incompatible with not_countries
not_countries str or list<str> Blacklist locations of the proxy using the ISO-3166 alpha-2 country code, Incompatible with countries
last_checked int [Bounds: 1-1000] Minutes since the proxy was checked
port int Proxies using a specific port
time_to_connect int [Bounds: 1-60] How many seconds it took for the proxy to connect
cookies bool Supports requests with cookies
google bool Can connect to Google
https bool Supports HTTPS requests
post bool Supports POST requests
referer bool Supports referer requests
user_agent bool Supports forwarding user-agents

ProxyFetcher Methods

Keeping it simple (stupid), so just get_proxy() and get_proxies(amount).

Method Returns
get_proxy() Single proxy as a string, format {ip}:{port}
get_proxies(amount) List of amount proxies, same format as above

Exceptions

All the exceptions are defined in errors.py.

Exception Description
ProxyError Base exception that all other pubproxpy errors inherit from
APIKeyError Error raised when the API gives an incorrect API Key response
RateLimitError Error raised when the API gives a rate-limiting response (more than 1 request per second)
DailyLimitError Error raised when the API gives the daily request limit response

Metadata

Release files for pubproxpy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pubproxpy 1.0.1
File Size Uploaded Provenance Actions
pubproxpy-1.0.1.tar.gz 18.9 kB Without provenance Details for pubproxpy-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pubproxpy 1.0.1
File Interpreter ABI Platform Actions
pubproxpy-1.0.1-py3-none-any.whl Python 3 none any Details for pubproxpy-1.0.1-py3-none-any.whl

Total release size: 68.3 kB

Release files / pubproxpy-1.0.1.tar.gz

Download URL pubproxpy-1.0.1.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d6ffacb16d7b6309f8e658a71e880a2fe002f0408aab658bb3064d2f7f1c8979
BLAKE2b-256 checksum
How to use checksums
d04c3088c42b9e749ef30b99754d17eac30ecdf7b01fa15099334e202bc1b3d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.11 CPython/3.7.4 Linux/5.3.1-arch1-1-ARCH

Release files / pubproxpy-1.0.1-py3-none-any.whl

Download URL pubproxpy-1.0.1-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6ecf618a7712b1db37b3ff4890f25fe9c4d7b99723b4dbd8c516cc0fc38a67f
BLAKE2b-256 checksum
How to use checksums
51273f5d2ce316ceb3afb030160c504b14cacc8b4a45be40f5c3e401a30a757b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.11 CPython/3.7.4 Linux/5.3.1-arch1-1-ARCH

Security for pubproxpy 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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