A lightweight, zero-dependency TypeScript client library for the GetFreeProxy API. Get free proxies with simple, async/await syntax.
- ✨ Zero Dependencies — Uses only Node.js native
httpsmodule - 📦 Dual Package — ESM and CommonJS support
- 🎯 Type Safe — Full TypeScript support with comprehensive types
- 🚀 Simple API — Clean, intuitive interface with async/await
- ⚡ Lightweight — Only 5KB gzipped
- 🛡️ Error Handling — Comprehensive error wrapping
- 🧪 Well Tested — Full test coverage with Jest
- 📝 Well Documented — JSDoc comments and examples
npm install getfreeproxyyarn add getfreeproxypnpm add getfreeproxyimport{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});try{// Get proxies from first pageconstproxies=awaitclient.query();console.log(`Got ${proxies.length} proxies`);// Print first proxy detailsif(proxies.length>0){constproxy=proxies[0];console.log(`${proxy.protocol}://${proxy.ip}:${proxy.port}`);console.log(`Country: ${proxy.countryCode}`);console.log(`Uptime: ${proxy.uptime}%`);}}catch(error){console.error(`API Error: ${errorinstanceofError ? error.message : error}`);}import{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});// Get US proxiesconstusProxies=awaitclient.queryCountry('US');// Get HTTPS proxiesconsthttpsProxies=awaitclient.queryProtocol('https');// Get proxies from page 2constpage2Proxies=awaitclient.queryPage(2);// Combine multiple filtersconstproxies=awaitclient.query({country: 'US',protocol: 'https',page: 1,});import{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});try{constproxies=awaitclient.query();}catch(error){console.error(errorinstanceofError ? error.message : error);}import{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key',timeout: 10000,// 10 secondsbaseUrl: 'https://custom-api.getfreeproxy.com',// Custom API endpoint});constproxies=awaitclient.query();newClient(options: ClientOptions)Options:
apiKey(required): Your API key from GetFreeProxytimeout(optional): Request timeout in milliseconds (default: 30000)baseUrl(optional): Custom API base URL (default: https://api.getfreeproxy.com)
Retrieves proxies with optional filters.
Parameters:
params(optional): Query parameterscountry: Filter by country code (e.g., 'US', 'GB', 'DE')protocol: Filter by protocol (e.g., 'http', 'https', 'socks5')page: Page number for pagination (default: 1)
Returns: Array of proxy objects
Throws:Error on API or network errors
Example:
constproxies=awaitclient.query({country: 'US',page: 1});Convenience method to get proxies by country.
Parameters:
country: Country code (e.g., 'US', 'GB')
Returns: Array of proxy objects
Example:
constusProxies=awaitclient.queryCountry('US');Convenience method to get proxies by protocol.
Parameters:
protocol: Protocol type (e.g., 'http', 'https', 'socks5')
Returns: Array of proxy objects
Example:
consthttpsProxies=awaitclient.queryProtocol('https');Convenience method to get proxies from a specific page.
Parameters:
page: Page number
Returns: Array of proxy objects
Example:
constpage2Proxies=awaitclient.queryPage(2);interfaceProxy{id: string;// Unique identifierprotocol: string;// 'http', 'https', 'socks5', etc.ip: string;// IP addressport: number;// Port numberuser?: string;// Username (if required)passwd?: string;// Password (if required)countryCode: string;// ISO 3166-1 alpha-2 country coderegion?: string;// Region/StateasnNumber?: string;// Autonomous System NumberasnName?: string;// ASN nameanonymity: string;// Anonymity leveluptime: number;// Uptime percentage (0-100)responseTime: number;// Response time in secondslastAliveAt: string;// ISO 8601 timestampproxyUrl: string;// Full proxy URL with credentialshttps: boolean;// Supports HTTPSgoogle: boolean;// Can access Google}const{ Client }=require('getfreeproxy');constclient=newClient({apiKey: 'your-api-key'});client.query().then(proxies=>{console.log(`Got ${proxies.length} proxies`);}).catch(error=>{console.error(error.message);});import{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});constproxies=awaitclient.query();import{Client}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});asyncfunctiongetAllProxies(){constallProxies=[];for(letpage=1;page<=100;page++){try{constproxies=awaitclient.queryPage(page);if(proxies.length===0){break;// No more proxies}allProxies.push(...proxies);console.log(`Page ${page}: Got ${proxies.length} proxies`);}catch(error){console.error(`Error on page ${page}:`,error);break;}}returnallProxies;}constproxies=awaitgetAllProxies();import{Client,Proxy}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});constproxies=awaitclient.query();// Get only high-uptime proxiesconstreliableProxies=proxies.filter(p=>p.uptime>=95);// Get only proxies that support GoogleconstgoogleProxies=proxies.filter(p=>p.google);// Get only HTTPS-capable proxiesconsthttpsProxies=proxies.filter(p=>p.https);// Combine filtersconstbestProxies=proxies.filter(p=>p.uptime>=95&&p.https&&p.google);import{Client,Proxy}from'getfreeproxy';constclient=newClient({apiKey: 'your-api-key'});constproxies=awaitclient.query();for(constproxyofproxies){// Ready-to-use proxy URL with credentialsconsole.log(`Full URL: ${proxy.proxyUrl}`);// Or build manuallyconstauth=proxy.user&&proxy.passwd ? `${proxy.user}:${proxy.passwd}@` : '';consturl=`${proxy.protocol}://${auth}${proxy.ip}:${proxy.port}`;console.log(`Manual URL: ${url}`);}Visit GetFreeProxy to get your API key and manage your account.
npm test# Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportnpm run dev # Watch TypeScript compilation
npm run build # Build for production (ESM + CommonJS)
npm run lint # Run ESLint
npm run format # Format with PrettierThe package publishes both ESM and CommonJS formats:
- ESM:
dist/esm/index.mjs - CommonJS:
dist/cjs/index.js - Types:
dist/index.d.ts
This package is designed for Node.js only and uses Node.js built-in https module. Browser-based requests to the GetFreeProxy API are not supported due to CORS restrictions - the API does not allow direct calls from web browsers.
For server-side or backend use, use this package. For browser-based applications, consider implementing a proxy server or API gateway to relay requests through your own backend.
- freeproxy-go — Go implementation
- freeproxy-python — Python implementation
- freeproxy-php — PHP implementation
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © gfpcom
For API documentation and support, visit GetFreeProxy Developer Docs.