Introduction
ApiLeap is an easy to use API that can capture near pixel perfect screenshots of web pages.
It relies on the Chrome rendering engine to ensure fast and accurate rendering.
As a result, modern HTML, CSS, and JS features are fully supported. ( FlexBox, Advanced Selectors, Webfonts, Box Sizing, Media Queries, ... )
Endpoints
Usage
Just make HTTP requests on one of the following endpoints:
  • https://apileap.com/api/screenshot/v1/urltoimage
  • https://apileap.com/api/screenshot/v1/htmltoimage
Both HTTP POST and GET methods can be used.
To use a parameters, add them as a query string parameters: https://apileap.com/api/screenshot/v1/urltoimage?param1=value1&param2=value2...
Responses
The response will contain the image data with the corresponding Content-Type and Content-Length headers.
/urltoimage GET POST
https://apileap.com/api/screenshot/v1/urltoimage
Parameter Default Description
access_key required Your personal access key to use the API. You can find it in your dashboard.
url required The URL of the website you want to request a snapshot from. The protocol (http:// or https://) must be specified for the URL to be valid.
ttl in seconds 86400 The number of seconds the screenshot should be kept in cache. When a screenshot is served from cache, the API call doesn't count in your monthly credit. From 0 to 604800 (1 week) seconds.
fresh False Return a fresh new screenshot instead of the eventually cached one.
full_page False Set this to true if you want to capture the full height of the target website.
width in pixels 1920 Width of the viewport to use.
height in pixels 1080 Height of the viewport to use. This will be ignored if full_page is set to true.
delay in seconds 0 Delay, after the pageload event is fired, to wait before taking the screenshot. From 0 to 10 seconds. Most websites are fully loaded after the pageload event so this parameter is not needed most of the time.
format jpeg The format of the returned screenshot. One of jpeg and png.
css An additional CSS string to be injected into the page before capturing.
/htmltoimage GET POST
https://apileap.com/api/screenshot/v1/htmltoimage
Parameter Default Description
access_key required Your personal access key to use the API. You can find it in your dashboard.
html required The HTML you want to make a snapshot of.
ttl in seconds 86400 The number of seconds the screenshot should be kept in cache. When a screenshot is served from cache, the API call doesn't count in your monthly credit. From 0 to 604800 (1 week) seconds.
fresh False Return a fresh new screenshot instead of the eventually cached one.
full_page False Set this to true if you want to capture the full height of the target website.
width in pixels 1920 Width of the viewport to use.
height in pixels 1080 Height of the viewport to use. This will be ignored if full_page is set to true.
delay in seconds 0 Delay, after the pageload event is fired, to wait before taking the screenshot. From 0 to 10 seconds. Most websites are fully loaded after the pageload event so this parameter is not needed most of the time.
format jpeg The format of the returned screenshot. One of jpeg and png.
css An additional CSS string to be injected into the page before capturing.
Examples
Our examples make a HTTP request to the API and then store the resulting image as a file called screenshot.jpeg.
using System.Net;

public class Api
{
    private const string ApiUrl = "https://apileap.com/api/screenshot/v1/urltoimage";

    public static void Main ()
    {
        using(var client = new WebClient())
        {
            // This requires the System.Web assembly reference.
            var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);
            queryString["url"] = "http://google.com";
            queryString["access_key"] = "YOUR_ACCESS_KEY";

            client.DownloadFile(ApiUrl + "?" + queryString, "screenshot.jpeg");
        }
    }
}
access_key="YOUR_ACCESS_KEY"
api_url="https://apileap.com/api/screenshot/v1/urltoimage"
url="http://google.com"

curl --request GET --url "${api_url}?access_key=${access_key}&url=${url}" > screenshot.jpeg
package main

import (
	"io"
	"net/http"
	"os"
)

func main() {

	apiUrl := "https://apileap.com/api/screenshot/v1/urltoimage"
	request, _ := http.NewRequest("GET", apiUrl, nil)
	query := request.URL.Query()
	query.Add("url", "http://google.com")
	query.Add("access_key", "YOUR_ACCESS_KEY")
	request.URL.RawQuery = query.Encode()

	client := &http.Client{}
	response, _ := client.Do(request)
	defer response.Body.Close()

	image, _ := os.Create("screenshot.jpeg")
	io.Copy(image, response.Body)
	image.Close()

}
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

public class Main {

    public static void main(String[] args) throws Exception {

        String accessKey = "YOUR_ACCESS_KEY";
        String apiUrl = "https://apileap.com/api/screenshot/v1/urltoimage";
        URL url = new URL(String.format("%s?access_key=%s&url=http://google.com", apiUrl, accessKey));
        InputStream inputStream = url.openStream();
        OutputStream outputStream = new FileOutputStream("screenshot.jpeg");

        byte[] b = new byte[2048];
        int length;

        while ((length = inputStream.read(b)) != -1) {
            outputStream.write(b, 0, length);
        }

        inputStream.close();
        outputStream.close();
    }
}
var fs = require('fs'),
    request = require('request');

request({
    url: "https://apileap.com/api/screenshot/v1/urltoimage",
    encoding: "binary",
    qs: {
        url: "http://google.com",
        access_key: "YOUR_ACCESS_KEY"
    }
}, function (error, response, body) {
    fs.writeFile("screenshot.jpeg", body, "binary", function (err) {
    });
});
<?php

$params = http_build_query(array(
    "url" => "http://google.com",
    "access_key" => "YOUR_ACCESS_KEY"
));

$image_data = file_get_contents("https://apileap.com/api/screenshot/v1/urltoimage?" . $params);
file_put_contents("screenshot.jpeg", $image_data);

?>
from urllib.parse import urlencode
from urllib.request import urlretrieve

params = urlencode({"url": "http://google.com", "access_key": "YOUR_ACCESS_KEY"})
urlretrieve("https://apileap.com/api/screenshot/v1/urltoimage?" + params, "screenshot.jpeg")
require "open-uri"

File.open('screenshot.jpeg', 'wb') do |fo|
  params = URI.encode_www_form("url" => "http://google.com",
                               "access_key" => "YOUR_ACCESS_KEY")
  fo.write open("https://apileap.com/api/screenshot/v1/urltoimage?"+params).read
end
Errors
When a query fails, the API respond with specific HTTP status codes.
The cause of the error can be determined from the following table.
Status Code Description
400 Bad Request Some api parameters are not valid.
401 Unauthorized No access key was provided or the provided access key is invalid or revoked.
402 Payment Required Monthly API request allowance has been exceeded for plan.
403 Forbidden The api feature is not available for plan.