# Browser profiles

> Every VirginProxy request is sent with a complete, current browser profile: headers, their order and the connection settings. How to choose the browser and the language.

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

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](https://docs.virginproxy.com/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**

```bash
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"
  }'
```

**Python**

```python
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 them
```

**Node.js**

```javascript
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/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 them
```

**Python SDK**

```pysdk
from 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)
```

**Node SDK**

```nodesdk
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**

```php
<?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;
```

**Go**

```go
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"])
}
```

POST`/v1/requests`[≈ 1 credit](https://docs.virginproxy.com/billing/#cost)[Open in Playground](https://dash.virginproxy.com/playground#request=eyJ1cmwiOiJodHRwczovL2h0dHBiaW4ub3JnL2hlYWRlcnMiLCJicm93c2VyIjoic2FmYXJpX2lvcyIsImxvY2FsZSI6ImVuLVVTIn0)

## What "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_version` in 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.

```json
{
  "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_android` or `safari_ios`.
- For JSON APIs, `none` sends 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.
