Introduction

ApiFlash is a simple yet powerful screenshot API that any modern company can easily use to make pixel perfect website screenshots at scale. An up to date version of Chrome is used to ensure that all modern web features are fully supported and that rendering is exactly as you would expect. It's also built over AWS Lambda to make sure that it truly scales and keeps being stable under heavy workloads.

We're one of the most cost efficient screenshot API out there and we are dedicated to provide an awesome service to all companies, big or small.

Access
The API can be accessed through a unique HTTPS endpoint that supports both GET and POST methods.
GET https://api.apiflash.com/v1/urltoimage
Parameters are passed through query string.
POST https://api.apiflash.com/v1/urltoimage
Parameters are passed as form data.
All API calls needs to be authenticated using a valid access key that can be found in the dashboard. For a GET request, the access key is passed in the query string as all other parameters.
GET https://api.apiflash.com/v1/urltoimage?access_key=YOUR_ACCESS_KEY
For a POST request, the access key is passed as form data as every other parameter.

By default the API returns directly the screenshot image data. It also passes along the appropriate Content-Type and Content-Length headers. If the response_type parameter is set to json, then the response contains a JSON document with links to the resulting screenshot.
Parameters
The table bellow contains all the available parameters of our screenshot API.
To use them, simply include them in the query string or form data of your API calls.
GET https://api.apiflash.com/v1/urltoimage?param1=value1&param2=value2...
Please also note that some parameter values need to be URL encoded to be processed correctly.
Parameter Default Description
access_key required A valid access key allowing you to make API calls. Access keys can be managed from your dashboard.
url required The complete URL of the website for which you want to capture a screenshot. The URL must include the protocol (http:// or https://) to be processed correctly.
ttl in seconds defaults to 86400 Number of seconds the screenshot is cached. API calls with the same parameters do return a cached screenshot and don't count in your monthly quota. From 0 seconds to 2592000 seconds (30 days).
fresh defaults to False Force the API to capture a fresh new screenshot instead of returning a screenshot from the cache.
full_page defaults to False Set this parameter to true to capture the entire page of the target website.
scroll_page defaults to False Set this parameter to true to scroll through the entire page before capturing a screenshot. This is useful to trigger animations or lazy loaded elements.
width in pixels defaults to 1920 The width, in pixels, of the viewport to use.
height in pixels defaults to 1080 The height, in pixels, of the viewport to use. This is ignored if full_page is true.
delay in seconds defaults to 0 The delay, in seconds, to wait after the page is loaded (load event fired and no more network connections for at least 500ms) before capturing the screenshot. From 0 seconds to a maximum of 10 seconds.
wait_for Wait until the provided CSS selector matches an element present in the page before capturing a screenshot. The process times out after 40 seconds.
format defaults to jpeg The image format of the captured screenshot. Either jpeg or png.
response_type defaults to image The type of response to return. Can be either image or json.
  • If the response type is image, the binary data of the screenshot is returned with the appropriate Content-Type and Content-Length headers.
  • If the response type is json, the response is a json document. formatted as follows:
    {
        "url": "https://url_of_screenshot_image...", 
        "extracted_html": "https://url_of_extracted_html_here..." 
    }
quality defaults to 80 The quality of the image between 0 and 100. This only works with the jpeg format.
transparent defaults to False Hides the default background and allows capturing screenshots with transparency. This only works with the png format.
scale_factor defaults to 1 The device scale factor to use when capturing the screenshot. A scale factor of 2 will produce a high definition screenshot suited to be displayed on retina devices. The bigger the scale factor is, the heavier the produced screenshot will be.
css A CSS string to inject in the web page when capturing the screenshot. This CSS string needs to be URL encoded to be processed correctly.
js Additional JavaScript code to be injected into the page before capturing. For security reasons, this feature is disabled by default for all accounts. If you need it, please let us know. The JS string might need to be URL encoded to be processed correctly.
extract_html defaults to False Extract the HTML of the page at the same time the screenshot is made. This only works when the response_type parameter is set to json. When this parameter is set to true, an extracted_html attribute is added to the returned json document.
accept_language Sets the Accept-Language header on requests to the target URL allowing you to make screenshots of a website with a specific language.
user_agent Sets the User-Agent header to emulate a particular device when making screenshots.
headers A semicolon separated list of headers to be used when capturing the screenshot. Each header should be supplied as a key value pair and multiple pairs should be separated by a semicolon. The headers parameter value should be URL encoded to be processed correctly. For example, Header1=value1;Header2=value2 would have to be URL encoded into Header1%3Dvalue1%3BHeader2%3Dvalue2.
cookies A semicolon separated list of cookies to be used when capturing the screenshot. Each cookie should be supplied as a name value pair and multiple pairs should be separated by a semicolon. The cookies parameter value should be URL encoded to be processed correctly. For example, cookie1=value1;cookie2=value2 would have to be URL encoded into cookie1%3Dvalue1%3Bcookie2%3Dvalue2.
ip_location An ISO alpha-2 country code designating the country that should be associated with the IP address of the proxy through which the screenshot is captured. This feature is only available for custom enterprise plans. Get in touch with us if you need it.
latitude The latitude to use when emulating geo-location between -90 and 90.
longitude The longitude to use when emulating geo-location between -180 and 180.
accuracy in meters defaults to 0 Accuracy value to use when emulating geo-location.
fail_on_status A comma separated list of HTTP status codes that should make the API call fail instead of returning a screenshot. Hyphen separated HTTP status codes can be used to define ranges. For example 400,404,500-511 would make the API call fail if the URL returns 400, 404 or any status code between 500 and 511.
proxy The address of a proxy server through which the screenshot should be captured. The proxy address should be formatted as address:port or user:password@address:port if authentication is needed.
Examples
The following examples make a HTTP request to the API and save the screenshot to a screenshot.jpeg file.
using System.Net;

public class ApiFlashExample
{
    private const string ApiFlashEndpoint = "https://api.apiflash.com/v1/urltoimage";

    public static void Main ()
    {
        using(var webClient = new WebClient())
        {
            // The System.Web assembly reference is required.
            var parameters = System.Web.HttpUtility.ParseQueryString(string.Empty);
            parameters["access_key"] = "YOUR_ACCESS_KEY";
            parameters["url"] = "https://example.com";

            webClient.DownloadFile(ApiFlashEndpoint + "?" + parameters, "screenshot_api_example.jpeg");
        }
    }
}
apiflash_endpoint="https://api.apiflash.com/v1/urltoimage"
access_key="YOUR_ACCESS_KEY"
url="https://example.com"

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

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

func main() {

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

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

	image, _ := os.Create("screenshot_api_example.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 {

    private static String ACCESS_KEY = "YOUR_ACCESS_KEY";
    private static String APIFLASH_ENDPOINT = "https://api.apiflash.com/v1/urltoimage";

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

        URL url = new URL(String.format("%s?access_key=%s&url=https://example.com", APIFLASH_ENDPOINT, ACCESS_KEY));
        InputStream inputStream = url.openStream();
        OutputStream outputStream = new FileOutputStream("screenshot_api_example.jpeg");

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

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

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

request({
    url: "https://api.apiflash.com/v1/urltoimage",
    encoding: "binary",
    qs: {
        access_key: "YOUR_ACCESS_KEY",
        url: "https://example.com"
    }
}, (error, response, body) => {
    if (error) {
        console.log(error);
    } else {
        fs.writeFile("screenshot_api_example.jpeg", body, "binary", error => {
            console.log(error);
        });
    }
});
<?php

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

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

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

params = urlencode(dict(access_key="YOUR_ACCESS_KEY",
                        url="https://example.com"))
urlretrieve("https://api.apiflash.com/v1/urltoimage?" + params, "screenshot_api_example.jpeg")
require "open-uri"

File.open('screenshot_api_example.jpeg', 'wb') do |fo|
  params = URI.encode_www_form("access_key" => "YOUR_ACCESS_KEY",
                               "url" => "https://example.com")
  fo.write open("https://api.apiflash.com/v1/urltoimage?" + params).read
end
Errors
If our screenshot API fails to capture a web page, the API response will contain an appropriate status code.
The list of possible status codes with their corresponding description can be found in the table bellow.
Status Code Description
400 Bad Request The request to the API endpoint contains some invalid parameters.
401 Unauthorized The access key used to make this API call has been revoked or is invalid.
402 Payment Required The monthly screenshot quota has been exceeded for the user's current plan.
403 Forbidden The current plan does not support some of the features requested through API parameters.