@proxyrequest/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/SECURITY.md +13 -0
- package/dist/index.cjs +1895 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1107 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1107 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1836 -0
- package/dist/index.js.map +1 -0
- package/dist/models-ECy_bhdn.d.ts +132 -0
- package/dist/models-ECy_bhdn.d.ts.map +1 -0
- package/dist/models-VMmyyuf_.d.cts +132 -0
- package/dist/models-VMmyyuf_.d.cts.map +1 -0
- package/dist/models.cjs +0 -0
- package/dist/models.d.cts +2 -0
- package/dist/models.d.ts +2 -0
- package/dist/models.js +0 -0
- package/dist/openapi.cjs +0 -0
- package/dist/openapi.d.cts +2 -0
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +0 -0
- package/dist/schema-CvCxeox5.d.cts +9762 -0
- package/dist/schema-CvCxeox5.d.cts.map +1 -0
- package/dist/schema-CvCxeox5.d.ts +9762 -0
- package/dist/schema-CvCxeox5.d.ts.map +1 -0
- package/docs/errors-and-pagination.md +36 -0
- package/docs/getting-started.md +41 -0
- package/docs/releasing.md +25 -0
- package/docs/reseller-workflow.md +38 -0
- package/docs/webhooks.md +23 -0
- package/package.json +128 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2026-08-21
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Initial official TypeScript SDK for all 82 ProxyRequest API operations and 127 schemas.
|
|
10
|
+
- Universal Fetch transport for Node.js 22+ and modern browsers.
|
|
11
|
+
- ESM and CommonJS builds with declaration and source maps.
|
|
12
|
+
- Static, Bearer, anonymous, and explicit Telegram service authentication.
|
|
13
|
+
- Normalized errors, lazy pagination, invoice downloads, raw requests, and webhook verification.
|
|
14
|
+
- Reproducible OpenAPI generation, package validation, Node/browser tests, CI, and npm provenance workflow.
|
|
15
|
+
|
|
16
|
+
[1.0.0]: https://github.com/proxyrequest/javascript-sdk/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ProxyRequest
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# ProxyRequest TypeScript SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@proxyrequest/sdk)
|
|
4
|
+
[](https://github.com/proxyrequest/javascript-sdk/actions/workflows/ci.yml)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
The official TypeScript SDK for the [ProxyRequest public API](https://proxyrequest.com/docs/api/). It provides a typed, promise-based client for Node.js 22+ and modern browsers, with both ESM and CommonJS builds.
|
|
9
|
+
|
|
10
|
+
## What is ProxyRequest?
|
|
11
|
+
|
|
12
|
+
[ProxyRequest](https://proxyrequest.com/) is the control plane for operating a white-label proxy platform. It connects the commercial and operational pieces that a proxy provider or reseller would otherwise have to build separately:
|
|
13
|
+
|
|
14
|
+
- customer and sub-user accounts;
|
|
15
|
+
- packages, traffic allocations, connection limits, and proxy credentials;
|
|
16
|
+
- invoices, payment links, coupons, rewards, and reseller workflows;
|
|
17
|
+
- residential and static ISP proxy inventory, targeting, routing, and sessions;
|
|
18
|
+
- usage accounting, analytics, operational visibility, and webhooks;
|
|
19
|
+
- dashboard, branding, API automation, and Telegram integration.
|
|
20
|
+
|
|
21
|
+
This SDK talks to the management API at `https://api.proxyrequest.com/api/v1`. It is not itself an HTTP/SOCKS proxy client. The credentials returned by the proxy generation endpoints are used separately by your application, browser, scraper, or other proxy-aware software.
|
|
22
|
+
|
|
23
|
+
Start with the [platform overview](https://proxyrequest.com/docs/), then see [API fundamentals](https://proxyrequest.com/docs/integration/api-fundamentals/) and the [API resource map](https://proxyrequest.com/docs/integration/api-resource-map/).
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @proxyrequest/sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @proxyrequest/sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn add @proxyrequest/sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { ProxyRequestClient } from "@proxyrequest/sdk";
|
|
43
|
+
|
|
44
|
+
const client = ProxyRequestClient.withApiKey(process.env.PROXYREQUEST_API_KEY!);
|
|
45
|
+
|
|
46
|
+
const users = await client.users.list({ limit: 25, search: "customer@example.com" });
|
|
47
|
+
for (const user of users.results) {
|
|
48
|
+
console.log(user.id, user.username);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
CommonJS is supported as well:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const { ProxyRequestClient } = require("@proxyrequest/sdk");
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`Client` is exported as a shorter alias for `ProxyRequestClient`.
|
|
59
|
+
|
|
60
|
+
## Authentication
|
|
61
|
+
|
|
62
|
+
Static API keys are intended for trusted backend services:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const client = ProxyRequestClient.withApiKey(process.env.PROXYREQUEST_API_KEY!, {
|
|
66
|
+
language: "en",
|
|
67
|
+
timeoutMs: 15_000,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Dashboard access tokens use Bearer authentication:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const client = ProxyRequestClient.withBearerToken(accessToken);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Public login, signup, locations, and similar calls can use an anonymous client:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const client = ProxyRequestClient.anonymous();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Never embed a Static API key, Telegram service secret, or webhook secret in frontend JavaScript. Browser support is intended for anonymous or appropriately scoped end-user token flows. See the service documentation on [authentication and API fundamentals](https://proxyrequest.com/docs/integration/api-fundamentals/).
|
|
84
|
+
|
|
85
|
+
## Resource API
|
|
86
|
+
|
|
87
|
+
The client exposes all 82 operations through 19 resource groups:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
client.apiKeys;
|
|
91
|
+
client.affiliates;
|
|
92
|
+
client.analytics;
|
|
93
|
+
client.authorization;
|
|
94
|
+
client.coupons;
|
|
95
|
+
client.invoices;
|
|
96
|
+
client.locations;
|
|
97
|
+
client.news;
|
|
98
|
+
client.orders;
|
|
99
|
+
client.packages;
|
|
100
|
+
client.profile;
|
|
101
|
+
client.proxies;
|
|
102
|
+
client.rewards;
|
|
103
|
+
client.sessions;
|
|
104
|
+
client.settings;
|
|
105
|
+
client.telegram;
|
|
106
|
+
client.telegramService;
|
|
107
|
+
client.users;
|
|
108
|
+
client.webhooks;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Method and option names use idiomatic `camelCase`. Request and response bodies preserve the API's `snake_case` JSON fields, so the values you inspect are exactly the values sent over the wire.
|
|
112
|
+
|
|
113
|
+
### Create a managed user
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const user = await client.users.create({
|
|
117
|
+
body: {
|
|
118
|
+
username: "customer_123",
|
|
119
|
+
password: "a-long-random-password",
|
|
120
|
+
is_reseller: false,
|
|
121
|
+
is_top_level: false,
|
|
122
|
+
package_id: "7ef79941-a099-4e4e-9282-a231bc683003",
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Read [users and data](https://proxyrequest.com/docs/integration/users-and-data/) for traditional and package-based account models.
|
|
128
|
+
|
|
129
|
+
### Add data to a user's order
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
await client.users.addData({
|
|
133
|
+
id: user.id!,
|
|
134
|
+
body: {
|
|
135
|
+
package_id: "7ef79941-a099-4e4e-9282-a231bc683003",
|
|
136
|
+
data: 10 * 1024 ** 3,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Create an invoice and payment link
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const invoice = await client.invoices.create({
|
|
145
|
+
body: {
|
|
146
|
+
gateway: "stripe",
|
|
147
|
+
package_id: "7ef79941-a099-4e4e-9282-a231bc683003",
|
|
148
|
+
user_id: user.id,
|
|
149
|
+
data: 10 * 1024 ** 3,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const payment = await client.invoices.getPaymentLink({ id: invoice.id! });
|
|
154
|
+
console.log(payment.payment_url);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Invoice creation is the normal API workflow for selling packages or topping up a user. Review [reseller workflow](https://proxyrequest.com/docs/integration/reseller-workflow/) and [billing and growth](https://proxyrequest.com/docs/integration/billing-and-growth/) before implementing checkout.
|
|
158
|
+
|
|
159
|
+
### Generate proxy credentials
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
const generated = await client.proxies.generate({
|
|
163
|
+
body: {
|
|
164
|
+
package_id: "7ef79941-a099-4e4e-9282-a231bc683003",
|
|
165
|
+
user_id: user.id,
|
|
166
|
+
quantity: 5,
|
|
167
|
+
targeting: { country: "US" },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
console.log(generated.proxies);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
See [catalog and proxies](https://proxyrequest.com/docs/integration/catalog-and-proxies/) and the separate [proxy connection documentation](https://proxyrequest.com/docs/proxy/authentication/).
|
|
175
|
+
|
|
176
|
+
## Pagination
|
|
177
|
+
|
|
178
|
+
List methods return the API page model. Use `client.paginate()` when you want a lazy async stream:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
for await (const user of client.paginate(
|
|
182
|
+
({ limit, offset }) => client.users.list({ limit, offset, ordering: "-created" }),
|
|
183
|
+
{ limit: 100 },
|
|
184
|
+
)) {
|
|
185
|
+
console.log(user.username);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The iterator follows `next`, rejects repeated pages, and stops after a configurable safety limit.
|
|
190
|
+
|
|
191
|
+
## Errors
|
|
192
|
+
|
|
193
|
+
Every non-2xx API response and transport failure is normalized as `ApiError`:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { ApiError } from "@proxyrequest/sdk";
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
await client.users.get({ id: "missing-user-id" });
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (error instanceof ApiError) {
|
|
202
|
+
console.error(error.kind, error.statusCode, error.detail);
|
|
203
|
+
console.error(error.fieldErrors, error.requestId, error.retryAfter);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Kinds include `validation`, `authentication`, `permission`, `not_found`, `conflict`, `rate_limit`, `server`, `network`, and `unexpected`. The SDK does not retry or refresh tokens automatically. See [common integration errors](https://proxyrequest.com/docs/integration/common-errors/).
|
|
209
|
+
|
|
210
|
+
## Per-request controls and custom Fetch
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const controller = new AbortController();
|
|
214
|
+
|
|
215
|
+
await client.analytics.getOverall({
|
|
216
|
+
start: "2026-08-01",
|
|
217
|
+
end: "2026-08-31",
|
|
218
|
+
request: {
|
|
219
|
+
signal: controller.signal,
|
|
220
|
+
timeoutMs: 30_000,
|
|
221
|
+
headers: { "X-Correlation-ID": crypto.randomUUID() },
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Frameworks such as SvelteKit or test suites can inject their own Fetch implementation:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
const client = ProxyRequestClient.withBearerToken(token, { fetch });
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Invoice PDFs
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
const download = await client.invoices.downloadPdf({ id: invoice.id! });
|
|
236
|
+
|
|
237
|
+
// Node.js
|
|
238
|
+
const { writeFile } = await import("node:fs/promises");
|
|
239
|
+
await writeFile(download.filename, download.content);
|
|
240
|
+
|
|
241
|
+
// Browser
|
|
242
|
+
const objectUrl = URL.createObjectURL(download.blob());
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`FileDownload` is deliberately filesystem-independent. It exposes `content`, `filename`, `contentType`, `arrayBuffer()`, `blob()`, and `text()`.
|
|
246
|
+
|
|
247
|
+
## Webhooks
|
|
248
|
+
|
|
249
|
+
Always verify the exact raw request body before parsing JSON:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
import { WebhookVerifier } from "@proxyrequest/sdk";
|
|
253
|
+
|
|
254
|
+
const event = await WebhookVerifier.decodeVerifiedJson(
|
|
255
|
+
rawBody,
|
|
256
|
+
request.headers.get("ProxyRequest-Signature") ?? "",
|
|
257
|
+
process.env.PROXYREQUEST_WEBHOOK_SECRET!,
|
|
258
|
+
);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Verification supports the `t=...,v1=...` format, multiple `v1` values, Web Crypto HMAC-SHA256, and a default five-minute tolerance. See the [webhook integration guide](https://proxyrequest.com/docs/integration/webhooks/) and [event reference](https://proxyrequest.com/docs/reference/webhook-events/).
|
|
262
|
+
|
|
263
|
+
## Raw requests
|
|
264
|
+
|
|
265
|
+
Use the escape hatch for a newly introduced endpoint that is not yet present in the generated resources:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
const response = await client.request("POST", "/new-endpoint", {
|
|
269
|
+
query: { preview: true },
|
|
270
|
+
body: { example_field: "value" },
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
It reuses base URL, authentication, language, timeout, cancellation, and `ApiError` behavior.
|
|
275
|
+
|
|
276
|
+
## Types and generated code
|
|
277
|
+
|
|
278
|
+
All 127 OpenAPI model types are exported from both the package root and `@proxyrequest/sdk/models`:
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import type { User, InvoiceCreateRequestRequest } from "@proxyrequest/sdk/models";
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Advanced consumers can import raw schema types:
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
import type { paths, operations } from "@proxyrequest/sdk/openapi";
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Generated files are committed for reproducible builds. Run `npm run generate` after replacing `openapi/openapi.yaml`; CI uses `npm run generate:check` to reject stale output.
|
|
291
|
+
|
|
292
|
+
## Development
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
npm ci
|
|
296
|
+
npm run generate:check
|
|
297
|
+
npm run lint
|
|
298
|
+
npm run typecheck
|
|
299
|
+
npm test
|
|
300
|
+
npm run build
|
|
301
|
+
npm run validate:package
|
|
302
|
+
npm run test:package
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
The repository also has a real Chromium smoke test via `npm run test:browser`.
|
|
306
|
+
|
|
307
|
+
## More documentation
|
|
308
|
+
|
|
309
|
+
- [Getting started](docs/getting-started.md)
|
|
310
|
+
- [Reseller workflow](docs/reseller-workflow.md)
|
|
311
|
+
- [Errors and pagination](docs/errors-and-pagination.md)
|
|
312
|
+
- [Webhook verification](docs/webhooks.md)
|
|
313
|
+
- [Release process](docs/releasing.md)
|
|
314
|
+
- [Full API reference](https://proxyrequest.com/docs/api/)
|
|
315
|
+
- [Platform changelog](https://proxyrequest.com/changelog/)
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
[MIT](LICENSE)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Security fixes are provided for the latest released major version.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Do not open a public issue for a vulnerability. Email `support@proxyrequest.com` with a description, reproduction steps, affected versions, and potential impact. Avoid including active API keys, tokens, webhook secrets, or customer data.
|
|
10
|
+
|
|
11
|
+
## Credential handling
|
|
12
|
+
|
|
13
|
+
Static API keys, Telegram service secrets, and webhook secrets belong only in trusted server environments. Rotate any credential that may have been exposed and remove it from Git history and build artifacts. Bearer tokens used in browsers should be short-lived and scoped according to the ProxyRequest API documentation.
|