Screenshot
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/screenshot \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"fullPage": true,
"selector": "<string>"
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/screenshot"
payload = {
"url": "<string>",
"fullPage": True,
"selector": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', fullPage: true, selector: '<string>'})
};
fetch('https://api.example.com/browser/sessions/{id}/screenshot', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/screenshot",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'fullPage' => true,
'selector' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/screenshot"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/screenshot")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/screenshot")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"image": "<string>",
"url": "<string>",
"width": 123,
"height": 123
}Tools
Screenshot
Capture a PNG screenshot of the active page, full-page or element-scoped.
POST
/
browser
/
sessions
/
{id}
/
screenshot
Screenshot
curl --request POST \
--url https://api.example.com/browser/sessions/{id}/screenshot \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"fullPage": true,
"selector": "<string>"
}
'import requests
url = "https://api.example.com/browser/sessions/{id}/screenshot"
payload = {
"url": "<string>",
"fullPage": True,
"selector": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', fullPage: true, selector: '<string>'})
};
fetch('https://api.example.com/browser/sessions/{id}/screenshot', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/browser/sessions/{id}/screenshot",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => '<string>',
'fullPage' => true,
'selector' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/screenshot"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/browser/sessions/{id}/screenshot")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/screenshot")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"fullPage\": true,\n \"selector\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"image": "<string>",
"url": "<string>",
"width": 123,
"height": 123
}Overview
Captures a PNG of the session’s active page and returns it base64-encoded. Supports viewport, full-page, and element-bounded capture via a CSS selector.Path Parameters
string
required
Browser session ID (UUID).
Body
string
Optional URL to navigate to before capturing.
boolean
default:"false"
When true, capture the full scrollable document height instead of just the viewport.
string
CSS selector of an element to capture. Clipped to the element’s bounding box.
Example Request
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/screenshot" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
curl -X POST "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/screenshot" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"fullPage": true
}'
Response
Success Response (200)
string
Base64-encoded PNG bytes.
string
Effective URL after any redirects.
integer
Screenshot width in pixels.
integer
Screenshot height in pixels.
{
"url": "https://example.com/",
"image": "iVBORw0KGgoAAAANSUhEUgAA...",
"width": 1920,
"height": 1080
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid body — bad selector or unreachable URL. |
401 | Unauthorized — invalid or missing API key. |
404 | Session not found, or selector matched no visible element. |
503 | The browser session is temporarily unreachable. |
Was this page helpful?
⌘I