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.
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.
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. | |
element | Capture a screenshot of the first element matched by the given CSS selector. This is ignored if full_page is true . |
|
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 .
|
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. |
thumbnail_width | The width, in pixels, of the thumbnail to generate. The aspect ratio will be preserved. This is ignored if full_page is true . |
|
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. The JS string needs 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. |
extract_text |
defaults to
False
|
Extract the text 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_text 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. It should be URL encoded to be processed correctly. |
|
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. |
time_zone | The time zone to use when capturing screenshots. This parameter accepts standard time zome database names. For example, Europe/Paris or America/New_York . It should be URL encoded to be processed correctly. |
|
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. |
|
no_ads |
defaults to
False
|
Prevent ads from being displayed. Block requests from popular ad-networks and hide common ad spaces. |
no_tracking |
defaults to
False
|
Prevent tracking scripts to run and block requests from popular tracking services. Use this to prevent page views to be incorrectly reported to tracking tools when screenshots are captured. |
no_cookie_banners |
defaults to
False
|
Prevent cookie banners and popups from being displayed. |
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.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.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.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.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.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.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.jpeg")
require "open-uri"
File.open('screenshot.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
429
.
Header Name | Description |
---|---|
X-Quota-Limit |
The maximum number of API calls you can make per billing period. |
X-Quota-Remaining |
The number of API calls remaining for the current billing period. |
X-Quota-Reset |
The time, in UTC epoch seconds, at which the current billing period ends and the remaining number of API calls resets. |
{
"limit": 100000,
"remaining": 999999,
"reset": 1584549777
}
Status Code | Description |
---|---|
400
Bad Request
|
Either the API call contains invalid parameters or the target URL cannot be captured. |
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. |
429
Too Many Requests
|
Too many API calls have been made. The specific reason is included in the response body. |
500
Internal Server Error
|
The screenshot capture failed because our API failed to handle the encountered situation. |
400
, it also provides a meaningful
error message to help you understand the root cause of the error.
If the response_type parameter is set to json
, an error type as well as additional
information might also be returned depending on the type of error.