A comprehensive TypeScript library for automatic proxy management with validation, rotation, and intelligent selection.
- π Automatic Proxy Rotation: Seamlessly rotate through working proxies
- π§ͺ Proxy Validation: Built-in proxy testing and validation
- β‘ Performance Optimization: Latency-based proxy selection
- π‘οΈ Fallback Support: Multiple URL fallbacks for enhanced reliability
- π― Smart Headers: Random User-Agent rotation and realistic headers
- π Comprehensive Statistics: Detailed proxy performance metrics
- π Easy Integration: Simple API with TypeScript support
- π§ Configurable: Customizable timeouts, fallbacks, and user agents
- πΎ Persistent Storage: Automatic proxy list caching and management
- π Type Safety: Full TypeScript support with comprehensive type definitions
npm install proxy-auto-ts
# or
yarn add proxy-auto-ts
# or
bun add proxy-auto-tsCurrent Version: 1.1.2
Node.js: >= 16.0.0
TypeScript: >= 5.0.0
import { ProxyManager } from 'proxy-auto-ts';
// Initialize with default configuration
const proxyManager = new ProxyManager();
// Auto-initialization on first use
const result = await proxyManager.fetchWithProxy('https://httpbin.org/ip');
console.log('Your IP:', result.data.origin);
console.log('Used proxy:', result.proxy);
console.log('Latency:', result.latency + 'ms');import { ProxyManager } from 'proxy-auto-ts';
const proxyManager = new ProxyManager();
await proxyManager.initialize(); // Explicitly initialize proxy list
const result = await proxyManager.fetchWithProxy('https://httpbin.org/ip');
console.log('Your IP:', result.data.origin);new ProxyManager(config?: ProxyManagerConfig)Configuration Options:
interface ProxyManagerConfig {
timeout?: number; // Request timeout (default: 15000ms)
validationTimeout?: number; // Proxy validation timeout (default: 8000ms)
fallbackUrls?: string[]; // Fallback URLs for testing
userAgents?: string[]; // Custom User-Agent list
proxyListPath?: string; // Custom proxy list file path
}Fetch URL through the first available working proxy with automatic fallbacks.
const result = await proxyManager.fetchWithProxy('https://example.com', 5);Find the best performing proxy based on latency.
const bestProxy = await proxyManager.findBestProxy();
console.log(`Best proxy: ${bestProxy.proxy} (${bestProxy.latency}ms)`);Fetch URL using a specific proxy.
const result = await proxyManager.fetchWithSpecificProxy(
'https://example.com',
'1.2.3.4:8080'
);Test if a specific proxy is working.
const isWorking = await proxyManager.testProxy('1.2.3.4:8080');Get proxy statistics and configuration.
const stats = proxyManager.getStats();
console.log(`Total proxies: ${stats.totalProxies}`);interface ProxyFetchResult {
data: any; // Response data
proxy: string; // Used proxy address
latency: number; // Request latency in milliseconds
}import { ProxyManager } from 'proxy-auto-ts';
const proxyManager = new ProxyManager({
timeout: 20000,
validationTimeout: 10000,
fallbackUrls: [
'https://httpbin.org/ip',
'https://api.ipify.org?format=json'
],
userAgents: [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36'
],
proxyListPath: './custom-proxies.txt'
});try {
const result = await proxyManager.fetchWithProxy('https://example.com');
console.log('Success:', result.data);
} catch (error) {
console.error('All proxies failed:', error.message);
}// Find and use the best proxy
const bestProxy = await proxyManager.findBestProxy();
// Use the best proxy for subsequent requests
const result = await proxyManager.fetchWithSpecificProxy(
'https://your-target-site.com',
bestProxy.proxy
);Create a proxies.txt file with the following format:
# Proxy List - Updated: 2025-07-06T08:23:16.183Z
# Total proxies: 59
52.74.26.202:8080 # 133ms
152.42.170.187:9090 # 171ms
188.166.230.109:31028 # 273ms
182.253.109.26:8080 # 286ms# Run comprehensive tests
bun run test
# Quick test
bun run test:quick
# Full comprehensive test
bun run test:full
# Update proxy list
bun run proxy
# Run examples
bun run examplesFor common issues and solutions, please check our TROUBLESHOOTING.md guide.
Common Issues:
- Connection timeouts: Adjust the
timeoutandvalidationTimeoutsettings - No working proxies: Update your proxy list with
bun run proxy - Rate limiting: Implement delays between requests in your application
# Clone the repository
git clone https://github.com/proxy-auto-ts/proxy-auto-ts.git
# Install dependencies
bun install
# Build the library
bun run build
# Run tests
bun run testbuild- Build the library for productionbuild:lib- Build TypeScript definitionsdev- Run development teststest- Run quick teststest:full- Run comprehensive teststest:quick- Run quick testsproxy- Update proxy list from sourcesexamples- Run example code
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This library is intended for educational and testing purposes. Users are responsible for ensuring compliance with all applicable laws and regulations when using proxy servers. Always respect website terms of service and rate limits.
- Built with TypeScript for type safety
- Uses axios for HTTP requests
- Powered by https-proxy-agent for proxy support
- Includes automatic proxy validation and rotation
- π Issues: GitHub Issues
- π Documentation: GitHub Repository
- π¬ Discussions: GitHub Discussions