Cache, change tracking, presets and schedules
Four things that save credits and code when you read the same pages again and again: keep answers and reuse them for free, be told when a page changed, save your options once under a name, and let a job run every hour or every day – always with a cap on what it may cost.
Reuse an answer: the cache
Add cache and the answer is kept. The same request within max_age_s gets it again at once and for 0 credits; nothing is fetched. true keeps it one hour; from 60 seconds to 7 days is possible.
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {
"max_age_s": 3600
}
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {"max_age_s": 3600},
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/requests", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://shop.example/products/42",
format: "markdown",
cache: { max_age_s: 3600 },
}),
signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {"max_age_s": 3600},
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
url: "https://shop.example/products/42",
format: "markdown",
cache: { max_age_s: 3600 },
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 180,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://shop.example/products/42",
"format" => "markdown",
"cache" => ["max_age_s" => 3600],
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {
"max_age_s": 3600
}
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 180 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/requests")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"url" => "https://shop.example/products/42",
"format" => "markdown",
"cache" => { "max_age_s" => 3600 },
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 180) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {
"max_age_s": 3600
}
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/requests"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(180))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"url": "https://shop.example/products/42",
"format": "markdown",
"cache": {
"max_age_s": 3600
}
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/requests");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/requests≈ 1 creditOpen in PlaygroundA reused answer is marked. Its id is the request that fetched it, so the request log shows one charged request.
{
"id": "req_V3nQ8xLp2KdW7sTm0RcY",
"status": 200,
"body": "<!doctype html>…",
"cost": { "credits": 0, "credits_used": 412, "credits_included": 25000 },
"cached": true,
"cached_at": "2026-11-25T08:00:12Z",
"cache_expires_at": "2026-11-25T09:00:12Z",
"…": "…"
}What makes two requests “the same”: every option except tag, echo, max_credits and cache itself – in any order. Only answers below status 400 are kept.
Note
Without cache nothing is kept: the page content of a request is not stored. With it, the answer is kept up to its age (at most 7 days, up to 256 MB per account; the oldest go first) and then deleted.
Know when a page changed
With track_changes the answer says whether the page is new to you, the same as last time or changed. Compared is your last request for the same page read the same way (address, method, format, extract, parse).
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example/products/42",
"extract": {
"price": {
"selector": ".price",
"type": "number"
}
},
"track_changes": {
"on": "extracted",
"diff": true
}
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://shop.example/products/42",
"extract": {"price": {"selector": ".price", "type": "number"}},
"track_changes": {"on": "extracted", "diff": True},
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/requests", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://shop.example/products/42",
extract: { price: { selector: ".price", type: "number" } },
track_changes: { on: "extracted", diff: true },
}),
signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://shop.example/products/42",
"extract": {"price": {"selector": ".price", "type": "number"}},
"track_changes": {"on": "extracted", "diff": True},
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
url: "https://shop.example/products/42",
extract: { price: { selector: ".price", type: "number" } },
track_changes: { on: "extracted", diff: true },
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 180,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://shop.example/products/42",
"extract" => ["price" => ["selector" => ".price", "type" => "number"]],
"track_changes" => ["on" => "extracted", "diff" => true],
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://shop.example/products/42",
"extract": {
"price": {
"selector": ".price",
"type": "number"
}
},
"track_changes": {
"on": "extracted",
"diff": true
}
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 180 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/requests")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"url" => "https://shop.example/products/42",
"extract" => { "price" => { "selector" => ".price", "type" => "number" } },
"track_changes" => { "on" => "extracted", "diff" => true },
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 180) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"url": "https://shop.example/products/42",
"extract": {
"price": {
"selector": ".price",
"type": "number"
}
},
"track_changes": {
"on": "extracted",
"diff": true
}
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/requests"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(180))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"url": "https://shop.example/products/42",
"extract": {
"price": {
"selector": ".price",
"type": "number"
}
},
"track_changes": {
"on": "extracted",
"diff": true
}
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/requests");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/requests≈ 1 creditOpen in Playground{
"id": "req_Q1rT7uWx3YzA5bC9dE2f",
"status": 200,
"extracted": { "price": 79 },
"change": {
"status": "changed",
"previous_request": "req_V3nQ8xLp2KdW7sTm0RcY",
"previous_at": "2026-11-24T08:00:03Z",
"diff": {
"added": ["{\"extracted\": {\"price\": 79}}"],
"removed": ["{\"extracted\": {\"price\": 89}}"],
"added_count": 1, "removed_count": 1, "truncated": false
}
},
"…": "…"
}"on": "body"(default) compares the page itself, whitespace folded."on": "extracted"compares only whatextract,parseorai_extractread – a new banner or ad does not count then."diff": truenames the lines that came and went (up to 200 each). The text is kept for that; withoutdiffonly a hash of it is kept."key": "…"names what you watch yourself, for example one product across addresses.- Change tracking is free. A page not requested for 90 days starts again as
new.
Tip
In a job, send only what changed to your server: "webhook": {"url": "…", "events": ["item.changed"]}.
Save options as a preset
Long render and extraction options belong in one place. Save them once with a key that has the manage permission …
curl https://api.virginproxy.com/v1/presets \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {
"wait_for": ".price"
},
"extract": {
"price": {
"selector": ".price",
"type": "number"
},
"title": {
"selector": "h1"
}
}
}
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/presets",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {"wait_for": ".price"},
"extract": {
"price": {"selector": ".price", "type": "number"},
"title": {"selector": "h1"},
},
},
},
timeout=30,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/presets", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
name: "shop-product",
description: "Product pages",
request: {
render: { wait_for: ".price" },
extract: {
price: { selector: ".price", type: "number" },
title: { selector: "h1" },
},
},
}),
signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.call("POST", "/v1/presets", {
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {"wait_for": ".price"},
"extract": {
"price": {"selector": ".price", "type": "number"},
"title": {"selector": "h1"},
},
},
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("POST", "/v1/presets", { body: {
name: "shop-product",
description: "Product pages",
request: {
render: { wait_for: ".price" },
extract: {
price: { selector: ".price", type: "number" },
title: { selector: "h1" },
},
},
} });
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/presets");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "shop-product",
"description" => "Product pages",
"request" => [
"render" => ["wait_for" => ".price"],
"extract" => [
"price" => ["selector" => ".price", "type" => "number"],
"title" => ["selector" => "h1"],
],
],
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {
"wait_for": ".price"
},
"extract": {
"price": {
"selector": ".price",
"type": "number"
},
"title": {
"selector": "h1"
}
}
}
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/presets", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/presets")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"name" => "shop-product",
"description" => "Product pages",
"request" => {
"render" => { "wait_for" => ".price" },
"extract" => {
"price" => { "selector" => ".price", "type" => "number" },
"title" => { "selector" => "h1" },
},
},
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 30) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {
"wait_for": ".price"
},
"extract": {
"price": {
"selector": ".price",
"type": "number"
},
"title": {
"selector": "h1"
}
}
}
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/presets"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(30))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"name": "shop-product",
"description": "Product pages",
"request": {
"render": {
"wait_for": ".price"
},
"extract": {
"price": {
"selector": ".price",
"type": "number"
},
"title": {
"selector": "h1"
}
}
}
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/presets");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/presets… and use them by name in a request, a job (also per item), a crawl's request or a batch. Options you send win over the preset's (one level deep for objects such as render).
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example/products/42",
"preset": "shop-product"
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://shop.example/products/42",
"preset": "shop-product",
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/requests", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://shop.example/products/42",
preset: "shop-product",
}),
signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://shop.example/products/42",
"preset": "shop-product",
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
url: "https://shop.example/products/42",
preset: "shop-product",
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 180,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://shop.example/products/42",
"preset" => "shop-product",
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://shop.example/products/42",
"preset": "shop-product"
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 180 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/requests")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"url" => "https://shop.example/products/42",
"preset" => "shop-product",
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 180) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"url": "https://shop.example/products/42",
"preset": "shop-product"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/requests"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(180))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"url": "https://shop.example/products/42",
"preset": "shop-product"
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/requests");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/requests≈ 1 creditOpen in PlaygroundList, change and delete them with GET /v1/presets, PATCH /v1/presets/{name} and DELETE /v1/presets/{name}. Up to 100 per account. In the dashboard's playground: Presets → Save these options as a preset.
A cost cap for jobs and crawls
max_credits on a job or crawl caps the whole run. Once it has used that many credits, requests that have not started end as job_budget_reached and are not charged. The job shows budget: the cap, what was used and what is left.
curl https://api.virginproxy.com/v1/jobs \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"format": "markdown"
},
"max_credits": 500
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/jobs",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"urls": ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults": {"format": "markdown"},
"max_credits": 500,
},
timeout=30,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/jobs", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
urls: ["https://shop.example/p/1", "https://shop.example/p/2"],
defaults: { format: "markdown" },
max_credits: 500,
}),
signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.create_job({
"urls": ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults": {"format": "markdown"},
"max_credits": 500,
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.createJob({
urls: ["https://shop.example/p/1", "https://shop.example/p/2"],
defaults: { format: "markdown" },
max_credits: 500,
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"urls" => ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults" => ["format" => "markdown"],
"max_credits" => 500,
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"format": "markdown"
},
"max_credits": 500
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/jobs", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/jobs")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"urls" => ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults" => { "format" => "markdown" },
"max_credits" => 500,
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 30) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"format": "markdown"
},
"max_credits": 500
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/jobs"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(30))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"format": "markdown"
},
"max_credits": 500
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/jobs");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/jobsurls with defaults sends the same options for many addresses; requests still takes a full body per item. GET /v1/jobs/{id}?wait=25 answers as soon as the job moves on (or after the seconds), instead of polling every second.
Run a job again and again
A schedule starts the same job or crawl every interval: 5m, 15m, 30m, 1h, 6h, 12h, 1d or 7d – or on a rhythm in words such as "weekdays at 09:30" (see Monitors). max_credits is required: it caps every run.
Tip
With "track": "pages" a schedule becomes a monitor: every run is compared with the last, and you get an e-mail or webhook when pages appear, disappear or change.
curl https://api.virginproxy.com/v1/schedules \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"preset": "shop-product",
"track_changes": {
"on": "extracted"
}
},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": [
"item.changed"
]
}
}
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/schedules",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults": {"preset": "shop-product", "track_changes": {"on": "extracted"}},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": ["item.changed"],
},
},
},
timeout=30,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/schedules", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
name: "Prices",
every: "1h",
max_credits: 200,
job: {
urls: ["https://shop.example/p/1", "https://shop.example/p/2"],
defaults: { preset: "shop-product", track_changes: { on: "extracted" } },
webhook: {
url: "https://your-server.example/hooks/virginproxy",
events: ["item.changed"],
},
},
}),
signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.create_schedule({
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults": {"preset": "shop-product", "track_changes": {"on": "extracted"}},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": ["item.changed"],
},
},
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.createSchedule({
name: "Prices",
every: "1h",
max_credits: 200,
job: {
urls: ["https://shop.example/p/1", "https://shop.example/p/2"],
defaults: { preset: "shop-product", track_changes: { on: "extracted" } },
webhook: {
url: "https://your-server.example/hooks/virginproxy",
events: ["item.changed"],
},
},
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/schedules");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Prices",
"every" => "1h",
"max_credits" => 200,
"job" => [
"urls" => ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults" => [
"preset" => "shop-product",
"track_changes" => ["on" => "extracted"],
],
"webhook" => [
"url" => "https://your-server.example/hooks/virginproxy",
"events" => ["item.changed"],
],
],
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"preset": "shop-product",
"track_changes": {
"on": "extracted"
}
},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": [
"item.changed"
]
}
}
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/schedules", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/schedules")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"name" => "Prices",
"every" => "1h",
"max_credits" => 200,
"job" => {
"urls" => ["https://shop.example/p/1", "https://shop.example/p/2"],
"defaults" => {
"preset" => "shop-product",
"track_changes" => { "on" => "extracted" },
},
"webhook" => {
"url" => "https://your-server.example/hooks/virginproxy",
"events" => ["item.changed"],
},
},
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 30) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"preset": "shop-product",
"track_changes": {
"on": "extracted"
}
},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": [
"item.changed"
]
}
}
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/schedules"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(30))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"name": "Prices",
"every": "1h",
"max_credits": 200,
"job": {
"urls": [
"https://shop.example/p/1",
"https://shop.example/p/2"
],
"defaults": {
"preset": "shop-product",
"track_changes": {
"on": "extracted"
}
},
"webhook": {
"url": "https://your-server.example/hooks/virginproxy",
"events": [
"item.changed"
]
}
}
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/schedules");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/schedules- Runs never overlap: while the last run is still open, the next one is left out.
- A schedule pauses itself when the account cannot pay (credits or daily cap used up), its key was revoked or the account is suspended – you get a notice in the dashboard.
paused_reasonsays why;PATCHwith{"status": "active"}resumes it. POST /v1/schedules/{id}/runstarts a run now. Per plan: Free 1 schedule (daily at most), Starter 5 (hourly), Growth 20 (every 15 minutes), Scale 50 (every 5 minutes).- In the dashboard: send many addresses as a job and choose Repeat; the jobs page lists your schedules with pause, resume and run now.
Pace yourself
GET /v1/limits shows what your plan and key allow right now and how much of it is in use – before a big batch, instead of running into 429 or 402. Free, with the read or requests permission.
{
"concurrency": { "limit": 5, "in_use": 2, "peak_today": 5 },
"rate": { "limit": 5, "now": 1.2, "avg_5s": 0.8, "peak_today": 4.6 },
"daily_cap": { "cap": 2000, "used": 1240, "left": 760, "resets_at": "2026-11-26T00:00:00Z" },
"key": { "id": "41", "credit_limit": null, "daily_limit": 500, "daily_used": 120, "daily_left": 380 }
}The daily cap, the credit alert thresholds and the alert webhook can be set through the API too: PATCH /v1/account/settings with daily_cap, alert_thresholds, alert_hook_url or alert_hook_slack (a key with manage).
Get a kept answer again
GET /v1/requests/{id}/answer returns the answer itself when it is kept: requests sent with an Idempotency-Key (24 hours) and cached answers (up to their age). Useful after a broken connection: nothing runs again, nothing is charged. Otherwise 404 answer_not_kept.
The request log takes the dashboard's filters too: GET /v1/requests?host=shop&kind=render&status_class=4xx&from=2026-11-24T00:00:00Z. Each record names its kind, key_id and the parts of its cost.
Respect robots.txt
Crawls and maps take robots: "respect" leaves out what the site's robots.txt disallows for us (or for every agent), "report" (map only) keeps those addresses marked with "disallowed": true. Reading robots.txt is an ordinary request of 1 credit. The default is "ignore".
Standard records without selectors
parse reads product, article, organization and breadcrumbs from the page's structured data – name, price, currency, availability, brand, rating; headline, author, dates; and so on. Fields the page does not give are null; nothing is guessed from the visible text.
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shop.example/products/42",
"parse": [
"product",
"breadcrumbs"
]
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://shop.example/products/42",
"parse": ["product", "breadcrumbs"],
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["status"], data["cost"]["credits"])const res = await fetch("https://api.virginproxy.com/v1/requests", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://shop.example/products/42",
parse: ["product", "breadcrumbs"],
}),
signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.status, data.cost.credits);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://shop.example/products/42",
"parse": ["product", "breadcrumbs"],
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
url: "https://shop.example/products/42",
parse: ["product", "breadcrumbs"],
});
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 180,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://shop.example/products/42",
"parse" => ["product", "breadcrumbs"],
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["status"], " ", $data["cost"]["credits"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://shop.example/products/42",
"parse": [
"product",
"breadcrumbs"
]
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 180 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["status"], data["cost"].(map[string]any)["credits"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/requests")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"url" => "https://shop.example/products/42",
"parse" => ["product", "breadcrumbs"],
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 180) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["status"], data["cost"]["credits"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"url": "https://shop.example/products/42",
"parse": [
"product",
"breadcrumbs"
]
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/requests"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(180))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"url": "https://shop.example/products/42",
"parse": [
"product",
"breadcrumbs"
]
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/requests");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("status") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));/v1/requests≈ 1 creditOpen in PlaygroundWas this page helpful?
Last updated