Website screenshot API
Send the address of a web page and get an image back. The whole page or only the first screen, as on a desktop or a phone.
# API key: switchfile.io/dashboard/keys. The answer is the capture as JSON; # result.file.url is the download link, valid for 24 hours. curl "https://api.switchfile.io/v1/captures?wait=30" \ -H "Authorization: Bearer $SWITCHFILE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com","output_format":"png","options":{"device":"mobile"}}'
// npm i switchfile import Switchfile from "switchfile"; const switchfile = new Switchfile({ apiKey: process.env.SWITCHFILE_API_KEY }); const capture = await switchfile.captures.create( { url: "https://example.com", output_format: "png", options: { device: "mobile" } }, { wait: true }, ); await switchfile.download(capture.result.file, "example.png");
# pip install switchfile-sdk import os import switchfile switchfile.configure(api_key=os.environ["SWITCHFILE_API_KEY"]) capture = switchfile.Capture.create( {"url": "https://example.com", "output_format": "png", "options": {"device": "mobile"}}, wait=True) switchfile.download(capture["result"]["file"], "example.png")
<?php // The answer is the capture as JSON with result.file.url. $ch = curl_init("https://api.switchfile.io/v1/captures?wait=30"); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("SWITCHFILE_API_KEY"), "Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode(["url" => "https://example.com", "output_format" => "png", "options" => ["device" => "mobile"]]), CURLOPT_RETURNTRANSFER => true, ]); $capture = json_decode(curl_exec($ch), true); echo $capture["result"]["file"]["url"] ?? $capture["status"], PHP_EOL;
What comes back
The capture comes back as JSON, with the download link in result.file.url.
What you get
Whole page or first screen
Desktop or phone
Pages behind a login
Image formats
Options
Send them in options as JSON. Options that do not fit the format are rejected with a message that names them.
| Option | Meaning |
|---|---|
| devicedevice | desktop (default) or mobile. |
| screen_ | Width of the browser window in pixels, 1440 by default (390 for mobile). |
| screen_ | Height of the window. Without it, the whole page is captured. |
| wait_ | CSS selector that must appear before the capture. |
| qualityquality | Quality for jpg and webp, 1 to 100, 80 by default. |
| transparent_ | Keep a transparent page background in png and webp. |
| cookiescookies | Cookies for the site of url, as a list of name and value. |
Where your files go
Captured on our server
Data processing agreement
Pricing
Free
20
free API key
Credit pack
ā¬7
500 credits, one-time, no subscription
Monthly
ā¬4
500 credits a month, cancel at any time
Each capture costs 1 credit, however long the page takes to load.
A capture uses 1 credit, which costs ā¬0.0043 to ā¬0.014 depending on the plan or pack.
See all pricesSDKs and integrations
Questions
About Website screenshot through the API.
What are the limits?
A page has 30 seconds to load and may load up to 50 MB. A full-page image is cut at 20000 pixels in height (webp: 16383), and the notes of the result say so. Each API key can start 30 captures per minute with credits, and 5 without credits or with a sandbox key.
Can it capture pages behind a login?
Yes. Send the session as cookies or a token in headers. Both are stored encrypted and appear as [redacted] in every response and webhook. They are deleted when the job finishes, or after 24 hours if it fails.
Does JavaScript run?
Yes. The page is loaded like a normal browser visit from our servers, with JavaScript on.
Can every website be captured?
No. The address must be reachable from the internet, and private networks are blocked. Websites that block automated visitors cannot be captured. For a check that finishes on its own we wait a few seconds; we never solve captchas.
How long do you keep my files?
The result is kept for 24 hours, then it is deleted. You can delete it earlier through the API.