Getting Started
ScreenshotAPI is a simple API that allows you to take programmatic screenshots of any website with ease. Screenshots can be saved as JPEG, PNG, WebP, and even PDF! We provide plenty of options.

Render a Screenshot (GET)

1
GET https://shot.screenshotapi.net/screenshot?token=TOKEN&url=URL&[OPTIONS]
Copied!
The following options for the API call are:
TOKEN: The TOKENor your API key should be replaced by your real ScreenshotAPI API, you can find your API key after you Sign Up or Log In to the service via the Dashboard page.
Note: If for any reason you need to get a new API key, simply click "Roll API Key" in the "Settings" card on the Dashboard. This will issue you a fresh API key and revoke access from the previous key.
URL: Website URL for the site you would like to render for the screenshot. We support a wide variety of websites types, such as single page apps, very long-content, and sites that require lazy loading or delays ensuring accurate and complete screenshots of these unique sites.
OPTIONS: Options indicates the different URL parameters keys and values that can be used to render your "perfect" screenshot. All the options for screenshots will be detailed below.
Note: Default options for the screenshot will be shown in the Options table below.

Example

1
GET https://shot.screenshotapi.net/screenshot?token=TOKEN&url=https://apple.com
Copied!
This will render the following png image output when you paste in the above string into your browsers URL bar (replacing TOKEN with your API key):

Render a Screenshot (POST)

1
POST https://shot.screenshotapi.net/screenshot
Copied!
POST mode accepts the exact same parameters in the request body, but you need to use a JSON.

Request Options

get
https://
shot.screenshotapi.net/screenshot?token=TOKEN&url=https://apple.com
Request Options

Errors

In rare circumstances the API may encounter an "Error 524" from Cloudflare. This is due to a timeout between the ScreenshotAPI API and our servers due to auto-scaling. If you see this error please just try your request again.

Quota

With each API call the following quota headers are sent.
X-Quota-Limit
X-Quota-Remaining
X-Quota-Reset-At
The total number of screenshots you can take per month
The number of screenshots you can still make this month
A unix timestamp of when the quota resets (the first of each month)

Query Builder

Use our Query Builder to explore our API. (If you are logged in your API key is automatically added). To easily view all the screenshot options in an interactive builder to ensure you have your ideal screenshot dialed in.
You can check out the Query Builder here: https://app.screenshotapi.net.

Code Examples

