Documentation
Getting started
The url format for making a screenshot request to Snapiant via GET
or POST
request:
https://screenshot.snapiant.com/v1/screenshot
Parameters are passed through a query string:
https://screenshot.snapiant.com/v1/screenshot?param1=somevalue¶m2=anothervalue
You'll also need to add your access_key
parameter to authorize usage of this service:
https://screenshot.snapiant.com/v1/screenshot?access_key=MY_ACCESS_KEY?url=amazon.com
Parameters
Parameter
Default
Description
access_key
A valid access key allowing you to make API calls. Access keys can be managed from your dashboard.
url
The URL of the website you wish to take a screenshot of.
timeout
30
How long to wait (in seconds) for the requested URL to response.
ttl
86400
The amount of seconds that a screenshot will be cached. This means that requesting the same screenshot within the TTL period will not count towards your usage. Range is from 0 seconds to 2592000 seconds (30 days).
force
Generate a new screenshot even if it is cached.
full_page
Set to true if you would like to capture the full page of the website.
width
1920
Width (in pixels) of the browser viewport.
height
1080
Height (in pixels) of the browser viewport.
delay
0
Delay (in seconds) to wait before the screenshot will be taken. Range: 0 seconds to 10 seconds.
wait_for_selector
Wait until the provided CSS selector matches within the webpage before taking a screenshot. Default timeout is 20 seconds.
selector
Takes a screenshot of the first match of the given CSS selector. Default timeout is 20 seconds.
wait_timeout
20
Time (in seconds) before `waitForSelector` or `selector` will timeout. Range: 0 seconds to 45 seconds.
format
jpeg
Format of the screenshot. Can be `jpeg` or `png`
quality
85
Image quality of the screenshot. Only works with `jpeg`. Range: 0 to 100
transparent
Hide the website's default background and the image will have a transparent background. Only works with `png`
thumbnail_width
Width (in pixels) of the thumbnail to be created. This option will be ignored if `fullPage` is set to true
retina
This will increase create a high definition screenshot that is suited well for retina devices. Since this is a heavy task, it will take slightly longer to generate.
css
You can provide custom CSS by using a URL encoded string.
js
You can provide custom JavaScript by using a URL encoded string.
accept_language
Sets the `Accept-Language` header.
user_agent
Sets the `User-Agent` header to mimic other devices/browsers.
headers
Sets headers on the request. The string should be URL encoded.
cookies
Sets cookies on the request. The string should be URL encoded.
latitude
Latitude used to emulate the Geolocation API.
longitude
Longitude used to emulate the Geolocation API.
accuracy
0
The accuracy value (in meters) used to emulate the Geolocation API.
fail_on_4xx
If the request to the URL receives a status code 400-451 it will make the API call fail.
fail_on_5xx
If the request to the URL receives a status code 500-511 it will make the API call fail.
Errors
HTTP Status Code
Description
400
Request contains invalid parameters or missing a required parameter.
401
Access key is not provided or invalid.
402
A failed payment has occurred.
403
Current subscription plan doesn't have permission to perform the request.
426
Monthly quota has been reached. Upgrade your subscription to continue.
429
Too many requests hit the API too quickly.
500
Something bad happened on Snapiant's end. (Rare).
Examples
curl --request GET --url https://screenshot.snapiant.com/v1/screenshot?access_key=MY_ACCESS_KEY&url=SOME_WEBSITE_URL
const fs = require('fs')
const axios = require('axios')
const options = {
method: 'GET',
url: 'https://screenshot.snapiant.com/v1/screenshot',
responseEncoding: 'binary',
params: {
url: 'https://some-website.com',
access_key: 'YOUR_ACCESS_KEY',
},
}
async function getScreenshot() {
try {
const response = await axios(options)
fs.writeFile('my_screenshot.jpeg', response.data, 'binary', err => {
if (err) {
console.log(err)
} else {
console.log('saved the screenshot')
}
})
} catch (error) {
console.log('failed fetching screenshot')
}
}
getScreenshot()
package main
import (
"io"
"net/http"
"os"
)
func main() {
request, err := http.NewRequest("GET", "https://screenshot.snapiant.com/v1/screenshot, nil)
if err != nil {
panic(err)
}
query := request.URL.Query()
query.Add("access_key", "YOUR_ACCESS_KEY")
query.Add("url", "https://some-website.com")
request.URL.RawQuery = query.Encode()
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
image, err := os.Create("my_screenshot.jpeg")
if err != nil {
panic(err)
}
_, err = io.Copy(image, response.Body)
if err != nil {
panic(err)
}
image.Close()
}
<?php
$params = http_build_query(array(
"access_key" => "YOUR_ACCESS_KEY",
"url" => "https://some-website.com",
"force" => true
));
$image_data = file_get_contents("https://screenshot.snapiant.com/v1/screenshot?" . $params);
file_put_contents("my_screenshot.jpeg", $image_data);
?>
from urllib.parse import urlencode
from urllib.request import urlretrieve
params = urlencode({'access_key': 'YOUR_ACCESS_KEY',
'url': 'https://some-website.com'})
urlretrieve("https://screenshot.snapiant.com/v1/screenshot?" +
params, "my_screenshot.jpeg")
require "open-uri"
File.open('my_screenshot.jpeg', 'wb') do |fo|
params = URI.encode_www_form("access_key" => "YOUR_ACCESS_KEY",
"url" => "https://some-website.com",
"force" => true)
fo.write open("https://screenshot.snapiant.com/v1/screenshot?" + params).read
end
Quota
Header
Description
X-Quota-Limit
Subscription plan limit
X-Quota-Remaining
Amount of screenshots remaining until your next billing period
X-Quota-Reset-At
UNIX timestamp for when the current billing period ends and your remaining screenshots resets