HTTP Endpoint
API Client Library DocumentationThis documentation is for the HTTP Endpoint. For GET
and POST
requests.
For API Libraries and Examples in these or other languages, refer to the Docs Index Page
We have introduced a new rendering engine based on Chrome. It offers a superior experience to Webkit, the old rendering system. If you want to use the old webkit rendering, include backend:"webkit"
in your request.
These examples use GET
requests because they are the simplest way of showing examples and getting started, but it is strongly suggested you use the POST
endpoint for "real" usage.
Basic Examples:
png
if you need transparency (if the backgrounds are weirdly black)@media:print
directives if you set IRenderSettings.emulateMedia, but we default to @media:screen for improved compatibility *pageResponse.pageRequest
for the default values to other parameters.Advanced Examples:
img
tag. For more info on using selectors, see IRenderSettings.selector(https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors)viewport
to 640px width, zooms out, and sets a 640x500 clipRectangle
to generate a thumbnail image of the CNN.com website.www.highcharts.com
has been replaced with wikipedia.org
but the path is preserved. read the text of the output error message to see this.clearCache:true
parameter. This is required so that .css resources are re-requested and blocked.pageResponses.cookies
property.clearCache:true
parameter. This is required so that all resources are re-requested so headers are populated.Hello:world
and Accept-encoding:tacos
values in the resulting HTML. Uses our example show request details pagetv2.dk
site lazy loads images only when it's shown in the browser, so if you take a screenshot without the provided script, the bottom part will be missing images. Important: This page takes aprox 25 seconds to load, and weighs aprox 2mb in size. (Costs about 0.0047 credits)outputAsJson:true
or you will not get usable resultsapplication/json
content-type and submit POST data. Check the payload
section of the output results.resourceTimeout
parameter like this example does. We will be developing our own proxy service in the coming months.Other Examples: See the Docs Index Page Usage FAQ for other examples (such as Page Automation / Button Clicking)
Test Pages: These pages are used in some of the above examples, and might be useful to you when evaluating this service:
To use this API, you need to submit a GET
or POST
request to the API endpoint:
GET
requests are the simplest way of showing examples and getting started, but it is strongly suggested you use the POST
endpoint for "real" usage.
[YOUR-KEY]
/?request=[REQUEST-JSON]
[REQUEST-JSON]
should be encoded via encodeURIComponent()
, do not encode the parts individually.[YOUR-KEY]
/?requestBase64=[REQUEST-JSON]
\t- The entirety of your [REQUEST-JSON]
should be Base64 Encoded, do not encode the parts individually, and do not urlEncode before you Base64 Encode.[YOUR-KEY]
/[REQUEST-JSON]
application/json
Your key used for creditBalance/billing. You can obtain this by signing up, or use the special key a-demo-key-with-low-quota-per-ip-address
for testing.
The details of your request as a JSON object. This JSON can take one of the following three forms, each of which are described here:
{url:"http://www.example.com",renderType:"jpg",outputAsJson:true}
[{url:"http://www.google.com"},{url:"https://www.google.com/doodles/",renderType:"jpg",outputAsJson:true}]
{proxy:false,pages:[{url:"http://www.google.com"},{url:"https://www.google.com/doodles/",renderType:"jpg",outputAsJson:true}]}
While the url
is required, everything else is optional. Click here to view the default values if you leave the various parameters blank
You can use CORS
(preferred) or JSONP
to integrate api calls from PhantomJs Cloud directly into your webpage.
CORS
enabled by default.JSONP
format, add the ?callback=CALLBACK_FUNCTION_NAME
querystring to your request (for either GET
or POST
requests). You MUST set outputAsJson:true
for JSONP to work. Here is an example JSONP simple request.Please refer to the main Docs Index Page for Basic Troubleshooting, Testing and Performance Optimization, Usage FAQ, and language-specific samples.
the different event phases that a page goes through
new for Chrome backend. summary of all resources requested during the page execution, and their current status upon page completion.
aborted because the resource exceeded IRequestSettings.resourceTimeout
requests that were still active (but healthy) upon page completion
successfully completed resource loads
failed due to normal browser workflows
requests that were still active (but took longer than IRequestSettings.resourceWait) upon page completion
if the browser looses track of resource request/response pairs, it will be put here (should never happen)
select the browser engine you will use
you may choose from the following shortcuts: "
default
", "preview
", "webkit
", "chrome
"default
: currentlywebkit pjs2.1.1
, will change tochrome
soonpreview
: currentlychrome
. may change at any time as this is for testing new backends or feature enhancements.webkit
: the latest stabke version of the default PhantomJs rendering engine:webkit pjs2.1.1
chrome
: the latest stable version of chromeor choose a specific backend:
chrome v68
,webkit pjs2.1.1
,webkit pjs2.5beta