Skip to content

Machine-readable: OpenAPI 3.1 specification (JSON)

Screenshot

The Screenshot Service provides a screenshot method that allows you to capture screenshots or thumbnails of any website. You can choose to render the webpage using either a desktop or mobile browser simulation. Additionally, the captured image can be resized to specified dimensions and output in either JPEG, PNG or PDF formats, offering flexible options for your screenshot needs.
To get access to the methods below, you need an API token for this web service. You can create one by clicking on the button below.

Available packages for quick integrations:

  • Python
    $ pip install hqapi-client
  • PHP
    $ composer require hqapi/hqapi-client
If your language is not listed, you can use the documentation below to create your own client.

Global Usage Statistics

The Screenshot methods:

POST /api/v1/{token}/screenshot/create

The Screenshot Create method captures a screenshot of a specified website URL. You can customize the virtual browser's width and height, choose to emulate a mobile device, and specify the output image format as either JPEG or PNG. To receive the webpage as PDF document specify format PDF. Additionally, the resulting image can be resized to your desired dimensions, providing flexible options for generating website thumbnails or screenshots.
Parameter Type Default Description
url (required) string The website URL to capture. Supported schemes: http and https.
theme string light The browser theme to use.

light|dark

browser_width int 1600 Width of the virtual browser viewport in pixels.

Range: 600 .. 1920

browser_height int 900 Height of the virtual browser viewport in pixels.

Range: 400 .. 8000

delay int 2500 Milliseconds to wait after page load before capturing the screenshot. Allows all resources and scripts to finish loading. Must be at least 3000 when hide_cookie_popups is true (the default of 2500 is then refused).

Range: 0 .. 5000

format string png The desired output of the image.

jpeg|png|pdf

jpeg_quality int 95 JPEG quality (1-100) for the output image. Used only if format=jpeg.

Range: 1 .. 100

image_width int Width in pixels to resize the image before sending. If only one dimension is provided, the other is auto-calculated to preserve aspect ratio.

Range: 32 .. 1920

image_height int Height in pixels to resize the image before sending. If only one dimension is provided, the other is auto-calculated to preserve aspect ratio.

Range: 32 .. 8000

mobile bool false If true, renders the screenshot with a mobile browser user agent and viewport settings.

false|true

hide_cookie_popups bool false If true, attempts to hide cookie popups on the page. Requires a delay of at least 3000 ms: the default delay of 2500 is refused.

false|true

full_page bool false If true, captures a screenshot of the entire page (up to 8000px height).

false|true

Example create requests:

Capture a screenshot with viewport 1024x768 and resize output to 640x480 PNG.
curl -o example.png -X POST -H "Content-Type: application/json" --data '{"url":"https://example.com/","browser_width":1024,"browser_height":768,"image_width":640,"image_height":480,"format":"png"}' \
    "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/create"
The response:
Content-type: image/png
Example response image
Capture a mobile-rendered screenshot of https://wikipedia.org.
curl -o example.png -X POST -H "Content-Type: application/json" --data '{"url":"https://wikipedia.org/","mobile":true}' \
    "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/create"
The response:
Content-type: image/png
Example response image
Capture a mobile screenshot of https://wikipedia.org resized to 100px width.
curl -o example.png -X POST -H "Content-Type: application/json" --data '{"url":"https://wikipedia.org/","mobile":true,"image_width":100}' \
    "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/create"
The response:
Content-type: image/png
Example response image
Capture a PDF document of https://wikipedia.org.
curl -o example.pdf -X POST -H "Content-Type: application/json" --data '{"url":"https://wikipedia.org/","format":"pdf"}' \
    "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/create"
The response:
Content-type: application/pdf
Capture a full-page screenshot of https://mozilla.org.
curl -o example.png -X POST -H "Content-Type: application/json" --data '{"url":"https://mozilla.org/","full_page":true}' \
    "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/create"
The response:
Content-type: image/png
Example response image

Try it now!

We have created a page with all the arguments and one of your tokens to test this create method out yourself.

GET /api/v1/{token}/screenshot/nop

Example nop requests:

curl "https://api.eu-west.hqapi.com/api/v1/YourToken01/screenshot/nop"
The response:
{}

Try it now!

We have created a page with all the arguments and one of your tokens to test this nop method out yourself.

Errors and limits

A successful call returns the image or PDF itself, with HTTP status 200. Anything else returns JSON with the HTTP status repeated in code and a human-readable message:

{"code": 429, "message": "You have exceeded the maximum number of concurrent calls."}
Status Meaning What to do
400 A parameter is missing or not valid, for example a URL that is not http(s) or does not resolve to a public address. Fix the request; the message names the parameter. Do not retry unchanged.
401 The token is unknown, or not valid for this API. Check the token on this page when logged in.
402 The token is inactive. Check your subscription.
429 More calls are running at the same time on this token than your plan allows. Retry after a short wait, for example after 1, 2 and 4 seconds.
500 The page could not be rendered. Retry once; if it keeps failing, the page itself is the problem.
502 Bad gateway: a part of the service did not answer. Retry in a minute.
504 No screenshot within 62 seconds. Retry later; a lower delay or no full_page makes it faster.

Limits

  • browser_width 600 to 1920, browser_height 400 to 8000 pixels. mobile uses a 640 by 1136 window.
  • image_width 32 to 1920 and image_height 32 to 8000 pixels, and at most twice the browser size per side: an image can be scaled up at most 2 times.
  • full_page captures at most 8000 pixels of the page's height.
  • delay 0 to 5000 milliseconds, and at least 3000 with hide_cookie_popups.
  • jpeg_quality 1 to 100.
  • A page gets 15 seconds to load; one that is still loading is stopped and captured as it is. The API answers within 62 seconds.
  • Only public http and https addresses: no localhost or internal networks.
  • How many calls may run at the same time, and how many a month, depends on your plan: see pricing.
  • Call the API from your server, not from an <img> tag in a web page: a GET request that comes from another site (with a Referer header) gets a "blocked" image, so your token is not exposed and used by others.