@apilayer/screenshotlayer

Screenshotlayer: Capture highly customizable snapshots of any website

Usage no npm install needed!

<script type="module">
  import apilayerScreenshotlayer from 'https://cdn.skypack.dev/@apilayer/screenshotlayer';
</script>

README

screenshotlayer-js

Screenshotlayer: Capture highly customizable snapshots of any website

Installation

Using npm

npm install --save @apilayer/screenshotlayer

or yarn

yarn add @apilayer/screenshotlayer

Getting Started

Head over to Screenshotlayer and create an account. Copy access key from dashboard.

You can set a secret key from the dashboard or just use an empty string.

import screenshotlayer from '@apilayer/screenshotlayer'

const useHTTPs = false
const layer = new screenshotlayer("<your-access-key>", "<your-secret-key>", useHTTPs)

capture

capture creates a valid screenshot URL

Signature:

capture(site: string, config: Config = null): string

Example:

const response = layer.capture("https://apilayer.com")

console.log("response:", response)

Response:

"http://api.screenshotlayer.com/api/capture
  ?access_key=<your-access-key>
  &url=https://apilayer.com
  &viewport=1440x900
  &format=PNG"

Alternatively, you can specify a Config object as the second parameter. Supported properties include:

Parameter Description
fullPage set to true if you want to capture the full height of the target website
width specify your preferred thumbnail width in pixels
vHeight specify your preferred viewport height dimensions in pixels
vWidth specify your preferred viewport width dimensions in pixels
format set your preferred image output format (PNG
injectCSS attach a URL containing a custom CSS stylesheet
delay specify a delay before screenshot is captured (in seconds)
tTL define the time (in seconds) your snapshot should be cached
force set to true if you want to force the API to capture a fresh screenshot
placeholder attach a URL containing a custom placeholder image or set to "1"
userAgent specify a custom User-Agent HTTP header to send with your request
acceptLang specify a custom Accept-Language HTTP header to send with your request
export export snapshot via custom ftp path or using your AWS S3 user details

License

MIT