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

HTTP POST to Call

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"; .

http://api.page2images.com/restfulbatches

Parameters

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:
www.google.com
google.com
http://www.google.com
https://www.google.com
{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.
Format:
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.
Format:
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_useragent} null Sets the User-Agent of browser to emulate a special device when making screenshots. It should be URL encoded to be processed correctly.
{p2i_accept_language} null Sets the Accept-Language header of request. You can simulate a special language of browser as needed.
Only p2i_engine=chrome support this feature. By default, p2i_engine is chrome.
{p2i_headers} null 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.
Only p2i_engine=chrome support this feature. By default, p2i_engine is chrome.
This feature only is available in "Advanced Plan" and above plans.
{p2i_css} null A CSS string to inject in the web page before token the screenshot. This CSS string should to be URL encoded to be processed correctly.
The length of the CSS string will be less than 16K.
Only p2i_engine=chrome support this feature. By default, p2i_engine is chrome.
This feature only is available in "Advanced Plan" and above plans.

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:

{
    "errno":"403"
    "msg": "detail information here"
    "status":"error",
}

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.

version:1.7