Get an API key Your API keys

Screenshots

GET /v1/screenshot loads a page in a real browser and answers with the picture itself – ready to save, show or hand to a vision model. Visible area, whole page or one element, in the size you need.

Take a screenshot

curl -G https://api.virginproxy.com/v1/screenshot \
  -H "Authorization: Bearer $VP_KEY" \
  --data-urlencode "url=https://example.com/" \
  -d full_page=true -d width=1280 -d height=800 \
  -o page.png
import os, requests

r = requests.get(
    "https://api.virginproxy.com/v1/screenshot",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    params={"url": "https://example.com/", "full_page": "true", "width": 1280, "height": 800},
    timeout=180,
)
if not r.ok:
    raise SystemExit(r.json()["error"]["code"] + ": " + r.json()["error"]["message"])
open("page.png", "wb").write(r.content)
print(r.headers["X-VP-Credits"], "credits,", r.headers["X-VP-Request-Id"])
import { writeFile } from "node:fs/promises";

const q = new URLSearchParams({ url: "https://example.com/", full_page: "true", width: "1280", height: "800" });
const res = await fetch("https://api.virginproxy.com/v1/screenshot?" + q, {
  headers: { Authorization: "Bearer " + process.env.VP_KEY },
  signal: AbortSignal.timeout(180_000),
});
if (!res.ok) { const e = (await res.json()).error; throw new Error(e.code + ": " + e.message); }
await writeFile("page.png", Buffer.from(await res.arrayBuffer()));
console.log(res.headers.get("x-vp-credits"), "credits,", res.headers.get("x-vp-request-id"));

The answer is the image (Content-Type: image/png, image/jpeg or image/webp). Our figures travel in headers:

HeaderMeaning
X-VP-Request-IdThe id of the request in your request log.
X-VP-CreditsCredits charged.
X-VP-StatusThe status the page answered with. A screenshot of an error page is still a screenshot: check this when it matters.
X-VP-Final-URLThe address after redirects.

Options

All options are query parameters. An unknown name is refused with invalid_options instead of being ignored.

ParameterDefaultMeaning
urlrequiredThe page, absolute http or https address.
full_pagefalsetrue: the whole page (up to 16,000 pixels high) instead of the visible area.
selector–CSS selector of one element: only that element is captured.
formatpngpng, jpeg or webp.
quality801 to 100, for jpeg and webp.
widthby browserViewport width in CSS pixels, 240 to 3,840. With width or height the picture has exactly that size (scale 1).
heightby browserViewport height, 240 to 4,320. Default 768 when only width is given.
scale1Pixel density, 0.5 to 4 (2 for a sharp "retina" picture).
wait_untilloadload, domcontentloaded or networkidle.
wait_for–CSS selector to wait for before the picture is taken.
wait_ms0Extra wait at the end, 0 to 15,000 milliseconds (for animations).
scroll0Scroll to the bottom this many times first (0 to 20), for pages that load more while scrolling.
browserchromeBrowser profile, see Browsers. chrome_android or safari_ios for a phone picture.
localede-DELanguage of the visitor.
timezoneEurope/BerlinIANA time zone the page sees.
color_schemelightlight or dark.
blocknoneComma-separated resource types not to load: image, media, font, stylesheet. Loads less, costs less, looks emptier.
session–Session name: same IP and cookies as your other requests with that name.
fresh_ipfalseA new IP first (5 credits).
max_credits–Never spend more than this (at least 10).
tag–Your tag for the request log.

What it costs

Like any request rendered in a browser: 10 credits for up to 1 MB loaded, 1 more for each further MB the browser loads for the page. Images and fonts are loaded by default – a screenshot needs them – so image-heavy pages cost a little more than render in POST /v1/requests, which skips them. Use block or max_credits to keep it small. See Credits and billing.

Errors

StatusCodeWhen
422screenshot_failedThe page loaded, but no picture could be taken – usually because selector matched nothing visible. The page was loaded, so this is charged (error.credits).
424timeoutThe page did not load in time. Not charged.
400invalid_optionsAn unknown parameter or a value out of range. Not charged.

Every other code is on the errors page.

PDF documents

GET /v1/pdf loads the page in a browser the same way and answers with a PDF of it (Content-Type: application/pdf) – for invoices, reports, archiving or handing a page to a document model.

Save a page as PDF
curl -G https://api.virginproxy.com/v1/pdf \
  -H "Authorization: Bearer $VP_KEY" \
  --data-urlencode "url=https://example.com/" \
  -d wait_until=networkidle \
  -o page.pdf

It takes the loading options of screenshots: url, wait_until, wait_for, wait_ms, scroll, browser, locale, timezone, color_scheme, block, session, fresh_ip, max_credits, tag. The cost is the same as a screenshot: 10 credits for up to 1 MB loaded. When the page loaded but no PDF could be made, the answer is pdf_failed (422, charged like a loaded page). The same headers (X-VP-Request-Id, X-VP-Credits, X-VP-Status) carry our figures. Inside POST /v1/requests, render.pdf returns the PDF as base64 together with the page.

Screenshot together with the page

Need the HTML (or Markdown) and a picture in one go? Use render.screenshot in POST /v1/requests: the answer carries the page and the screenshot as base64 in screenshot, with screenshot_type.

Request body
{
  "url": "https://example.com/",
  "format": "markdown",
  "render": {
    "screenshot": {
      "full_page": true,
      "format": "jpeg",
      "quality": 70
    }
  }
}

Tip

For a picture as a phone sees it, set browser=chrome_android (or safari_ios) and leave out width: the page gets the phone's own screen size and pixel density.

Was this page helpful?

Last updated