Browser profiles
A browser sends more than a User-Agent: a set of headers in a fixed order and its own connection settings. Every request through VirginProxy is sent with such a complete, current browser profile, so pages are delivered the way a browser receives them. By default that is Chrome on a Windows computer; browser chooses another one.
Choose a browser
| browser | Looks like |
|---|---|
chrome | Chrome on Windows. The default. |
chrome_mac | Chrome on a Mac. |
chrome_android | Chrome on an Android phone. The default when you use render. |
edge | Microsoft Edge on Windows. |
firefox | Firefox on Windows. |
safari | Safari on a Mac. |
safari_ios | Safari on an iPhone. |
none | No browser headers: only the headers you send, plus a User-Agent, Accept: */* and Accept-Encoding. Meant for APIs that expect a program, not a person. |
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://httpbin.org/headers",
"browser": "safari_ios",
"locale": "en-US"
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://httpbin.org/headers",
"browser": "safari_ios",
"locale": "en-US",
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["browser"], data["http_version"])
print(data["body"]) # the headers as the target received themconst 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/headers",
browser: "safari_ios",
locale: "en-US",
}),
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.browser, data.http_version);
console.log(data.body); // the headers as the target received themfrom virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://httpbin.org/headers",
"browser": "safari_ios",
"locale": "en-US",
})
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/headers",
browser: "safari_ios",
locale: "en-US",
});
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/headers",
"browser" => "safari_ios",
"locale" => "en-US",
], 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["browser"], " ", $data["http_version"], PHP_EOL;
echo $data["body"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://httpbin.org/headers",
"browser": "safari_ios",
"locale": "en-US"
}`)
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["browser"], data["http_version"])
fmt.Println(data["body"])
}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/headers",
"browser" => "safari_ios",
"locale" => "en-US",
})
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/headers",
"browser": "safari_ios",
"locale": "en-US"
}
""";
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/headers",
"browser": "safari_ios",
"locale": "en-US"
}
""";
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);/v1/requests≈ 1 creditOpen in PlaygroundWhat "looks like a browser" means
- The connection. The encrypted connection is negotiated the way that browser does it, and HTTP/2 is used wherever the site supports it, as browsers do.
http_versionin the response tells you which version was used. - The headers. The request carries the headers that browser sends when you open a page (User-Agent, Accept, Accept-Language, the client hints of Chrome and Edge, the Sec-Fetch headers and so on), with matching values and in the browser's order.
- Redirects. Each step of a redirect is sent as the browser would send it, with the cookies collected so far.
Language: locale
locale is the language of the visitor and fills Accept-Language. The default is de-DE. Use a language code, optionally with a region: en, en-US, fr-FR, pt-BR.
| locale | Accept-Language sent |
|---|---|
de-DE | de-DE,de;q=0.9,en;q=0.8 |
en-US | en-US,en;q=0.9 |
fr | fr,en;q=0.8 |
en | en |
When rendering, locale is also the language the browser reports to the page's scripts.
Your own headers win
Headers you send in headers replace the browser's headers of the same name, whatever their case. Headers the browser does not send are added after its own. An empty value leaves a header out completely.
{
"url": "https://www.example.com/page",
"headers": {
"Referer": "https://www.example.org/",
"Sec-Fetch-Site": "cross-site",
"Priority": ""
}
}Note
A User-Agent of your own that does not match the rest of the browser profile gives an inconsistent request. To use another browser profile, choose it with browser.
Which browser to pick
- Start with the default. It works for most sites.
- To see the mobile version of a page, choose
chrome_androidorsafari_ios. - For JSON APIs,
nonesends only what you specify.
With render, chrome_android and safari_ios load the page as a phone (small screen, touch), every other value as a desktop computer.
Was this page helpful?
Last updated