ProxyKit
A lightweight Python package for managing and rotating proxy servers with built-in validation and caching.
Features
- 🔄 Multiple Data Formats: JSON, CSV, and IP list support
- ✅ Proxy Validation: Multi-threaded validation with configurable test sites
- 💾 Smart Caching: Persistent storage with TTL-based expiration
- 🎯 Context Manager: Easy integration with HTTP requests
- 🔀 Random Selection: Built-in proxy rotation
Installation
pip install proxykit
Quick Start
from proxykit import ProxyKit, ProxyLoader
from proxykit.models import ProxyDataFormat
# clear all previous Proxies
ProxyKit.clear_all_data() # Optional only if you want to have fresh start
# Load proxies from various sources
ProxyLoader.load("proxies.json", format=ProxyDataFormat.JSON)
ProxyLoader.load("https://api.example.com/proxies", format=ProxyDataFormat.JSON)
# Use with context manager
with ProxyKit() as pk:
proxy = pk.get_random_proxy()
print(f"Using proxy: {proxy.host}:{proxy.port}")
Supported Formats
ipandportare required rest all are optionalipcan also be proper ip address with port separated by:, e.g:127.0.0.1:8080in this caseportis ignored
JSON Format
ProxyLoader.load(
"proxies.json",
format=ProxyDataFormat.JSON,
entry=["data"], # Navigate nested JSON
key_mapping={
"ip": "host",
"anonymity": "anonymityLevel"
}
)
CSV Format
ProxyLoader.load(
"proxies.csv",
format=ProxyDataFormat.CSV,
key_mapping={
"ip": "proxy_host",
"port": "proxy_port"
}
)
IP List Format
# Simple text file with IP:PORT format
ProxyLoader.load("proxies.txt", format=ProxyDataFormat.IP)
API Reference
ProxyLoader
| Method | Description |
|---|---|
load(source, format, key_mapping, entry, token) |
Load proxies from file or URL |
custom_load(data) |
Load pre-parsed ProxyServer objects |
ProxyKit
| Method | Description |
|---|---|
get_random_proxy() |
Get a random validated proxy |
clear_cache() |
Clear cached proxy data |
clear_all_data() |
Static method to clear all data |
Key Mapping
Map your data fields to ProxyKit's expected format:
key-mapping required for only unmatched keys
key_mapping = {
"ip": "your_host_field",
"port": "your_port_field",
"protocol": "your_protocol_field",
"anonymity": "your_anonymity_field",
"username": "your_username_field",
"password": "your_password_field",
"country": "your_country_field",
"latency": "your_latency_field",
"is_working": "your_status_field"
}
Models
ProxyServer
@dataclass
class ProxyServer:
host: str
port: int
protocol: ProxyProtocol = ProxyProtocol.HTTP
anonymity: AnonymityLevel = AnonymityLevel.UNKNOWN
country: str | None = None
latency: float | None = None
username: str | None = None
password: str | None = None
is_working: bool = True
Enums
- ProxyProtocol:
HTTP,HTTPS,SOCKS4,SOCKS5 - AnonymityLevel:
ELITE,ANONYMOUS,TRANSPARENT,UNKNOWN - ProxyDataFormat:
JSON,CSV,IP,CUSTOM
Configuration
Customize validation settings in constants.py:
TEST_SITES = [
"https://httpbin.org/ip",
"https://icanhazip.com",
"https://example.com"
]
THREADS = 25 # Validation concurrency
Requirements
License
MIT License - see LICENSE for details.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Author
Suraj Airi - surajairi.ml@gmail.com
Release files for proxykit 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| proxykit-0.0.2.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| proxykit-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.5 kB
Release files / proxykit-0.0.2.tar.gz
| Download URL | proxykit-0.0.2.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9af762b0c87e718469371f635e5e140ce5c47d57556527cf320292db0c521877
|
|
BLAKE2b-256 checksum How to use checksums |
d762538c49de2a35733e794c4f9e20d8420fd91426cc64a703802346347363bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.2
|
Release files / proxykit-0.0.2-py3-none-any.whl
| Download URL | proxykit-0.0.2-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32aed77f90b99b6b9c4a371633564eaca06953170e1849800acd25beabb50b4f
|
|
BLAKE2b-256 checksum How to use checksums |
be3846230d93adc68e2d88f726c5094e1a91305278c0f3f4d8f103a9f6b5b05d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.2
|