Skip to content

Commit a31f3a3

Browse files
committed
Polish SDK repositories
1 parent ac13fc2 commit a31f3a3

8 files changed

Lines changed: 143 additions & 27 deletions

File tree

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [18, 20, 22]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: ${{ matrix.node-version }}
18+
- run: npm test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
npm-debug.log*
3+
yarn-debug.log*
4+
yarn-error.log*
5+
coverage/

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing
2+
3+
Thanks for helping improve the Proxy11 Node.js client.
4+
5+
## Local Setup
6+
7+
```bash
8+
npm test
9+
```
10+
11+
Keep changes small and focused. If you add or change behavior, add a test for it.

README.md

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
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
1420
const { ProxyClient } = require("proxy11");
1521

1622
const 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
3745
const 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
4452
const proxy = await client.random({ country: "us" });
45-
// "103.152.112.166:8080"
46-
4753
const 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
5459
const 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
6366
const 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

SECURITY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Security
2+
3+
If you find a security issue in this client or in the Proxy11 API, please do not open a public issue.
4+
5+
Email: info@proxy11.com
6+
7+
Include enough detail to reproduce the issue. We will review and respond as quickly as possible.

examples/basic.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { ProxyClient } = require("../src");
2+
3+
async function main() {
4+
const client = new ProxyClient("YOUR_API_KEY");
5+
const proxies = await client.get({ limit: 10, country: "us" });
6+
console.log(proxies);
7+
}
8+
9+
main().catch((error) => {
10+
console.error(error);
11+
process.exit(1);
12+
});

examples/rotator.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { ProxyClient } = require("../src");
2+
3+
async function main() {
4+
const client = new ProxyClient("YOUR_API_KEY");
5+
const rotator = await client.rotator({
6+
country: "us",
7+
proxyType: "anonymous",
8+
autoRefresh: true,
9+
});
10+
11+
for (let i = 0; i < 10; i += 1) {
12+
console.log(await rotator.next());
13+
}
14+
}
15+
16+
main().catch((error) => {
17+
console.error(error);
18+
process.exit(1);
19+
});

examples/save.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { ProxyClient } = require("../src");
2+
3+
async function main() {
4+
const client = new ProxyClient("YOUR_API_KEY");
5+
const count = await client.save("proxies.txt", { limit: 100, country: "us" });
6+
console.log(`saved ${count} proxies`);
7+
}
8+
9+
main().catch((error) => {
10+
console.error(error);
11+
process.exit(1);
12+
});

0 commit comments

Comments
 (0)