Metadata-Version: 2.5
Name: proxy-string
Version: 1.0.2
Summary: Proxy server data representation and parser package.
Project-URL: Homepage, https://github.com/sergey-scat/proxy-string
Project-URL: Documentation, https://sergey-scat.github.io/proxy-string/
Project-URL: Issues, https://github.com/sergey-scat/proxy-string/issues
Author-email: Sergey Scat <py.unicaps@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries
Requires-Python: <4,>=3.12
Requires-Dist: aiofiles>=25.1.0
Requires-Dist: attrs>=26.1.0
Requires-Dist: pywhatwgurl>=0.1.2
Provides-Extra: ada-url
Requires-Dist: ada-url>=4.0.0; extra == 'ada-url'
Provides-Extra: can-ada
Requires-Dist: can-ada>=3.1.0; extra == 'can-ada'
Description-Content-Type: text/markdown

<p align="center">
  <img src="assets/logo.jpg" alt="proxy-string logo" width="220" />
</p>

<h1 align="center">proxy-string</h1>

<p align="center">
  <a href="https://sergey-scat.github.io/proxy-string/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-blue.svg" alt="Documentation" /></a>
  <a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.12%2B-blue.svg" alt="Python" /></a>
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
  <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/badge/code%20style-ruff-000000.svg" alt="Code style: ruff" /></a>
  <a href="https://github.com/bwhmather/ty"><img src="https://img.shields.io/badge/types-ty-blueviolet.svg" alt="Checked with ty" /></a>
  <a href="https://github.com/sergey-scat/proxy-string"><img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg" alt="Coverage" /></a>
</p>

<p align="center">
  A lightweight, type-safe Python library for parsing, validating, and converting proxy server connection data.
</p>

<p align="center">
  <strong><a href="https://sergey-scat.github.io/proxy-string/">📖 Read the Documentation</a></strong>
</p>

---

## Features

- **WHATWG URL Standard**: Conforms to modern WHATWG URL standards via pure-Python `pywhatwgurl` with optional high-speed C++ backends (`can-ada`, `ada-url`).
- **Protocols Supported**: HTTP, HTTPS, SOCKS4, and SOCKS5 (with `socks4a` and `socks5h` remote DNS schemes).
- **Network Compatibility**: Full support for IPv4, IPv6 (RFC bracketed), UTF-8 Unicode credentials, and IDN / Punycode domain names.
- **Flexible Ingestion**: Parse from URLs, strings (with format auto-detection), dictionaries, JSON, and text files (sync & async generators).
- **Immutable & Safe**: Frozen `@attrs.frozen` instances with `with_*` evolution methods and strict port/protocol validation.
- **Client Integrations**: Built-in `prepare_for()` for `requests`, `httpx`, `aiohttp`, `playwright`, `curl_cffi`, and more.

---

## Installation

```bash
# Using uv (recommended)
uv add proxy-string

# Using pip
pip install proxy-string
```

For maximum URL parsing throughput, optional C++ WHATWG URL backends can be installed:

```bash
uv add "proxy-string[can_ada]"  # or "proxy-string[ada_url]"
```

---

## Quick Start

```python
from proxy_string import ProxyServer, ProxyServerProtocol

# 1. Parse from URL (supports Unicode credentials and remote DNS)
proxy = ProxyServer.from_url("socks5h://юзер:пароль@proxy.example.com:1080")
print(proxy.protocol)  # ProxyServerProtocol.SOCKS5
print(proxy.remote_dns)  # True

# 2. Parse from text string (format auto-detected)
auto = ProxyServer.from_string("192.168.1.1:8080:alice:secret")
print(auto.host)  # '192.168.1.1'
print(auto.port)  # 8080

# 3. Create modified copies (objects are immutable)
updated = auto.with_port(9090).with_creds("bob", "new_pass")

# 4. Export configuration for third-party HTTP clients
requests_config = updated.prepare_for("requests")
print(requests_config)
# {'http': 'http://bob:new_pass@192.168.1.1:9090', 'https': 'http://bob:new_pass@192.168.1.1:9090'}
```

---

## Documentation

Full documentation with interactive search and detailed guides is available at:
**[https://sergey-scat.github.io/proxy-string/](https://sergey-scat.github.io/proxy-string/)**

- **[Installation Guide](https://sergey-scat.github.io/proxy-string/getting-started/installation/)**: Package installation and C++ backend selection.
- **[Quickstart Tutorial](https://sergey-scat.github.io/proxy-string/getting-started/quickstart/)**: Step-by-step introduction.
- **[Parsing Sources](https://sergey-scat.github.io/proxy-string/guides/parsing/)**: Parsing URLs, strings, files (sync/async), JSON, and IDN.
- **[Supported Formats](https://sergey-scat.github.io/proxy-string/guides/formats/)**: Detailed proxy string formats and auto-detection rules.
- **[Modifying Proxies](https://sergey-scat.github.io/proxy-string/guides/evolution/)**: Immutability and `with_*` methods.
- **[Client Integrations](https://sergey-scat.github.io/proxy-string/guides/integrations/)**: Configuration recipes for `requests`, `httpx`, `aiohttp`, `playwright`, `curl_cffi`, etc.
- **[API Reference](https://sergey-scat.github.io/proxy-string/reference/proxy-server/)**: Complete autogenerated reference for all classes and functions.

---

## Development

```bash
# Clone the repository
git clone https://github.com/sergey-scat/proxy-string.git
cd proxy-string

# Install all dependencies including docs and dev groups
uv sync --all-extras --dev --group docs

# Run tests with coverage
uv run pytest

# Check code formatting and linting
uv run ruff check .
uv run ruff format --check .

# Static type check
uv run ty check src/proxy_string

# Build documentation locally
uv run mkdocs serve
```

---

## License

This project is licensed under the [MIT License](LICENSE).
