11# proxy11
22
3- Lightweight Node.js client for the [ Proxy11] ( https://proxy11.com ) proxy API.
3+ [ ![ npm] ( https://img.shields.io/npm/v/proxy11.svg )] ( https://www.npmjs.com/package/proxy11 )
4+ [ ![ Node] ( https://img.shields.io/node/v/proxy11.svg )] ( package.json )
5+ [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-green.svg )] ( LICENSE )
6+
7+ Official Node.js client for the [ Proxy11] ( https://proxy11.com ) proxy API.
8+
9+ Use it to fetch fresh proxy lists, filter by country or anonymity type, rotate through proxies, and export simple ` ip:port ` files.
410
511## Install
612
@@ -14,41 +20,40 @@ npm install proxy11
1420const { ProxyClient } = require (" proxy11" );
1521
1622const client = new ProxyClient (" YOUR_API_KEY" );
23+
24+ const proxies = await client .get ({ limit: 50 , country: " us" });
25+ const proxy = await client .random ({ proxyType: " anonymous" });
26+ const proxyList = await client .asList ({ limit: 100 });
1727```
1828
19- ` Proxy11Error ` , ` APIError ` , and ` NoProxiesError ` are exported if you want to catch client-specific errors.
29+ ## Examples
2030
21- ## Get Proxies
31+ ### Get Proxies
2232
2333``` js
24- const proxies = await client .get ();
25-
26- const usProxies = await client .get ({
34+ const proxies = await client .get ({
2735 limit: 50 ,
2836 country: " us" ,
2937 proxyType: " anonymous" ,
3038 speed: 1.0 ,
3139});
3240```
3341
34- ## Get ` ip:port ` List
42+ ### Get ` ip:port ` List
3543
3644``` js
3745const proxies = await client .asList ({ limit: 50 });
3846// ["103.152.112.166:8080", "45.77.56.114:4145"]
3947```
4048
41- ## Random Proxy
49+ ### Random Proxy
4250
4351``` js
4452const proxy = await client .random ({ country: " us" });
45- // "103.152.112.166:8080"
46-
4753const proxyDetails = await client .randomProxy ();
48- // { ip: "103.152.112.166", port: "8080", country: "Indonesia", ... }
4954```
5055
51- ## Save to File
56+ ### Save to File
5257
5358``` js
5459const count = await client .save (" proxies.txt" , { country: " us" });
@@ -57,8 +62,6 @@ console.log(`saved ${count} proxies`);
5762
5863## Rotator
5964
60- Cycle through proxies with optional auto-refresh and dead-proxy removal.
61-
6265``` js
6366const rotator = await client .rotator ({
6467 country: " us" ,
@@ -73,26 +76,55 @@ for (let i = 0; i < 100; i += 1) {
7376 // if proxy fails:
7477 // rotator.markDead(proxy);
7578}
79+ ```
80+
81+ ## Error Handling
7682
77- console .log (` ${ rotator .remaining } proxies left in pool` );
83+ ``` js
84+ const { APIError , NoProxiesError , ProxyClient } = require (" proxy11" );
85+
86+ const client = new ProxyClient (" YOUR_API_KEY" );
87+
88+ try {
89+ const proxy = await client .random ({ country: " us" });
90+ console .log (proxy);
91+ } catch (error) {
92+ if (error instanceof NoProxiesError) {
93+ console .log (" No proxies matched the filters" );
94+ } else if (error instanceof APIError) {
95+ console .log (` Proxy11 API error: ${ error .message } ` );
96+ } else {
97+ throw error;
98+ }
99+ }
78100```
79101
80- ## Parameters
102+ ## API
103+
104+ | Method | Description |
105+ | --------| -------------|
106+ | ` get(filters) ` | Return proxy rows as objects |
107+ | ` asList(filters) ` | Return proxies as ` ip:port ` strings |
108+ | ` random(filters) ` | Return one random ` ip:port ` proxy |
109+ | ` randomProxy(filters) ` | Return one random proxy object |
110+ | ` save(path, filters) ` | Save ` ip:port ` proxies to a file |
111+ | ` rotator(filters) ` | Create an async proxy rotator |
81112
82- | Parameter | Type | Description |
83- | -------------| --------| --------------------------------------------------|
84- | ` limit ` | number | Max proxies to return (free: 50, ultimate: 5000) |
85- | ` country ` | string | Filter by country name or code |
86- | ` port ` | number | Filter by port number |
87- | ` speed ` | number | Max response time in seconds |
88- | ` proxyType ` | string | ` anonymous ` or ` transparent ` |
113+ ## Filters
89114
90- ## API Key
115+ | Parameter | Type | Description |
116+ | -----------| ------| -------------|
117+ | ` limit ` | number | Max proxies to return, capped by your plan |
118+ | ` country ` | string | Country name or two-letter country code |
119+ | ` port ` | number | Proxy port |
120+ | ` speed ` | number | Max response time in seconds |
121+ | ` proxyType ` | string | ` anonymous ` or ` transparent ` |
91122
92- Get a free API key at [ proxy11.com ] ( https://proxy11.com/newaccount ) .
123+ ## Links
93124
94- - ** Free plan** : 50 proxies per request
95- - ** Ultimate plan** : 5,000 proxies per request, from $12
125+ - Website: [ proxy11.com] ( https://proxy11.com )
126+ - API docs: [ proxy11.com/apidoc] ( https://proxy11.com/apidoc )
127+ - SDK page: [ proxy11.com/sdk] ( https://proxy11.com/sdk )
96128
97129## License
98130
0 commit comments