JavaScript rendering

Some pages show nothing until their scripts have run. With one option your request is loaded in a real browser, and you get the finished page back – plus a screenshot or PDF if you want one.

Start with 50 free creditsOpen playground

You send

POST /v1/requests
{
  "url": "https://app.example/search?q=lamps",
  "render": {
    "wait_for": ".results .item",
    "scroll": 2,
    "screenshot": true
  }
}
Endpoint
POST /v1/requests
Cost
9 extra credits per page
Plans
All plans, Free included
Failed requests
Not charged
Documentation
Step-by-step guide

Running headless browsers yourself means servers, memory, crashes and updates – and keeping them current takes time every week.

How VirginProxy helps

  • "render": true loads the page in a real browser; "render": "auto" uses the browser only when the page needs it – and charges it only then.
  • Wait for an element, scroll to load more, or run up to 30 steps: click, type, select, hover, press keys, run your own script.
  • Screenshots of the visible area, the whole page or one element, and PDFs – returned in the same answer.
  • Device and environment as you need them: time zone, location, screen size, dark mode, language.

How it works, step by step

  1. Switch on render

    "render": true loads the page in a real browser and returns the HTML after its scripts ran.

  2. Say when the page is ready

    Wait for an element with wait_for, or for the network to be quiet – instead of guessing a fixed time.

  3. Act on the page if needed

    Up to 30 steps: click, type, select, hover, press keys, scroll, run your own script.

  4. Take what you need

    The HTML, a screenshot or PDF, extracted fields, or the JSON the page loaded in the background.

Example request

A search page that builds its results with JavaScript: wait until the results are there, scroll twice and take a screenshot.

curl https://api.virginproxy.com/v1/requests \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://app.example/search?q=lamps",
    "render": {
      "wait_for": ".results .item",
      "scroll": 2,
      "screenshot": true
    }
  }'
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/requests",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://app.example/search?q=lamps",
        "render": {
            "wait_for": ".results .item",
            "scroll": 2,
            "screenshot": True
        }
    },
    timeout=150,
)
data = r.json()
print(data["status"], data["exit"]["ip"], 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://app.example/search?q=lamps",
    "render": {
      "wait_for": ".results .item",
      "scroll": 2,
      "screenshot": true
    }
  }),
});
const data = await res.json();
console.log(data.status, data.exit.ip, data.cost.credits);
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "url" => "https://app.example/search?q=lamps",
        "render" => [
            "wait_for" => ".results .item",
            "scroll" => 2,
            "screenshot" => true,
        ],
    ]),
    CURLOPT_TIMEOUT => 150,
]);
$data = json_decode(curl_exec($ch), true);
echo $data["status"], " ", $data["exit"]["ip"], " ", $data["cost"]["credits"];
body := strings.NewReader(`{
  "url": "https://app.example/search?q=lamps",
  "render": {
    "wait_for": ".results .item",
    "scroll": 2,
    "screenshot": true
  }
}`)
req, _ := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")

res, err := http.DefaultClient.Do(req)
if err != nil {
	log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
json.NewDecoder(res.Body).Decode(&data)
fmt.Println(data["status"], data["exit"].(map[string]any)["ip"], data["cost"].(map[string]any)["credits"])

Documentation for this feature · API reference

What comes back

The rendered page, a screenshot and the data the page loaded itself:

{
  "status": 200,
  "body": "<!doctype html><html>…</html>",
  "screenshot": "iVBORw0KGgoAAAANSUhEUgAA…",
  "captured": [ { "url": "https://app.example/api/items", "status": 200 } ],
  "cost": { "credits": 10 }
}

What it costs

A rendered page costs 10 credits – 1 for the data, 9 for the browser – as long as everything the browser loads stays under 1 MB. 5,000 rendered pages in 30 days are 50,000 credits – Starter (€19) plus 25,000 extra credits for €30, €49 in total. Try without render first: most pages do not need it, and then they cost 1 credit.

Pricing and cost examples

Good to know

  • Images, media and fonts are not loaded by default – faster and smaller answers.
  • If the page loads its data as JSON, capture it instead of parsing the finished HTML.
  • Set the device when a page reacts to it: time zone, language, screen size, dark mode.
  • Use wait_for rather than wait_ms: the request ends as soon as the page is ready.
  • Not sure a page needs the browser? "render": "auto" tries without it first and uses it only when the page needs it – the 9 browser credits are charged only then.
  • When a sequence of steps goes wrong, "trace": true inside render returns a small picture after every step, with the page’s console messages.

Questions

How much does rendering cost?

A rendered page costs 9 credits on top of the data, so a page of up to 1 MB costs 10 credits. Try without it first: most pages do not need it.

Can I get the data a page loads in the background?

Yes. Name the address patterns with "capture", and the answers of the matching background requests come back as well – often the data is already there as JSON.

Which pages need render?

Pages that show nothing until their scripts ran – many shops, apps and search pages. If the HTML without render already has your data, you do not need it.

Can I get a PDF of a page?

Yes, with "pdf": true inside render, in the same answer.

How long may a rendered request take?

Up to your plan’s timeout, 30 to 120 seconds per attempt.

How do I know whether "auto" used the browser?

The answer says so in strategy – "http" or "browser" – and strategy_attempts lists every try with its status and credits. Only the answer you get is charged.

Try it with 50 free credits

Pick up where you left off

No card needed. Your first request takes two minutes.

Your credits, keys and recent requests are waiting in the dashboard.

Start with 50 free creditsGo to dashboard