API Documentation
Complete guide to integrating Snapito screenshot API into your application
Getting Started
The Snapito API provides a simple way to capture website screenshots programmatically. To get started, you'll need an API key.
Step 1: Sign Up
Create a free account at app.snapito.io
Step 2: Get Your API Key
Navigate to your dashboard and copy your API key from the settings page.
Step 3: Make Your First Request
Use the endpoint below with your API key to capture your first screenshot.
Authentication
All API requests require authentication using your API key. Include your key in the URL path:
https://api.snapito.io/v2/webshot/YOUR_API_KEY
Basic Usage
The simplest way to capture a screenshot is to make a GET request with the target URL:
GET https://api.snapito.io/v2/webshot/YOUR_API_KEY?url=example.com
This returns a JPEG image of example.com at default dimensions (800x600 pixels).
Example Response
The API returns the image directly as a binary response with appropriate headers:
Content-Type: image/jpeg
Content-Length: 245680
Cache-Control: public, max-age=86400
Parameters
Customize your screenshots with the following URL parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
string | required | The URL to capture. Can be with or without http:// |
size |
string | 800x600 | Viewport size in format WIDTHxHEIGHT. Use 0 for full page. |
format |
string | jpg | Output format: jpg, png, or pdf |
quality |
integer | 90 | JPEG quality (1-100). Only applies to JPEG format. |
delay |
integer | 0 | Delay in milliseconds before capture (0-10000) |
cache |
integer | 1 | Use cached screenshot if available. Set to 0 to force fresh capture. |
fullpage |
boolean | true | Capture entire page height |
ua |
string | Chrome | User agent string for the request |
Example with Parameters
https://api.snapito.io/v2/webshot/YOUR_API_KEY?url=example.com&size=1280x0&format=png&quality=95&delay=2000
Response Format
The API returns the screenshot image directly in the requested format. Response headers include:
HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 245680
X-Snapito-Cache: HIT
X-Snapito-Render-Time: 3.2s
Cache-Control: public, max-age=86400
Response Headers
X-Snapito-Cache- HIT or MISS, indicates if screenshot was cachedX-Snapito-Render-Time- Time taken to render the screenshotX-Snapito-Quota-Remaining- Screenshots remaining in your monthly quota
Error Handling
The API uses standard HTTP status codes. In case of errors, a JSON response is returned:
| Status Code | Description |
|---|---|
| 200 | Success - Screenshot returned |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
Error Response Example
{
"error": "invalid_url",
"message": "The provided URL is not valid",
"status": 400
}
Rate Limits
Rate limits vary by plan:
- Free: 10 requests per minute
- Starter: 30 requests per minute
- Professional: 60 requests per minute
- Business: 120 requests per minute
- Enterprise: Custom limits
Check the X-RateLimit-Remaining header to monitor your usage.
Code Examples
cURL
curl -o screenshot.jpg "https://api.snapito.io/v2/webshot/YOUR_API_KEY?url=example.com"
PHP
<?php
$apiKey = 'YOUR_API_KEY';
$url = 'example.com';
$screenshotUrl = "https://api.snapito.io/v2/webshot/{$apiKey}?url={$url}";
$image = file_get_contents($screenshotUrl);
file_put_contents('screenshot.jpg', $image);
?>
Python
import requests
api_key = 'YOUR_API_KEY'
url = 'example.com'
screenshot_url = f'https://api.snapito.io/v2/webshot/{api_key}?url={url}'
response = requests.get(screenshot_url)
with open('screenshot.jpg', 'wb') as f:
f.write(response.content)
JavaScript (Node.js)
const fs = require('fs');
const https = require('https');
const apiKey = 'YOUR_API_KEY';
const url = 'example.com';
const screenshotUrl = `https://api.snapito.io/v2/webshot/${apiKey}?url=${url}`;
https.get(screenshotUrl, (response) => {
const file = fs.createWriteStream('screenshot.jpg');
response.pipe(file);
});
Ruby
require 'open-uri'
api_key = 'YOUR_API_KEY'
url = 'example.com'
screenshot_url = "https://api.snapito.io/v2/webshot/#{api_key}?url=#{url}"
File.open('screenshot.jpg', 'wb') do |file|
file.write(URI.open(screenshot_url).read)
end
Advanced Options
Custom CSS Injection
Hide elements or modify page styling before capture:
?url=example.com&css=.ads{display:none;}
JavaScript Execution
Execute JavaScript before capture (Professional plan and above):
?url=example.com&js=document.querySelector('.popup').remove();
Custom Headers
Send custom headers with the request:
POST https://api.snapito.io/v2/webshot/YOUR_API_KEY
Content-Type: application/json
{
"url": "example.com",
"headers": {
"Authorization": "Bearer token123",
"Custom-Header": "value"
}
}
Webhooks
For async screenshot capture, you can use webhooks to get notified when screenshots are ready:
POST https://api.snapito.io/v2/webshot/YOUR_API_KEY
Content-Type: application/json
{
"url": "example.com",
"webhook_url": "https://your-domain.com/webhook",
"async": true
}
Webhook Payload
When the screenshot is ready, we'll POST to your webhook URL:
{
"id": "screenshot_123456",
"url": "example.com",
"screenshot_url": "https://cdn.snapito.io/screenshots/abc123.jpg",
"status": "completed",
"timestamp": "2025-01-15T10:30:00Z"
}
Best Practices
1. Use Caching
Enable caching for frequently accessed pages to reduce API calls and costs.
2. Implement Retry Logic
Network issues can occur. Implement exponential backoff for retries.
3. Monitor Your Quota
Check the X-Snapito-Quota-Remaining header to avoid hitting limits.
4. Optimize Image Size
Use appropriate dimensions for your use case to reduce bandwidth.
5. Handle Errors Gracefully
Always check status codes and handle errors appropriately.