Getting Started
SnapMySite provides a simple REST API to capture screenshots and generate PDFs from any URL or raw HTML. Follow these steps to get started:
- Create a free account to get your API key.
- Include your API key in the
X-API-Keyheader with every request. - Make a GET or POST request to the screenshot or PDF endpoint.
- Receive the binary image or PDF in the response body.
Base URL:
https://api.snapmysite.com
Authentication
All API requests require authentication via the X-API-Key header. You can find your API key on the dashboard after registering.
curl "https://api.snapmysite.com/api/v1/screenshot?url=https://example.com" \ -H "X-API-Key: sk_live_your_api_key_here" \ --output screenshot.png
If the API key is missing or invalid, the API returns a 401 Unauthorized response.
Screenshot API
Capture a screenshot of any web page or raw HTML content.
Endpoint
GET /api/v1/screenshot POST /api/v1/screenshot
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string | yes* | - | The URL to capture. Must start with http:// or https://. |
html |
string | yes* | - | Raw HTML to render and capture. Use POST with JSON body. |
width |
integer | no | 1280 | Viewport width in pixels. |
height |
integer | no | 800 | Viewport height in pixels. |
full_page |
boolean | no | false | Capture the full scrollable page. |
format |
string | no | png | Image format: png, jpeg, or webp. |
quality |
integer | no | 80 | Image quality (1-100). Only applies to JPEG and WebP. |
delay_ms |
integer | no | 0 | Wait time in milliseconds before capturing (max 10000). |
* Either url or html is required. If both are provided, url takes precedence.
Response
Returns the binary image data with the appropriate Content-Type header (image/png, image/jpeg, or image/webp).
Example
# GET request with query parameters curl "https://api.snapmysite.com/api/v1/screenshot?url=https://example.com&width=1440&format=webp" \ -H "X-API-Key: sk_live_your_api_key" \ --output screenshot.webp # POST request with JSON body (for raw HTML) curl -X POST "https://api.snapmysite.com/api/v1/screenshot" \ -H "X-API-Key: sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{"html": "<h1>Hello World</h1>", "width": 800, "height": 600}' \ --output screenshot.png
PDF API
Generate a PDF document from any web page or raw HTML content.
Endpoint
GET /api/v1/pdf POST /api/v1/pdf
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string | yes* | - | The URL to render as PDF. Must start with http:// or https://. |
html |
string | yes* | - | Raw HTML to render as PDF. Use POST with JSON body. |
width |
integer | no | 1280 | Viewport width in pixels for rendering. |
landscape |
boolean | no | false | Use landscape orientation. |
paper_width |
float | no | 8.5 | Paper width in inches. |
paper_height |
float | no | 11 | Paper height in inches. |
margin_top |
float | no | 0.4 | Top margin in inches. |
margin_bottom |
float | no | 0.4 | Bottom margin in inches. |
margin_left |
float | no | 0.4 | Left margin in inches. |
margin_right |
float | no | 0.4 | Right margin in inches. |
scale |
float | no | 1.0 | Scale of the webpage rendering (0.1 - 2.0). |
delay_ms |
integer | no | 0 | Wait time in milliseconds before generating PDF (max 10000). |
* Either url or html is required. If both are provided, url takes precedence.
Response
Returns the binary PDF data with Content-Type: application/pdf.
Example
# Generate a PDF from a URL curl "https://api.snapmysite.com/api/v1/pdf?url=https://example.com&landscape=true" \ -H "X-API-Key: sk_live_your_api_key" \ --output document.pdf
Error Handling
The API returns standard HTTP status codes and JSON error responses when something goes wrong.
| Status Code | Meaning | Description |
|---|---|---|
200 |
OK | Request succeeded. Binary data returned. |
400 |
Bad Request | Invalid parameters or missing required fields. |
401 |
Unauthorized | Missing or invalid API key. |
403 |
Forbidden | URL blocked by SSRF protection. |
429 |
Too Many Requests | Rate limit exceeded. Check Retry-After header. |
500 |
Internal Server Error | Something went wrong on our end. |
Error Response Format
{
"error": {
"code": "invalid_parameter",
"message": "Parameter 'url' is required when 'html' is not provided."
}
}
Rate Limits
Rate limits are applied per API key. The following headers are included in every response:
X-RateLimit-Limit— Maximum requests per minute for your plan.X-RateLimit-Remaining— Requests remaining in the current window.X-RateLimit-Reset— Unix timestamp when the window resets.
| Plan | Monthly Requests | Rate Limit (per min) |
|---|---|---|
| Free | 100 | 5 |
| Starter | 2,000 | 20 |
| Pro | 10,000 | 60 |
| Business | 50,000 | 200 |
Code Examples
curl
# Screenshot curl "https://api.snapmysite.com/api/v1/screenshot?url=https://example.com&full_page=true" \ -H "X-API-Key: sk_live_your_api_key" \ --output screenshot.png # PDF curl "https://api.snapmysite.com/api/v1/pdf?url=https://example.com" \ -H "X-API-Key: sk_live_your_api_key" \ --output document.pdf
JavaScript (Node.js)
const fs = require('fs'); async function captureScreenshot(url) { const response = await fetch( `https://api.snapmysite.com/api/v1/screenshot?url=${encodeURIComponent(url)}`, { headers: { 'X-API-Key': 'sk_live_your_api_key' } } ); if (!response.ok) { const err = await response.json(); throw new Error(err.error.message); } const buffer = Buffer.from(await response.arrayBuffer()); fs.writeFileSync('screenshot.png', buffer); console.log('Screenshot saved!'); } captureScreenshot('https://example.com');
Python
import requests API_KEY = "sk_live_your_api_key" BASE_URL = "https://api.snapmysite.com" # Screenshot response = requests.get( f"{BASE_URL}/api/v1/screenshot", headers={"X-API-Key": API_KEY}, params={ "url": "https://example.com", "width": 1440, "full_page": "true", "format": "webp", } ) if response.status_code == 200: with open("screenshot.webp", "wb") as f: f.write(response.content) print("Screenshot saved!") else: print(f"Error: {response.json()}") # PDF response = requests.get( f"{BASE_URL}/api/v1/pdf", headers={"X-API-Key": API_KEY}, params={"url": "https://example.com"} ) if response.status_code == 200: with open("document.pdf", "wb") as f: f.write(response.content) print("PDF saved!")
Go
package main import ( "fmt" "io" "net/http" "os" ) func main() { apiKey := "sk_live_your_api_key" url := "https://api.snapmysite.com/api/v1/screenshot?url=https://example.com&full_page=true" req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("X-API-Key", apiKey) client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { body, _ := io.ReadAll(resp.Body) fmt.Printf("Error %d: %s\n", resp.StatusCode, body) return } file, _ := os.Create("screenshot.png") defer file.Close() io.Copy(file, resp.Body) fmt.Println("Screenshot saved!") }