0.1.6 • Published 5 years ago

@apilayer/screenshotlayer v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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:

ParameterDescription
fullPageset to true if you want to capture the full height of the target website
widthspecify your preferred thumbnail width in pixels
vHeightspecify your preferred viewport height dimensions in pixels
vWidthspecify your preferred viewport width dimensions in pixels
formatset your preferred image output format (PNGGIFJPG)
injectCSSattach a URL containing a custom CSS stylesheet
delayspecify a delay before screenshot is captured (in seconds)
tTLdefine the time (in seconds) your snapshot should be cached
forceset to true if you want to force the API to capture a fresh screenshot
placeholderattach a URL containing a custom placeholder image or set to "1"
userAgentspecify a custom User-Agent HTTP header to send with your request
acceptLangspecify a custom Accept-Language HTTP header to send with your request
exportexport snapshot via custom ftp path or using your AWS S3 user details

License

MIT