API Endpoint Access URL
https://api.pixlab.io/screencapture
Get Your API Key & Try SCREENCAPTURE Now ↗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)}")
fetch('https://api.pixlab.io/screencapture?url=https://github.com&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("The screen capture is located on: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$url = 'https://api.pixlab.io/screencapture';
$params = [
'url' => 'https://github.com',
'key' => 'PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new RuntimeException('Curl error: ' . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "The screen capture is located on: " . $reply['link'];
}
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://api.pixlab.io/screencapture')
params = { url: 'https://github.com', key: 'PIXLAB_API_KEY' }
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
puts "The screen capture is located on: #{reply['link']}"
end