# SDKs and tools

> Small official clients for Python and Node.js (one file each, no dependencies), a Postman collection and the OpenAPI description for generating your own.

Source: https://docs.virginproxy.com/sdks/

Two small official clients – one file each, no dependencies – cover every endpoint, retry short-lived limits on their own and verify webhook signatures. Download the file into your project and import it.

| Language | File | Needs |
| --- | --- | --- |
| Python | [`virginproxy.py`](https://docs.virginproxy.com/sdk/virginproxy.py) | Python 3.8+, standard library only |
| Node.js | [`virginproxy.mjs`](https://docs.virginproxy.com/sdk/virginproxy.mjs) + [`virginproxy.d.ts`](https://docs.virginproxy.com/sdk/virginproxy.d.ts) (types) | Node.js 18+, no packages |

*Download:*

```bash
curl -O https://docs.virginproxy.com/sdk/virginproxy.py
curl -O https://docs.virginproxy.com/sdk/virginproxy.mjs
```

## Use

**Python**

```python
from virginproxy import VirginProxy, VirginProxyError

vp = VirginProxy()  # reads VP_KEY

page = vp.scrape("https://example.com/")          # Markdown of the main content
print(page["body"][:200], page["cost"]["credits"])

shot = vp.screenshot("https://example.com/", full_page=True)
open("page.png", "wb").write(shot.body)

batch = vp.batch(urls=["https://example.com/", "https://example.org/"])
job = vp.crawl("https://example.com/", max_pages=50)
vp.wait_for_job(job["id"])
for item in vp.iter_job_results(job["id"]):
    print(item["url"], item["status"])

try:
    vp.request({"url": "https://example.com/", "max_credits": 5})
except VirginProxyError as e:
    print(e.code, e.message, e.request_id)
```

**Node.js**

```javascript
import { VirginProxy, VirginProxyError } from './virginproxy.mjs';

const vp = new VirginProxy(); // reads VP_KEY

const page = await vp.scrape('https://example.com/');   // Markdown of the main content
console.log(page.body.slice(0, 200), page.cost.credits);

const shot = await vp.screenshot('https://example.com/', { full_page: true });
await import('node:fs/promises').then((fs) => fs.writeFile('page.png', shot.image));

const batch = await vp.batchUrls(['https://example.com/', 'https://example.org/']);
const job = await vp.crawl({ url: 'https://example.com/', max_pages: 50 });
await vp.waitForJob(job.id);
for await (const item of vp.iterJobResults(job.id)) console.log(item.url, item.status);

try {
  await vp.request({ url: 'https://example.com/', max_credits: 5 });
} catch (err) {
  if (err instanceof VirginProxyError) console.log(err.code, err.message, err.requestId);
}
```

## What the clients do for you

- One method per endpoint: requests, raw, screenshot, PDF, batch, map, estimate, jobs and crawls (with waiting, paging through results and export), account, usage, request log, keys and webhooks.
- Errors become an exception with the API's `code`, `status`, `request_id`, `retry_after_ms`, `charged` and `credits`.
- `rate_limited`, `concurrency_limited`, `busy` and the other [wait-and-retry codes](https://docs.virginproxy.com/errors/) are retried after the time the API asks for (2 times by default, `max_retries` / `maxRetries`). Nothing else is retried, so nothing is charged twice.
- `idempotency_key` / `idempotencyKey` on requests, jobs and crawls ([Send again safely](https://docs.virginproxy.com/limits/#idempotency)).
- Webhook signatures: `verify_webhook(secret, raw_body, header)` in Python, `VirginProxy.verifyWebhook(secret, rawBody, header)` in Node.js – constant time, with a 5-minute window.
- Test keys (`vp_test_…`) work unchanged: see [Test mode](https://docs.virginproxy.com/test-mode/).

## Which method calls which endpoint

Read from the two client files, so this table always matches the version you download. Helpers that build on another method (for example `scrape` on `request`) are listed with its endpoint.

| Endpoint | Node.js | Python |
| --- | --- | --- |
| [POST `/v1/requests`](https://docs.virginproxy.com/endpoints/#op-createRequest) | `request()`, `scrape()` | `request()`, `scrape()` |
| [GET `/v1/raw`](https://docs.virginproxy.com/endpoints/#op-rawRequest) | `raw()` | `raw()` |
| [GET `/v1/screenshot`](https://docs.virginproxy.com/endpoints/#op-screenshot) | `screenshot()` | `screenshot()` |
| [POST `/v1/estimate`](https://docs.virginproxy.com/endpoints/#op-estimate) | `estimate()` | `estimate()` |
| [GET `/v1/pdf`](https://docs.virginproxy.com/endpoints/#op-pdf) | `pdf()` | `pdf()` |
| [POST `/v1/batch`](https://docs.virginproxy.com/endpoints/#op-createBatch) | `batch()`, `batchUrls()` | `batch()` |
| [POST `/v1/map`](https://docs.virginproxy.com/endpoints/#op-mapSite) | `map()` | `map()` |
| [POST `/v1/search`](https://docs.virginproxy.com/endpoints/#op-search) | `search()` | `search()` |
| [POST `/v1/crawl`](https://docs.virginproxy.com/endpoints/#op-createCrawl) | `crawl()` | `crawl()` |
| [GET `/v1/jobs`](https://docs.virginproxy.com/endpoints/#op-listJobs) | `listJobs()` | `list_jobs()` |
| [POST `/v1/jobs`](https://docs.virginproxy.com/endpoints/#op-createJob) | `createJob()`, `createJobNdjson()` | `create_job()` |
| [GET `/v1/jobs/{id}`](https://docs.virginproxy.com/endpoints/#op-getJob) | `getJob()`, `waitForJob()` | `get_job()`, `wait_for_job()` |
| [DELETE `/v1/jobs/{id}`](https://docs.virginproxy.com/endpoints/#op-cancelJob) | `cancelJob()` | `cancel_job()` |
| [GET `/v1/jobs/{id}/results`](https://docs.virginproxy.com/endpoints/#op-getJobResults) | `jobResults()`, `iterJobResults()` | `job_results()`, `iter_job_results()` |
| [GET `/v1/jobs/{id}/stream`](https://docs.virginproxy.com/endpoints/#op-streamJobResults) | `streamJob()` | not in the client – use `call()` |
| [GET `/v1/jobs/{id}/export`](https://docs.virginproxy.com/endpoints/#op-exportJobResults) | `exportJob()` | `export_job()` |
| [POST `/v1/jobs/{id}/retry`](https://docs.virginproxy.com/endpoints/#op-retryJob) | `retryJob()` | `retry_job()` |
| [GET `/v1/requests`](https://docs.virginproxy.com/endpoints/#op-listRequests) | `listRequests()` | `list_requests()` |
| [GET `/v1/requests/{id}`](https://docs.virginproxy.com/endpoints/#op-getRequest) | `getRequest()` | `get_request()` |
| [GET `/v1/requests/{id}/answer`](https://docs.virginproxy.com/endpoints/#op-getRequestAnswer) | `getAnswer()` | `get_answer()` |
| [GET `/v1/limits`](https://docs.virginproxy.com/endpoints/#op-getLimits) | `limits()` | `limits()` |
| [PATCH `/v1/account/settings`](https://docs.virginproxy.com/endpoints/#op-updateAccountSettings) | `updateSettings()` | `update_settings()` |
| [GET `/v1/account`](https://docs.virginproxy.com/endpoints/#op-getAccount) | `account()` | `account()` |
| [GET `/v1/usage`](https://docs.virginproxy.com/endpoints/#op-getUsage) | `usage()` | `usage()` |
| [GET `/v1/usage/breakdown`](https://docs.virginproxy.com/endpoints/#op-getUsageBreakdown) | `usageBreakdown()` | `usage_breakdown()` |
| [GET `/v1/destinations`](https://docs.virginproxy.com/endpoints/#op-listDestinations) | `listDestinations()` | `list_destinations()` |
| [POST `/v1/destinations`](https://docs.virginproxy.com/endpoints/#op-createDestination) | `createDestination()` | `create_destination()` |
| [DELETE `/v1/destinations/{id}`](https://docs.virginproxy.com/endpoints/#op-deleteDestination) | `deleteDestination()` | `delete_destination()` |
| [POST `/v1/destinations/{id}/test`](https://docs.virginproxy.com/endpoints/#op-testDestination) | `testDestination()` | `test_destination()` |
| [GET `/v1/keys`](https://docs.virginproxy.com/endpoints/#op-listKeys) | `listKeys()` | `list_keys()` |
| [POST `/v1/keys`](https://docs.virginproxy.com/endpoints/#op-createKey) | `createKey()` | `create_key()` |
| [PATCH `/v1/keys/{id}`](https://docs.virginproxy.com/endpoints/#op-updateKey) | `updateKey()` | `update_key()` |
| [DELETE `/v1/keys/{id}`](https://docs.virginproxy.com/endpoints/#op-revokeKey) | `revokeKey()` | `revoke_key()` |
| [POST `/v1/keys/{id}/roll`](https://docs.virginproxy.com/endpoints/#op-rollKey) | `rollKey()` | `roll_key()` |
| [GET `/v1/webhooks`](https://docs.virginproxy.com/endpoints/#op-getWebhooks) | `getWebhooks()` | `get_webhooks()` |
| [POST `/v1/webhooks/secret`](https://docs.virginproxy.com/endpoints/#op-rotateWebhookSecret) | `rotateWebhookSecret()` | `rotate_webhook_secret()` |
| [GET `/v1/webhooks/deliveries`](https://docs.virginproxy.com/endpoints/#op-listWebhookDeliveries) | `listDeliveries()` | `list_deliveries()` |
| [GET `/v1/webhooks/deliveries/{id}`](https://docs.virginproxy.com/endpoints/#op-getWebhookDelivery) | `getDelivery()` | `get_delivery()` |
| [POST `/v1/webhooks/test`](https://docs.virginproxy.com/endpoints/#op-testWebhook) | `testWebhook()` | `test_webhook()` |
| [POST `/v1/webhooks/deliveries/{id}/redeliver`](https://docs.virginproxy.com/endpoints/#op-redeliverWebhook) | `redeliver()` | `redeliver()` |
| [GET `/v1/presets`](https://docs.virginproxy.com/endpoints/#op-listPresets) | `listPresets()` | `list_presets()` |
| [POST `/v1/presets`](https://docs.virginproxy.com/endpoints/#op-createPreset) | `createPreset()` | `create_preset()` |
| [GET `/v1/presets/{name}`](https://docs.virginproxy.com/endpoints/#op-getPreset) | `getPreset()` | `get_preset()` |
| [PATCH `/v1/presets/{name}`](https://docs.virginproxy.com/endpoints/#op-updatePreset) | `updatePreset()` | `update_preset()` |
| [DELETE `/v1/presets/{name}`](https://docs.virginproxy.com/endpoints/#op-deletePreset) | `deletePreset()` | `delete_preset()` |
| [GET `/v1/schedules`](https://docs.virginproxy.com/endpoints/#op-listSchedules) | `listSchedules()` | `list_schedules()` |
| [POST `/v1/schedules`](https://docs.virginproxy.com/endpoints/#op-createSchedule) | `createSchedule()` | `create_schedule()` |
| [GET `/v1/schedules/{id}`](https://docs.virginproxy.com/endpoints/#op-getSchedule) | `getSchedule()` | `get_schedule()` |
| [PATCH `/v1/schedules/{id}`](https://docs.virginproxy.com/endpoints/#op-updateSchedule) | `updateSchedule()`, `pauseSchedule()`, `resumeSchedule()` | `update_schedule()`, `pause_schedule()`, `resume_schedule()` |
| [DELETE `/v1/schedules/{id}`](https://docs.virginproxy.com/endpoints/#op-deleteSchedule) | `deleteSchedule()` | `delete_schedule()` |
| [POST `/v1/schedules/preview`](https://docs.virginproxy.com/endpoints/#op-previewSchedule) | `previewSchedule()` | `preview_schedule()` |
| [GET `/v1/schedules/{id}/reports`](https://docs.virginproxy.com/endpoints/#op-listScheduleReports) | `scheduleReports()` | `schedule_reports()` |
| [POST `/v1/schedules/{id}/run`](https://docs.virginproxy.com/endpoints/#op-runSchedule) | `runSchedule()` | `run_schedule()` |
| [GET `/v1/docs`](https://docs.virginproxy.com/endpoints/#op-listMemberDocs) | not in the client – use `call()` | not in the client – use `call()` |
| [GET `/v1/docs/{name}`](https://docs.virginproxy.com/endpoints/#op-getMemberDoc) | not in the client – use `call()` | not in the client – use `call()` |
| [GET `/v1/status`](https://docs.virginproxy.com/endpoints/#op-getStatus) | `status()` | `status()` |
| [GET `/v1/errors`](https://docs.virginproxy.com/endpoints/#op-listErrors) | `errors()` | `errors()` |

3 endpoints have no method of their own yet. Every endpoint can still be reached with the generic `vp.call(method, path, …)` of both clients, which adds the key, retries and error handling.

## Postman and Insomnia

The [Postman collection](https://docs.virginproxy.com/postman/virginproxy.postman_collection.json) has every endpoint with its parameters and example bodies, grouped like this documentation. Import it, then set the collection variable `VP_KEY` to your key. Insomnia, Bruno and most other API tools import the same file – or the OpenAPI description directly.

## Generate your own client

For other languages, generate a client from the [OpenAPI 3.1 description](https://api.virginproxy.com/openapi.json) with the generator you like; it is built from the same lists as this documentation and the API's own checks. Or call the API with any HTTP library, as in the [language guides](https://docs.virginproxy.com/python/).

> **Note:** The clients are offered as files on this site; there is no package on a package registry yet.
