API Documentation

Use our simple API to capture screenshots of websites.

Making an API request

To create a screenshot send a GET request to this endpoint.

https://api.pikwy.com

Authentication

Add the token parameter with your API token to the request to authorize yourself.

https://api.pikwy.com/?token=YOUR_API_TOKEN&url=https://wikipedia.org

Parameters

This is a list of all parameters that you can add to the request. You can use long or short parameter names.

Parameter Type Default value Value range Description
token/tkn string '' '' Your API token.
url/u string '' '' The url of the website. Needs to be URL encoded.
width/w int 1280 100 - 10000 The width of the browser in pixels.
height/h int 1024 100 - 50000 The height of the browser in pixels.
full_page/fs int 0 0, 1 If 1, a screenshot will be taken over the entire height of the web page.
format/f string jpg png, jpg Format of the thumbnail or screenshot
response_type/rt string image json, html, image If you select json, the API will return an image encoded in base64 and additional information: response code, response headers. If you select html, API will return the html page code. If you select an image, the API will return the image. In case of unsuccessful response, error text.
timeout/t int 0 0 - 120000 Limits the maximum time in milliseconds for screenshot creation. If screenshot isn't created in time, API return timeout error.
delay/d int 0 0 - 60000 How many seconds to wait before taking the screenshot.
refresh/r int 0 0, 1 After the page is fully loaded, Pikwy waits 1 second and refreshes the page.
user_agent/ua string '' '' User variable to set your user-agent. The value have to be url encoded.
headers/hdrs string '' '' User variable to set your headers fields. Allowed multiple headers parameters.
&headers[Referer]=https://wikipedia.org/&headers[Cache-Control]=max-age=0
&headers[Cookie]=SSID=WX84BVOEA3WEDSHJHG;SEARCH_SAMESITE=CgQI5o4B
In some cases, cookies sent using the &headers[Cookie] to certain sites are not accepted. In this case, you must use the cookie parameter below.
cookie/c string '' '' To send a cookie with one parameter:
&cookie[0][name]=is_mobile_app&cookie[0][value]=true
To send a cookie with multiple parameters:
&cookie[0][name]=is_mobile_app&cookie[0][value]=true&cookie[1][name]=city_id&cookie[1][value]=710000000&cookie[1][domain]=wikipedia.org, etc.
optional keys - “path”, “domain”, “secure”, “expiry”
http_proxy/pxip string '' '' IP address to connect to the proxy. Example: 127.0.0.1:8080
proxy_user_name/pxnm string '' '' Specify a username for proxy server
proxy_password/pxpw string '' '' Specify a password for proxy server

Code Examples

These code examples show how to save a website screenshot to a file.

var fs = require('fs')
var request = require('request');

// The parameters.
var token = 'YOUR_API_TOKEN';
var url = encodeURIComponent('https://www.wikipedia.org/');
var width = 1280;
var height = 1024;
var response_type = 'image';

// Create the query URL.
var query = "https://api.pikwy.com";
query += `?token=${token}&url=${url}&width=${width}&height=${height}&response_type=${response_type}`;

// Call the API and save the screenshot.
request.get({url: query, encoding: 'binary'}, (err, response, body) => {
    fs.writeFile("screenshot.png", body, 'binary', err => {
        if (err) {
            console.log(err);
        } else {
            console.log("The file was saved!");
        }
    });
});

function SiteScreenshot($token, $url, $width, $height, $response_type = 'image') {
	// Parameters.
	$token = $token; ///YOUR_API_TOKEN
	$url = urlencode($url);
	$width = $width;
	$height = $height;
	$response_type = $response_type; ///Response type: json, image

	// Create the query URL.
	$query = "https://api.pikwy.com/";
	$query .= "?token=$token&url=$url&width=$width&height=$height&response_type=$response_type";

	// Call the API.
	$image = file_get_contents($query);

	// Store the screenshot image.
	file_put_contents('./screenshot.png', $image);
}
#!/usr/bin/python3
import urllib.request
import urllib.parse

def generate_screenshot_api_url(token, options):
  api_url = 'https://api.pikwy.com/?token=' + token
  if token:
    api_url = api_url + '&url=' + options.get('url')
    api_url = api_url + '&width=' + options.get('width')
    api_url = api_url + '&height=' + options.get('height')
    api_url = api_url + '&response_type=' + options.get('response_type')
  return api_url;

token = 'YOUR_API_TOKEN'
options = {
  'url': 'https://www.wikipedia.org/',
  'width': '1280',
  'height': '2000',
  'response_type': 'image'
  }

api_url = generate_screenshot_api_url(token, options)

#
opener = urllib.request.build_opener()
urllib.request.install_opener(opener)
output = 'output.png'
urllib.request.urlretrieve(api_url, output)
		  
Imports System
Imports System.net
				
Public Module PikwyClient
	Public Sub Main()
        Dim token As String
        Dim ApiUrl As String
        Dim UrlOpt As Url_Options	
        token = "YOUR_API_TOKEN"

        UrlOpt.url = "https://www.wikipedia.org/"
        UrlOpt.width = 1280
        UrlOpt.height = 1024
        UrlOpt.response_type = "image"
		
        REM Parameters.
        ApiUrl = "https://api.pikwy.com/?token=" & token
        If token <> "" Then
            ApiUrl = ApiUrl & "&url=" & UrlOpt.url
            ApiUrl = ApiUrl & "&width=" & UrlOpt.width
            ApiUrl = ApiUrl & "&height=" & UrlOpt.height
            ApiUrl = ApiUrl & "&response_type=" & UrlOpt.response_type
        End If
		
        REM Save screenshot as an image.
        Dim Client As New WebClient
        Dim output As String = "\output.png"
		Console.WriteLine(ApiUrl)
        Client.DownloadFile(ApiUrl, output)		
		Console.WriteLine("The file was saved!")
	End Sub
End Module

Module PikwyOptions
    Public Structure Url_Options
        Public url As String
        Public width As Integer
        Public height As Integer
        Public response_type As String
    End Structure
End Module