Below is sample code for the following languages: Node.JS, PHP, Go, Java, Python, and Ruby.
If you need assistance integrating into our API with a given language please contact us.
NodeJS
PHP
Go
Java
Python
Untitled
1
var fs = require('fs')
2
var request = require('request');
3
​
4
// @param {String} token - String containing your API Key
5
// @param {String} url - Encoded URI string container the URI you're targeting
6
// @param {Integer} width - Integer indicating the width of your target render
7
// @param {Integer} height - Integer indicating the height of your target render
8
// @param {String} output - String specifying the output format, "image" or "json"
9
var token = 'Your API Key';
10
var url = encodeURIComponent('https://google.com');
11
var width = 1920;
12
var height = 1080;
13
var output = 'image';
14
​
15
// Construct the query params and URL
16
var query = "https://shot.screenshotapi.net/screenshot";
17
query += `?token=${token}&url=${url}&width=${width}&height=${height}&output=${output}`;
18
​
19
// Call the API and save the screenshot
20
request.get({url: query, encoding: 'binary'}, (err, response, body) => {
21
fs.writeFile("screenshot.png", body, 'binary', err => {
22
if (err) {
23
console.log(err);
24
} else {
25
console.log("The file was saved!");
26
}
27
});
28
});
29
​
Copied!
1
// @param {String} $token - String containing your API Key
2
// @param {String} $url - Encoded URI string container the URI you're targeting
3
// @param {Integer} $width - Integer indicating the width of your target render
4
// @param {Integer} $height - Integer indicating the height of your target render
5
// @param {String} $output - String specifying the output format, "image" or "json"
6
$token = 'Your API Key';
7
$url = urlencode('https://google.com');
8
$width = 1920;
9
$height = 1080;
10
$output = 'image';
11
​
12
// Construct the query params and URL
13
$query = "https://shot.screenshotapi.net/screenshot";
14
$query .= "?token=$token&url=$url&width=$width&height=$height&output=$output";
15
​
16
// Call the API
17
$image = file_get_contents($query);
18
​
19
// Save the screenshot
20
file_put_contents('./screenshot.png', $image);
Copied!
1
package main
2
​
3
import (
4
"fmt"
5
"io"
6
"io/ioutil"
7
"net/http"
8
url2 "net/url"
9
"os"
10
)
11
​
12
func main() {
13
// @param {String} token - String containing your API Key
14
// @param {String} url - Encoded URI string container the URI you're targeting
15
// @param {Integer} width - Integer indicating the width of your target render
16
// @param {Integer} height - Integer indicating the height of your target render
17
// @param {String} output - String specifying the output format, "image" or "json"
18
token := "Your API Key"
19
url := url2.QueryEscape("https://google.com")
20
width := 1920
21
height := 1080
22
output := "image"
23
​
24
// Construct the query params and URL
25
query := "https://shot.screenshotapi.net/screenshot"
26
query += fmt.Sprintf("?token=%s&url=%s&width=%d&height=%d&output=%s",
27
token, url, width, height, output)
28
​
29
// Call the API
30
resp, err := http.Get(query)
31
if err != nil {
32
panic(err)
33
}
34
defer resp.Body.Close()
35
​
36
// Raise error if call was unsucessfull
37
if resp.StatusCode != 200 {
38
errorBody, _ := ioutil.ReadAll(resp.Body)
39
panic(fmt.Errorf("error while calling api %s", errorBody))
40
}
41
​
42
// Save the screenshot
43
file, err := os.Create("./screenshot.png")
44
if err != nil {
45
panic(err)
46
}
47
defer file.Close()
48
​
49
_, err = io.Copy(file, resp.Body)
50
if err != nil {
51
panic(err)
52
}
53
}
54
​
Copied!
1
package main;
2
​
3
import java.io.FileOutputStream;
4
import java.io.InputStream;
5
import java.io.OutputStream;
6
import java.net.URL;
7
import java.net.URLEncoder;
8
​
9
public class Main {
10
​
11
public static void main(String[] args) {
12
try {
13
// @param {String} $token - String containing your API Key
14
// @param {String} $url - Encoded URI string container the URI you're targeting
15
// @param {Integer} $width - Integer indicating the width of your target render
16
// @param {Integer} $height - Integer indicating the height of your target render
17
// @param {String} $output - String specifying the output format, "image" or "json"
18
String token = "Your API Key";
19
String url = URLEncoder.encode("https://google.com");
20
int width = 1920;
21
int height = 1080;
22
String output = "image";
23
​
24
// Construct the query params and URL
25
String query = "https://shot.screenshotapi.net/screenshot";
26
query += String.format("?token=%s&url=%s&width=%d&height=%d&output=%s",
27
token, url, width, height, output);
28
URL apiUrl = new URL(query);
29
​
30
// Call the API and save the screenshot
31
InputStream inputStream = apiUrl.openStream();
32
OutputStream outputStream = new FileOutputStream("./screenshot.png");
33
inputStream.transferTo(outputStream);
34
​
35
inputStream.close();
36
outputStream.close();
37
} catch(Exception ex) {
38
ex.printStackTrace();
39
}
40
}
41
}
42
​
Copied!
1
import urllib.parse
2
import urllib.request
3
import ssl
4
​
5
ssl._create_default_https_context = ssl._create_unverified_context
6
​
7
# @param {String} $token - String containing your API Key
8
# @param {String} $url - Encoded URI string container the URI you're targeting
9
# @param {Integer} $width - Integer indicating the width of your target render
10
# @param {Integer} $height - Integer indicating the height of your target render
11
# @param {String} $output - String specifying the output format, "image" or "json"
12
token = "Your API Key"
13
url = urllib.parse.quote_plus("https://google.com")
14
width = 1920
15
height = 1080
16
output = "image"
17
​
18
# Construct the query params and URL
19
query = "https://shot.screenshotapi.net/screenshot"
20
query += "?token=%s&url=%s&width=%d&height=%d&output=%s" % (token, url, width, height, output)
21
​
22
# Call the API
23
urllib.request.urlretrieve(query, "./screenshot.png")
24
​
Copied!
1
​
Copied!

Support

At ScreenshotAPI we are there for you. We are developers ourselves and strive to ensure you have a great screenshot experience. If you need help at any point please contact us at [email protected] or use the chat bubble in the bottom right of your screen.
The ScreenshotAPI Team -- Andrew, Michael, Tom, and Henry
Last modified 6mo ago