API Documentation > Rest API > Create Website Screenshots with Batch Rest API

We are sorry.

This API has been removed because some unknow issues.

Actually, it is very hard to use the batch API. And the single process API is much easier and stable than the batch version. Old customers still can use the batchAPI.

Create website Screenshots with Batch Rest API

Use this BATCH REST API to get the website Screenshots


We only support POST method. To make a call, make an HTTP POST request to api server to following URL. If you are using callback mode, it is not necessary to use batch API. Batch API is designed for batch Pull mode. For .Net developer, you need set In C#: request.ContentType = "application/x-www-form-urlencoded"; .



Required Parameters

Parameter Default Description
{requests} N/A Json array(max size is 1,000).
Valid inputs:
["{\"id\":\"0\", \"p2i_key\":\"YOUR_API_KEY\",\"p2i_url\":\"TARGET_URL1\"}",
"{\"id\":\"1\", \"p2i_key\":\"YOUR_API_KEY\",\"p2i_url\":\"TARGET_URL2\", \"p2i_device\":0,\"p2i_size\":\"640x400\",\"p2i_screen\":\"640x400\", \"p2i_fullpage\":1,\"p2i_callback\":\"YOUR_CALL_BACK_URL\", \"p2i_imageformat\":\"jpg\", \"p2i_wait\":30}"]

Required Parameters in requests array objects

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 in requests array objects

{id} N/A Will return in result data to pair with post data.
{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
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. Again, it is not necessary to use batch API when your request is using callback.
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:

    	"total": 2,
    	"success": 1,
    	"error": 0,
    	"estimated_complete_time": 10,
    	"spend_time": 662,
    	"status": "processing"

If server has finished your request, you will receive:

    	"total": 2,
    	"success": 1,
    	"error": 1,
        "result_data":["{\"id\":\"0\", \"status\":\"error\",\"msg\":\"URL format of target page is wrong.\", \"errno\":404}",
            "{\"id\":\"1\", \"status\":\"finished\", \"image_url\":\"http://api.page2images.com/images/00/00/10923423.jpg\", \"duration\":11, \"left_calls\":923023}"],
    	"spend_time": 662,
    	"status": "finished"

Each object as json in result_data is same result as rest api.

If server encounter any problem, we will return:

    "msg": "detail information here"

Possible error messages are following:

Errno:403 Msg: You must pass a requests to us.

Errno:403 Msg: Sorry, one batch request only can process 1,000 sub requests.

Errno:403 Msg: Sorry, please check your post data.

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.