Web to Image

Taking a screenshot


Authorization

You need to always provide an API Key which you can create within your account here

If you call a GET request include api key in the url like below.

GET http://api.webtoimage.com/v1/screenshot?url=https://google.com&api_key=YOUR_API_KEY

If you use the POST request include it within the body parameters.

curl -H "Content-Type: application/json" -X POST -o image.png -d "{\"api_key\":\"YOUR_API_KEY_HERE\",\"html\":\"<h1>HELO<\/h1>\"}" https://api.webtoimage.com/v1/screenshot

From URL

The easiest way to take a screenshot is to provide an url.

{primary} The response time depends mostly on the site speed and overall loading times with all images, fonts, styles.

Simpliest example

GET http://api.webtoimage.com/v1/screenshot?url=https://google.com&api_key=YOUR_API_KEY

{info} Loading the site from URL takes longer then providing the HTML like below. Avg difference is 1.5sec between those two.

From HTML

Second approach is to provide a HTML page.

POST http://api.webtoimage.com/v1/screenshot

{info} The POST request can handle both the URL & HTML source. The GET post is limited by query characters limit so it only accepts URL.

CURL HTML Example

curl -H "Content-Type: application/json" -X POST -o image.png -d "{\"html\":\"<h1>HELO<\/h1>\"}" https://api.webtoimage.com/v1/screenshot

CURL URL Example

curl -H "Content-Type: application/json" -X POST -o image.png -d "{\"url\":\"https:\/\/google.com\"}" https://api.webtoimage.com/v1/screenshot

{warning} Assets (images, fonts, styles) needs to be accesible online or inlined so the server can load them properly