Request Anatomy

https://www.sitesnapr.com/v2/APIKEY/TOKEN/?url=URL

Code Examples

Sample code is available in the following languages, If you would like help integrating our API please get in touch.


PHP Curl Ruby C# Python
public static string sitesnapr(string siteurl)
{

    string APIKey = "xxxxxxx";
    string APISecret = "xxxxxxx";

    string url = HttpUtility.UrlEncode(siteurl);

    string getstring = "fullpage=true&url=" + url;

    string sitesnapr_hash = Md5HashPHPCompliant(APISecret + "+" + getstring).ToLower();

    return "https://www.sitesnapr.com/v2/" + APIKey + "/" + sitesnapr_hash + "/?" + getstring;

}


public static string Md5HashPHPCompliant(string pass)
{

    System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

    byte[] dataMd5 = md5.ComputeHash(Encoding.UTF8.GetBytes(pass));
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i <= dataMd5.Length - 1; i++)
    {
        sb.AppendFormat("{0:x2}", dataMd5[i]);
    }

    return sb.ToString();

}
import hashlib
from urllib import urlencode

def sitesnapr(url, api_key, secret, fullpage=true, force=true):

    data = {
        'url': url,
        'fullpage': 'true' if fullpage else 'false',
        'force': true
        }
    filtered_data = dict((opt, data[opt]) for opt in data if data[opt])

    query_string = urlencode(filtered_data)

    token = hashlib.md5('{}{}'.format(query_string, secret)).hexdigest()
    return "https://www.sitesnapr.com/v2/{}/{}/?{}".format(api_key, token, query_string)

api_key="xxxxxx"
secret="xxxxxx"

print sitesnapr ("http://website.com/", api_key, secret)
require 'cgi' unless defined?(CGI)
require 'digest' unless defined?(Digest)
 
class sitesnapr
  attr_reader :apikey, :secret, :query_string, :token
  def initialize options
 
    @apikey = 'xxxxxxx'
    @secret = 'xxxxxxx'
 
    @query_string = options.sort.map { |k,v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}" }.join("&")
    @token = Digest::MD5.hexdigest(query_string + secret)
  end
 
  def url
    "https://www.sitesnapr.com/v2/#{apikey}/#{token}/?#{query_string}"
  end
 
end
 
options = {
  url: "http://www.website.com",
  fullpage: true
}
 
puts sitesnapr.new(options).url
#!/bin/bash

APIKEY="xxxxxxx"
SECRET="xxxxxxx"
TOKEN=$(echo -n "?url=google.com&force=true$SECRET" | md5sum | cut -d " " -f 1)

curl -vvs "https://www.sitesnapr.com/v2/$APIKEY/$TOKEN/?url=website.com&force=true" > screenshot.png

function sitesnapr_v2($url, $args) {

    $APIKEY = "xxxxxxx";
    $SECRET = "xxxxxxx";
    
    # urlencode request target
    $options['url'] = urlencode($url);
    
    $options += $args;
    
    # create the query string based on the options
    foreach($options as $key => $value) { $_parts[] = "$key=$value"; }
    
    # create a token from the ENTIRE query string
    $query_string = implode("&", $_parts);
    $TOKEN = md5($query_string . $SECRET);
    
    return "https://www.sitesnapr.com/v2/$APIKEY/$TOKEN/?$query_string";
    
} 

# usage
$options['force']       = 'false';     # [false,true] Default: false
$options['fullpage']    = 'false';     # [true,false] Default: false
$options['thumb']       = '500';      # [0%-100%] reduce or limit the size of the captured image by upto 100%
$options['delay']       = '2000';      # [ms] wait an extra ms milliseconds after the page has finished loading before capturing the image 
$options['width']       = '1280';
$options['height']      = '1024';
						
$src = sitesnapr_v2("website.com", $options); 

Request Options

Construct a querystring using the below variables to control the snapshot behavior.

URL

Specify the URL of the webpage to be captured.

&url=www.google.com

Width

Sets the viewport width in pixels

&width=1280

Height

Sets the viewport height in pixels

&height=1024

Force

Fetch a new screenshot instead of displaying a cached one

&force=true
&force=false #default

Fullpage

Capture the entire length of a webpage or just the visible area.

&fullpage=true
&fullpage=false #default

Thumbnail

Reduces the dimesions of returned image to the specified width in pixels.

&thumb=500

Delay

Waits the specified number of milliseconds after the page has loaded before taking the screenshot.

&delay=2000