Get an API key Your API keys

Device and environment

A page that runs scripts can ask the browser a lot: the time zone, the location, the screen, the colour scheme, how many processor cores and how much memory there are, what it stored on the last visit. With render you decide each of these answers.

Note

These options belong into the render object and only work there: a plain request runs no JavaScript, so the page cannot ask anything.

curl https://api.virginproxy.com/v1/requests \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://httpbin.org/anything",
    "render": {
      "timezone": "America/New_York",
      "geolocation": {
        "latitude": 40.713,
        "longitude": -74.006
      },
      "viewport": {
        "width": 390,
        "height": 844,
        "scale": 3
      },
      "color_scheme": "dark",
      "actions": [
        {
          "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })"
        }
      ]
    }
  }'
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/requests",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://httpbin.org/anything",
        "render": {
            "timezone": "America/New_York",
            "geolocation": {"latitude": 40.713, "longitude": -74.006},
            "viewport": {"width": 390, "height": 844, "scale": 3},
            "color_scheme": "dark",
            "actions": [
                {
                    "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
                },
            ],
        },
    },
    timeout=180,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["steps"][0]["value"])  # {"zone": "America/New_York", "screen": "390x844", "dark": true}
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://httpbin.org/anything",
    render: {
      timezone: "America/New_York",
      geolocation: { latitude: 40.713, longitude: -74.006 },
      viewport: { width: 390, height: 844, scale: 3 },
      color_scheme: "dark",
      actions: [
        {
          evaluate: "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
        },
      ],
    },
  }),
  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.steps[0].value); // { zone: "America/New_York", screen: "390x844", dark: true }
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.request({
    "url": "https://httpbin.org/anything",
    "render": {
        "timezone": "America/New_York",
        "geolocation": {"latitude": 40.713, "longitude": -74.006},
        "viewport": {"width": 390, "height": 844, "scale": 3},
        "color_scheme": "dark",
        "actions": [
            {
                "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
            },
        ],
    },
})
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://httpbin.org/anything",
  render: {
    timezone: "America/New_York",
    geolocation: { latitude: 40.713, longitude: -74.006 },
    viewport: { width: 390, height: 844, scale: 3 },
    color_scheme: "dark",
    actions: [
      {
        evaluate: "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
      },
    ],
  },
});
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://httpbin.org/anything",
        "render" => [
            "timezone" => "America/New_York",
            "geolocation" => ["latitude" => 40.713, "longitude" => -74.006],
            "viewport" => ["width" => 390, "height" => 844, "scale" => 3],
            "color_scheme" => "dark",
            "actions" => [
                [
                    "evaluate" => "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
                ],
            ],
        ],
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo json_encode($data["steps"][0]["value"], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), PHP_EOL;
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "url": "https://httpbin.org/anything",
  "render": {
    "timezone": "America/New_York",
    "geolocation": {
      "latitude": 40.713,
      "longitude": -74.006
    },
    "viewport": {
      "width": 390,
      "height": 844,
      "scale": 3
    },
    "color_scheme": "dark",
    "actions": [
      {
        "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })"
      }
    ]
  }
}`)
	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["steps"].([]any)[0].(map[string]any)["value"])
}
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://httpbin.org/anything",
  "render" => {
    "timezone" => "America/New_York",
    "geolocation" => { "latitude" => 40.713, "longitude" => -74.006 },
    "viewport" => { "width" => 390, "height" => 844, "scale" => 3 },
    "color_scheme" => "dark",
    "actions" => [
      {
        "evaluate" => "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })",
      },
    ],
  },
})

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 JSON.pretty_generate(data)
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://httpbin.org/anything",
              "render": {
                "timezone": "America/New_York",
                "geolocation": {
                  "latitude": 40.713,
                  "longitude": -74.006
                },
                "viewport": {
                  "width": 390,
                  "height": 844,
                  "scale": 3
                },
                "color_scheme": "dark",
                "actions": [
                  {
                    "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \\"x\\" + screen.height, dark: matchMedia(\\"(prefers-color-scheme: dark)\\").matches })"
                  }
                ]
              }
            }
            """;
        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://httpbin.org/anything",
      "render": {
        "timezone": "America/New_York",
        "geolocation": {
          "latitude": 40.713,
          "longitude": -74.006
        },
        "viewport": {
          "width": 390,
          "height": 844,
          "scale": 3
        },
        "color_scheme": "dark",
        "actions": [
          {
            "evaluate": "({ zone: Intl.DateTimeFormat().resolvedOptions().timeZone, screen: screen.width + \"x\" + screen.height, dark: matchMedia(\"(prefers-color-scheme: dark)\").matches })"
          }
        ]
      }
    }
    """;
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);

Options

FieldTypeMeaning
timezonestringIANA time zone such as Europe/Berlin (default), Europe/London or America/New_York. Affects Date, Intl and everything the page derives from it.
geolocationobject{"latitude": -90…90, "longitude": -180…180, "accuracy": 1…100000} (accuracy in metres, default 50). What navigator.geolocation reports; the permission is granted automatically, so no prompt blocks the page.
viewportobject{"width": 240…3840, "height": 240…4320, "scale": 0.5…4}. Screen size in CSS pixels and the pixel density. Default: 1366 × 900 for desktop browsers, 412 × 915 at 2.625 for phones. With a phone browser, a page without a viewport tag is laid out 980 pixels wide, just like on a real phone; screen.width still reports your width.
color_schemestring"light" or "dark": what prefers-color-scheme answers.
reduced_motionbooleantrue: prefers-reduced-motion: reduce, many pages then skip animations.
cpu_coresinteger1 to 64: navigator.hardwareConcurrency.
memory_gbnumber0.25, 0.5, 1, 2, 4 or 8: navigator.deviceMemory.
javascriptbooleanfalse loads the page without running its scripts. Faster, and useful to see what a page delivers without them – but most pages that need render stay empty then.
local_storageobjectUp to 100 {"key": "text"} entries (together at most 1 MB), put into localStorage of the target's origin before the page's scripts run. Values the page sets itself are not overwritten.
session_storageobjectThe same for sessionStorage.

Many sites remember the cookie banner in localStorage. If you know the key, the banner does not appear at all:

request
{
  "url": "https://shop.example/",
  "render": {
    "local_storage": {
      "consent": "{\"necessary\":true,\"stats\":false}"
    }
  }
}

Keep it consistent

Pages compare these values with each other. A phone browser with a 2560-pixel screen, or a German language with a time zone on another continent and a location on a third, looks odd. Choose values that belong together: browser, locale, timezone, geolocation and viewport. Leave out what you do not need – the defaults already fit together.

Was this page helpful?

Last updated