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.pngimport 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:
| Header | Meaning |
|---|---|
X-VP-Request-Id | The id of the request in your request log. |
X-VP-Credits | Credits charged. |
X-VP-Status | The status the page answered with. A screenshot of an error page is still a screenshot: check this when it matters. |
X-VP-Final-URL | The address after redirects. |
Options
All options are query parameters. An unknown name is refused with invalid_options instead of being ignored.
| Parameter | Default | Meaning |
|---|---|---|
url | required | The page, absolute http or https address. |
full_page | false | true: 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. |
format | png | png, jpeg or webp. |
quality | 80 | 1 to 100, for jpeg and webp. |
width | by browser | Viewport width in CSS pixels, 240 to 3,840. With width or height the picture has exactly that size (scale 1). |
height | by browser | Viewport height, 240 to 4,320. Default 768 when only width is given. |
scale | 1 | Pixel density, 0.5 to 4 (2 for a sharp "retina" picture). |
wait_until | load | load, domcontentloaded or networkidle. |
wait_for | – | CSS selector to wait for before the picture is taken. |
wait_ms | 0 | Extra wait at the end, 0 to 15,000 milliseconds (for animations). |
scroll | 0 | Scroll to the bottom this many times first (0 to 20), for pages that load more while scrolling. |
browser | chrome | Browser profile, see Browsers. chrome_android or safari_ios for a phone picture. |
locale | de-DE | Language of the visitor. |
timezone | Europe/Berlin | IANA time zone the page sees. |
color_scheme | light | light or dark. |
block | none | Comma-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_ip | false | A 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
| Status | Code | When |
|---|---|---|
| 422 | screenshot_failed | The page loaded, but no picture could be taken – usually because selector matched nothing visible. The page was loaded, so this is charged (error.credits). |
| 424 | timeout | The page did not load in time. Not charged. |
| 400 | invalid_options | An 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.
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.pdfIt 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.
{
"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