Skip to main content

ProxyKit is a lightweight Python package for managing and rotating proxy servers, user agents, and headers. It validates proxy lists and provides a context manager to easily inject reliable, random configurations into your HTTP requests.

Project description

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

(not published yet)

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

  • ip and port are required rest all are optional
  • ip can also be proper ip address with port separated by :, e.g: 127.0.0.1:8080 in this case port is 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Author

Suraj Airi - surajairi.ml@gmail.com

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

proxykit-0.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

proxykit-0.0.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file proxykit-0.0.1.tar.gz.

File metadata

  • Download URL: proxykit-0.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for proxykit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9cceacde04621ead818ff045e98475f9ae85f1251912103fea843ea1d27f96bc
MD5 deb1de8d45a13cfc2800a0082cd64e4c
BLAKE2b-256 af5a10871d4aca6eb0c0f82849dfc7f35b9f6510e9bc3e93d328e16e7cfb0802

See more details on using hashes here.

File details

Details for the file proxykit-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: proxykit-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for proxykit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac4334440def2f49cd08d4e035be036ce46ce3711e6a95549af00f13b2176da4
MD5 e790acf97330af8083372abf9d691541
BLAKE2b-256 83c83c511731f1a66d8663cb20c613d4a0b7259b4c40c62d61a94cbc231131ba

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