Get Screenshot
Retrieve the details and download URL of a specific screenshot using its request ID.
Endpoint
Section titled “Endpoint”GET https://api.peekshot.com/api/v1/screenshots/{requestId}
Authentication
Section titled “Authentication”All requests must include the x-api-key
header with a valid API key.
Request Headers
Section titled “Request Headers”Header | Required | Description |
---|---|---|
x-api-key | Yes | Your unique API key for authentication |
Path Parameters
Section titled “Path Parameters”Parameter | Type | Required | Description |
---|---|---|---|
requestId | integer | Yes | The unique ID of the screenshot request |
Example Request
Section titled “Example Request”curl --location 'https://api.peekshot.com/api/v1/screenshots/123' \
--header 'x-api-key: your-api-key'
const axios = require("axios");
const getScreenshot = async (requestId) => {
const config = {
method: "get",
url: `https://api.peekshot.com/api/v1/screenshots/${requestId}`,
headers: {
"x-api-key": "your-api-key",
},
};
try {
const response = await axios.request(config);
console.log(JSON.stringify(response.data));
return response.data;
} catch (error) {
console.log(error);
throw error;
}
};
// Usage
const screenshot = await getScreenshot(123);
import requests
def get_screenshot(request_id):
url = f"https://api.peekshot.com/api/v1/screenshots/{request_id}"
api_key = "your-api-key"
headers = {
"x-api-key": api_key
}
response = requests.get(url, headers=headers)
print("Response Code:", response.status_code)
print("Response Body:", response.json())
return response.json()
# Usage
screenshot = get_screenshot(123)
<?php
$requestId = 123;
$apiUrl = "https://api.peekshot.com/api/v1/screenshots/$requestId";
$apiKey = "your-api-key";
// Initialize cURL
$ch = curl_init($apiUrl);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"x-api-key: $apiKey"
]);
// Execute the request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
echo "cURL Error: " . curl_error($ch);
} else {
echo "Response (HTTP $httpCode): " . $response;
}
// Close cURL session
curl_close($ch);
?>
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
requestId := "123"
url := "https://api.peekshot.com/api/v1/screenshots/" + requestId
// Create an HTTP request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("x-api-key", "your-api-key")
// Send the request using http.Client
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read and print the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("Response:", string(body))
}
Response
Section titled “Response”Success Response (200 OK)
Section titled “Success Response (200 OK)”When the screenshot is completed:
{
"status": "success",
"message": "screenshot request status fetched successfully",
"data": {
"id": 1,
"organizationId": 1,
"projectId": 1,
"status": "COMPLETE",
"url": "https://peekshot.com/",
"screenshotImageSize": 1012796,
"options": {
"delay": 0,
"fresh": true,
"width": 1680,
"height": 867,
"output": "json",
"retina": false,
"language": "en-GB,en-US;q=0.9,en;q=0.8",
"block_ads": false,
"dark_mode": false,
"file_type": "jpeg",
"full_page": false,
"disable_javascript": false,
"block_cookie_banner": false
},
"screenshotUrl": "https://peekshot.s3.ap-south-1.amazonaws.com/6/image.jpeg",
"creditsRequired": 1,
"duration": "9.864",
"isActive": true,
"createdAt": "2025-03-23T09:11:25.906Z",
"updatedAt": "2025-03-23T09:11:25.906Z",
"deletedAt": null,
"deletedByUserId": null
},
"statusCode": 200
}
Error Responses
Section titled “Error Responses”Status Code | Error Message | Description |
---|---|---|
400 | Invalid Request | Check your input parameters |
403 | Forbidden | Invalid or inactive API key |
500 | Internal Server Error | Something went wrong on our end |
Best Practices
Section titled “Best Practices”-
Implement Polling Logic: For screenshots that take time to process, implement polling with reasonable intervals (2-5 seconds)
-
Handle Different Status States: Always check the status field and handle all possible states appropriately
-
Cache Results: Once a screenshot is completed, cache the download URL to avoid repeated API calls
-
Error Handling: Implement robust error handling for network issues and API errors
-
Optimize Polling: Use reasonable intervals when polling to avoid unnecessary load
Related Endpoints
Section titled “Related Endpoints”- Take Screenshot - Create new screenshots
- Screenshots List - List all screenshots
- Projects List - Manage screenshot projects