SCREENCAPTURE API Endpoint

Version 2.197 (Release Notes ↗)

Description

Extract a screen capture from any website URL with the SCREENCAPTURE API endpoint. Perfect for developers and creators looking to integrate screenshot functionality into their projects.

Extract a screen capture from a given website URL.

HTTP Methods

GET

HTTP Parameters

Required

Fields Type Description
url URL Website to extract a screen capture from.
key String Your PixLab API Key ↗.

Optional

Fields Type Description
width Integer Desired capture width. If this parameter is missing, then the default width is set to 1280px.
height Integer Desired capture height. If this parameter is missing, then the default width is set to 1024px.
zoom Integer Zoom factor. A value between 1 .. 10.
export File Format Desired image output format. Only png or jpeg output format are allowed. If this field is missing then png is the default format.
blob Boolean By default, this API endpoint return a JSON Object holding the link to the image output. But, if the Blob parameter is set to true then the image binary contents is returned instead.

HTTP Response

The endpoint returns application/json if the optional blob parameter is not set.

This endpoint returns a JSON Object after each call only if the optional blob parameter is not set. Otherwise, the image binary contents are returned directly. The following fields are included in the JSON response body:

Fields Type Description
status Integer Status code 200 indicates success, any other code indicates failure.
link URL Link to the image output (your screen capture) which is stored on the pixlab.xyz storage server unless you configure custom S3 keys (refer to your dashboard ↗ for configuration).
id String Unique image identifier.
error String Error message when status != 200

Code Samples


import requests


def capture_screenshot(url: str, api_key: str) -> str:
    """Capture a screenshot using the PixLab API and return the image URL."""
    endpoint = "https://api.pixlab.io/screencapture"
    params = {"url": url, "key": api_key}
    
    try:
        response = requests.get(endpoint, params=params, timeout=10)
        response.raise_for_status()
        data = response.json()
        
        if data.get("status") != 200:
            raise ValueError(data.get("error", "Unknown error occurred"))
            
        return data["link"]
        
    except requests.exceptions.RequestException as e:
        raise ConnectionError(f"API request failed: {str(e)}")


if __name__ == "__main__":
    try:
        screenshot_url = capture_screenshot(
            url="https://github.com",
            api_key="PIXLAB_API_KEY"
        )
        print(f"The screen capture is located at: {screenshot_url}")
    except Exception as e:
        print(f"Error: {str(e)}")
← Return to API Endpoint Listing