Url Examples
Using a URL, you can convert a website that is accessible on the internet. In this section, we demonstrate how to use a URL to generate a pdf and an image. If you require authentication to access your URL, see the Authentication section for examples.
Json Request
At its most basic, a URL is the only required parameter to generate a PDF or Image.
{
"url": "https://google.com"
}
Pdf Example
cURL - Google Pdf
curl --request POST \
--url https://api.cloudlayer.io/v2/url/pdf \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR-API-KEY>' \
--data '{
"url": "https://google.com"
}' \
--output "response.json"
Wget - Google Pdf
wget --method POST \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR-API-KEY>' \
--body-data '{"url": "https://google.com"}' \
- https://api.cloudlayer.io/v2/url/pdf \
-O "response.json"
Image Example
cURL - Google PNG
curl --request POST \
--url https://api.cloudlayer.io/v2/url/image \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR-API-KEY>' \
--data '{
"url": "https://google.com"
}' \
--output "response.json"
Wget - Google PNG
wget --method POST \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR-API-KEY>' \
--body-data '{"url": "https://google.com"}' \
- https://api.cloudlayer.io/v2/url/image \
-O "response.json"
Autoscroll
Some sites have lazy loaded images and other content that is not loaded until the page scrolls past a certain point. Using autoscroll, will scroll down the page forcing the content to be loaded before performing the conversion.
Autoscroll Example
curl --request POST \
--url https://api.cloudlayer.io/v2/url/image \
--header 'Content-Type: application/json' \
--header 'x-api-key: <YOUR-API-KEY>' \
--data '{
"url": "https://apple.com",
"autoScroll": true
}'