To take screenshots trough the SiteCapt API you make a GET request to the API URL:
The API supports these parameters.
|api_key||Your SiteCapt API key.|
|url||The URL of the website for the screenshot.|
|viewport_width||The width of the browser viewport in pixels.|
|viewport_height||The height of the browser viewport in pixels.|
|width||The width of the generated screenshot image.|
|height||The height of the generated screenshot image.|
|fullsize||Produce a full size screenshot of the entire page. The height parameter is ignored when fullsize is yes.|
|wait||Wait this many seconds after the page has fully loaded before taking the screenshot.|
curl "https://api.sitecapt.com/?api_key=44f398ca-4055-4d47-8464-54c5d0c5b7a7&url=http://www.flickr.com/&viewport_width=1600&viewport_height=1200&width=800&height=400" > screenshot.png
This will generate a screenshot of http://www.flickr.com/. The browser viewport will be 1600x1200 pixels large and the screenshot will be scaled and cropped to 800x400 pixels.
If an image needs to be cropped, we always cut away pixels away at the right and bottom edges.
The resulting image is always in PNG format.
While it might be convenient for you to use the API URL directly in your HTML code to load website screenshots on the fly we would like to point out that for several reasons it is much safer and efficient to load and cache the screenshots yourself before displaying them:
- It takes an awful amount of time to load a website screenshot. On average a screenshot will be ready after 7 (!) seconds.
- If you cache screenshots and use these cached versions to display the images on your website you save a lot of money. Creating a screenshot again, even one you've requested a second ago, will cost credits.
- If you expose your API key to the public everyone can use you API key at their leisure to generate screenshots at your expense, so guard your API key as best as you can.
- The PNG format generated by the API ensures that you get the maximum quality resulting in a rather large file size. In most cases it makes more sense to deliver a much smaller JPEG image to your users.