Introduction
ApiFlash is easy to use and 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
Make HTTP requests to one of the following endpoints:
  • https://api.apiflash.com/v1/urltoimage
Both HTTP POST and GET methods can be used.
Parameters are passed in the query string:
https://api.apiflash.com/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://api.apiflash.com/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.
scroll_page False Set this to true if you want the page to be scrolled through to trigger animations or lazy loaded elements.
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.
quality 80 The quality of the image between 0 and 100. This only works with the jpeg format.
transparent False Hides the default background and allows capturing screenshots with transparency. This only works with the png format.
css An additional CSS string to be injected into the page before capturing. The CSS string might need 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.
accept_language Sets an Accept-Language header on requests to the target URL allowing you to make screenshots of a website with a specific language.
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 0 Accuracy value to use when emulating geo-location.
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 Api
{
    private const string ApiUrl = "https://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/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://api.apiflash.com/v1/urltoimage?" + params).read
end
Errors
When ApiFlash is enable to make a screenshot, 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 the current plan.
403 Forbidden The api feature is not available for the current plan.