Skip to main content

Use a proxy as a string, but achieve broad functionality for various scenarios

Project description

omniproxy

CI PyPI version Python versions Documentation License: MIT

omniproxy parses proxy strings into a str subclass with structured fields (ip, port, credentials, protocol, optional rotation URL), checks proxies through pluggable HTTP clients (httpx, aiohttp, requests, curl_cffi, tls_client), and ships sync/async proxy pools with cooldowns, filters, optional rate limits, and background health monitoring. A small CLI bulk-checks files and scrapes proxy-like lines from URLs.

Use it when you want one canonical type for “proxy as string” in configs and logs, but still need reachability checks, anonymity hints, and pool orchestration without rewriting glue code each time.


Key features

  • String-like Proxy type — behaves as a canonical proxy string while exposing structured data and metadata (latency, anonymity, optional geo-style fields).
  • Many input formatshost:port, colon/pipe auth variants, full URLs, SOCKS, bracketed IPv6, trailing [rotation_url] for mobile proxies.
  • Multi-backend checks — sync and async APIs; optional anonymity classification; configurable default URL lists and retries.
  • I/O helpers — read/write proxy lists; fetch_proxies to scrape pages over HTTPS.
  • PoolsSyncProxyPool / AsyncProxyPool with round-robin or random selection, lifecycle hooks, optional HealthMonitor.
  • CLIomniproxy check and omniproxy scrape for quick operational workflows.
  • Typedpy.typed marker; suitable for strict typing in downstream projects.

Documentation

Full narrative docs, CLI details, and an API reference (MkDocs + Material + mkdocstrings) are published from main:

https://mfdi.github.io/omniproxy/


Installation

Python: 3.10 or newer (requires-python = ">=3.10").

Runtime dependencies (always installed with the wheel): msgspec, orjson. HTTP clients are optional extras—install at least one backend you intend to use for checks or the built-in httpx helpers.

pip

pip install omniproxy

With an HTTP backend (recommended for checks and Client / AsyncClient):

pip install "omniproxy[httpx]"

Other extras:

pip install "omniproxy[aiohttp]"
pip install "omniproxy[requests]"
pip install "omniproxy[curl_cffi]"
pip install "omniproxy[tls_client]"
pip install "omniproxy[all]"

uv

uv add omniproxy

With extras:

uv add "omniproxy[httpx]"
uv add "omniproxy[all]"

Quickstart

from omniproxy import Proxy

proxy = Proxy("login:password@210.173.88.77:3001")

print(proxy)         # http://login:password@210.173.88.77:3001
print(proxy.url)     # canonical URL
print(proxy.server)  # protocol://ip:port (no credentials)
print(proxy.as_requests_proxies())

Supported shapes include host:port, host:port:login:password, login:password@host:port, host:port|login:password, and http:// / socks5:// URLs. Mobile rotation API in brackets:

Proxy("login:password@host:port[https://rotate.example/api]")

Full usage

Checking proxies

from omniproxy import Proxy, check_proxy, check_proxies

single = Proxy("10.0.0.1:8000")
proxy, ok = check_proxy(single)

good, bad = check_proxies(
    ["10.0.0.1:8000", "10.0.0.2:8000"],
    backend="httpx",
    detect_anonymity=True,
)

Async: acheck_proxy, acheck_proxies, await proxy.acheck(...), await proxy.aget_info(...).

HTTP client wrappers (httpx)

Requires omniproxy[httpx]:

from omniproxy import AsyncClient, Client, Proxy

proxy = Proxy("socks5://login:password@127.0.0.1:9050")

with Client(proxy=proxy) as client:
    print(client.get("https://httpbin.org/ip").status_code)

Proxy pool

from omniproxy import ProxyPool

pool = ProxyPool(["10.0.0.1:8000", "10.0.0.2:8000"], strategy="round_robin")
print(pool.get_next())

For new code, prefer SyncProxyPool / AsyncProxyPool from omniproxy.pool (see docs — Pools).

Global configuration

from omniproxy import settings

settings.default_backend = "httpx"
settings.default_timeout = 10.0
settings.default_check_urls = ["https://api.ipify.org/?format=json"]

default_check_urls is a non-empty list used for reachability checks (with rotation across entries on retry). Templates for with_info=True live in settings.default_check_info_url_templates (each must contain {fields}). Details: Configuration.

CLI

omniproxy check proxies.txt --backend httpx --timeout 8 --output-good good.txt
omniproxy scrape https://example.com/proxies -o scraped.txt

See CLI documentation and omniproxy --help.


Project structure

omniproxy/
├── omniproxy/              # Library package
│   ├── backends/           # httpx, aiohttp, requests, curl_cffi, tls_client
│   ├── cli.py
│   ├── config.py
│   ├── extended_proxy.py   # Proxy subclass, checks, bulk helpers
│   ├── io.py
│   ├── pool.py
│   ├── proxy.py
│   ├── utils.py
│   └── ...
├── tests/
├── docs/                   # MkDocs site source
├── examples/               # Runnable examples
├── scripts/
├── .github/workflows/      # CI (ruff, mypy), docs deploy
├── mkdocs.yml
├── pyproject.toml
├── uv.lock
├── README.md
├── LICENSE
└── FEATURES.md             # Architecture checklist (reviewer map)

Contributing

  1. Fork the repository and create a feature branch from main.
  2. Make your changes; keep commits focused and messages clear.
  3. Style: this repo uses Ruff for linting (and formatting where configured). Run uv run ruff check omniproxy tests before opening a PR.
  4. Types: run uv run mypy omniproxy when you touch typing-sensitive code.
  5. Tests: run uv run pytest locally; fix failures and avoid regressions.
  6. Open a pull request against main with a short description of the change and any trade-offs.

Changelog

There is no root CHANGELOG.md yet. Release history and tags are tracked on GitHub:

https://github.com/mfdi/omniproxy/releases

For semantic versioning, follow the version in omniproxy/__init__.py and PyPI.


Development (from a clone)

uv sync --group dev --group httpx   # or rely on [tool.uv] default-groups
uv run ruff check omniproxy tests
uv run mypy omniproxy
uv run pytest
uv build

Preview documentation:

uv sync --group dev --group httpx
uv run mkdocs serve

License

This project is licensed under the MIT License — see LICENSE.

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

omniproxy-4.0.0.tar.gz (240.1 kB view details)

Uploaded Source

Built Distribution

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

omniproxy-4.0.0-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file omniproxy-4.0.0.tar.gz.

File metadata

  • Download URL: omniproxy-4.0.0.tar.gz
  • Upload date:
  • Size: 240.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for omniproxy-4.0.0.tar.gz
Algorithm Hash digest
SHA256 51d0a90c46ce6597b12db6254189ed122857a461bac5f8a77ede17cd4e79d11e
MD5 de711f50c9e364a44adfd8e791d6cc60
BLAKE2b-256 3151ddd67904c3c9ce5d27afa2b38cfd5a800c67cbc746e132ca2aff325c608a

See more details on using hashes here.

File details

Details for the file omniproxy-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: omniproxy-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for omniproxy-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd8280705d33a5bd709b4872929ba9669422f2235f3eaac5b34a5231783e1088
MD5 7f8375f46eb94639d5ac1c6979399a5c
BLAKE2b-256 75fd580cfd85f09edc72383ac8bfb115b8c60da552607a20038cd4a9e45b4d14

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