API Documentation > Rest API > Create Website Screenshot with Rest API

Create website Screenshot with Rest API

Use this REST API to get the website Screenshot


We support both of GET and POST method. To make a call, make an HTTP GET or POST request to api server to following URL.


Quick Start

The most simple API looks like this:

Click this here to see the demo image


Required Parameters

Parameter Default Description
{p2i_url} N/A URL of target page. Do not need to be encode.
Valid inputs:
{p2i_key} N/A The API key in your account. You can get it here.
Please use the Restful Key rather than Direct Link Key. Why?

Optional Parameters

Parameter Default Description
{p2i_device} 6 Our system can generate the screenshot for those smart phones and desktops. Please pass it to server as needed.
Following are devices we supported:
0 - iPhone4, 1 - iPhone5, 2 - Android, 3 - WinPhone, 4 - iPad, 5 - Android Pad, 6 - Desktop, 7 - iPhone6, 8 - iPhone6+
{p2i_size} N/A The screenshot file size you want to get. Not the screen size of device. If you want a big image, you need enlarge the width and height. If you need a small one, you need reduce the width and height. But it will take some more time to download a big image than a small one.
widthxheight e.g. 300x300

We predefined the size for those devices for most usage:
Mobile Phones: 320x480
Tablets: 512x384
Desktop: 640x400

Advanced information:
1) If you only know the fixed width or height of the images you want to get, you can just pass the width or height to us by following format: 512x0 or 0x512. We will resize the image to fit that width/height and make sure it is the biggest image we can generate.
2) The screenshot image will be resized to fit the width and height without stretching
{p2i_screen} N/A The screen size of device you want to simulate.
screen_widthxscreen_height e.g. 1024x768
We predefined the size for those devices for most usage:
Mobile: 320x480
Mobile iPhone5: 320x500
Mobile iPhone6: 375x667
Mobile iPhone6+: 414x736
Tablets: 1024x768
Desktop: 1280x800
Advanced information:
1) The screen size should not be less than image size.
{p2i_fullpage} True Full page or just the screen area. If the value is 1 or true, we will take the full page screenshot. If the value is 0 or false, we will take the screen area only.
{p2i_callback} N/A It will take around 10-30 seconds to generate one screenshot. If you want to us send a notification when we finish the screenshot of one page, you can send us your listener URL in the request. Please return 200 status code when you get the request.
How to create website screenshot with callback API
{p2i_imageformat} png png, jpg, pdf.
We strongly recommend jpg since most jpg file is smaller than png. But png quaility is much better than jpg.
{p2i_quality} 80 The quality of the image. By default, JPG is 90 and PNG is 80.
JPG: you can change it from 80 to 95 as needed.
PNG: you can change it from 70 to 85 as needed.
{p2i_wait} 0 How many second wait after page load complete. System will not accept the value larger than 25 seconds.
{p2i_js} 1 1 or 0. 1 means enable javascript. 0 means disable javascript. If you do not want to run javascript on target page (for example, some welcome message), please use this parameter.
{p2i_csspath} null It is an URL which point to a css file. For example, http://your_domain/test.css. System will add the css styles when load the target page.

1. It is hard to debug. But it do works. :)
2. Only chrome engine can use this field;
3. Please use !important in the properties of CSS since it is important.
4. CSS file size should less than 1 M.
5. We will not throw out any exception when your CSS file is not valid to access or it is not a valid CSS style. So, be carefull on that.

Following is an example, we change our header to a red version. Request: http://api.page2images.com/restfullink?p2i_url=http://www.page2images.com&p2i_device=6&p2i_screen=1024x768&p2i_csspath=http://api.page2images.com/test.css&p2i_key=YOUR_KEY

Possible Return Values

All of the return format is Json format which supported by most of the programming languages.

If server is processing your request, you will receive:


If server has finished your request, you will receive:
PS: image_url is JSON encoded.


Then you can download and do whatever you think is right on the images. We will keep this image for you for 24 hours. After that, due to the disk limitation, we will remove that image. Of cause, if you want to generate it again, we will capture it again.

If server encounter any problem, we will return:

"msg": "detail information here"

Possible error messages are following:

Errno:403 Msg: The API Key does not exist.

Errno:403 Msg: Account does not have enough credits.

Errno:403 Msg: Account has expired.

Errno:403 Msg: You are using direct link key in Rest API.

Errno:404 Msg: We cannot access target URL.

Errno:500 Msg: Time out.

Sample Codes
Download Java sample source code for website screenshot
Download PHP sample source code for website screenshot
Download Python sample source code for website screenshot
Download PHP sample source code for convert HTML to image
Use Code Generator to Build the Code

Using our Code Generator, you can quickly generate the source code for IMG Tags. Use page2images code generator for website screenshot.

Free Engineering Service

Premium and XLarge rate plan users get free help with writing and testing code. Please contact us if you need help.