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

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.2.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.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: proxykit-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 9af762b0c87e718469371f635e5e140ce5c47d57556527cf320292db0c521877
MD5 d5280aef2546de52216dabcbccae2a2d
BLAKE2b-256 d762538c49de2a35733e794c4f9e20d8420fd91426cc64a703802346347363bc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for proxykit-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32aed77f90b99b6b9c4a371633564eaca06953170e1849800acd25beabb50b4f
MD5 dadc04ecaa166416d9c54ccd2b26b97a
BLAKE2b-256 be3846230d93adc68e2d88f726c5094e1a91305278c0f3f4d8f103a9f6b5b05d

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