Socket
Book a DemoInstallSign in
Socket

screenshotly-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

screenshotly-js

JavaScript client for the Screenshotly API - capture screenshots of any website programmatically

0.2.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Screenshotly JS

A JavaScript client library for the Screenshotly API that allows you to capture screenshots of any website programmatically.

Installation

npm install screenshotly-js

Or with yarn:

yarn add screenshotly-js

Usage

Basic Example

const { Screenshotly } = require('screenshotly-js');

// Initialize the client with your API key
const client = new Screenshotly('your-api-key-here');

// Capture a screenshot of a URL
async function captureScreenshot() {
  const screenshot = await client.capture({
    url: 'https://example.com',
    width: 1280,
    height: 800,
    fullPage: true,
    delay: 500
  });
  
  if (screenshot.success) {
    console.log('Screenshot URL:', screenshot.data.imageUrl);
    console.log('Remaining credits:', screenshot.remainingCredits);
  } else {
    console.error('Error:', screenshot.error);
  }
}

captureScreenshot();

Batch Screenshots

const { Screenshotly } = require('screenshotly-js');

const client = new Screenshotly('your-api-key-here');

async function captureBatchScreenshots() {
  const result = await client.captureBatch({
    urls: [
      'https://example.com',
      'https://google.com',
      'https://github.com'
    ],
    options: {
      format: 'png',
      width: 1280,
      height: 800,
      fullPage: true,
      delay: 500
    }
  });
  
  if (result.success) {
    console.log('Screenshots:', result.data);
    console.log('Remaining credits:', result.remainingCredits);
  } else {
    console.error('Error:', result.error);
  }
}

captureBatchScreenshots();

Advanced Options

const { Screenshotly } = require('screenshotly-js');

// You can also pass configuration options
const client = new Screenshotly({
  apiKey: 'your-api-key-here',
  baseUrl: 'https://api.screenshotly.dev',
  timeout: 90000 // 90 seconds timeout for large pages
});

async function captureWithAdvancedOptions() {
  const screenshot = await client.capture({
    url: 'https://example.com',
    format: 'png',
    width: 1920,
    height: 1080,
    fullPage: true,
    deviceScaleFactor: 2, // Retina-quality screenshot
    isMobile: true,
    hasTouch: true,
    waitForSelector: '.content-loaded',
    delay: 1000, // Wait 1 second before capturing
    timeout: 45000 // 45 seconds timeout
  });
  
  console.log('Screenshot URL:', screenshot.data.imageUrl);
}

API Reference

Screenshotly Class

Constructor

// Simple format
new Screenshotly(apiKey)

// Advanced format
new Screenshotly(config)
  • apiKey (string): Your Screenshotly API key
  • config.apiKey (required): Your Screenshotly API key
  • config.baseUrl (optional): Custom API base URL (default: 'https://api.screenshotly.dev')
  • config.timeout (optional): Request timeout in milliseconds (default: 60000)

Methods

capture(options): Promise<object>

Captures a screenshot of the specified URL.

Options:

  • url: URL to capture (required)
  • name: Optional name for the screenshot
  • width: Width of the viewport in pixels (default: 1920)
  • height: Height of the viewport in pixels (default: 1080)
  • fullPage: Whether to capture the full page or just the viewport (default: false)
  • format: Output format ('png', 'jpeg', 'webp') (default: 'png')
  • deviceScaleFactor: Device scale factor (default: 1)
  • isMobile: Whether to emulate a mobile device (default: false)
  • hasTouch: Whether the device has touch capabilities (default: false)
  • isLandscape: Whether to use landscape orientation (default: false)
  • waitForSelector: Optional selector to wait for before taking the screenshot
  • delay: Delay in milliseconds before capturing the screenshot (default: 0)
  • timeout: Timeout in milliseconds (default: 30000)
captureBatch(request): Promise<object>

Captures multiple screenshots in batch.

Request:

  • urls: Array of URLs to take screenshots of
  • options: Screenshot options (applied to all URLs)
getScreenshots(page, limit): Promise<object>

Gets a list of your screenshots.

  • page: Page number (default: 1)
  • limit: Number of items per page (default: 10)
getScreenshot(id): Promise<object>

Gets a specific screenshot by ID.

deleteScreenshot(id): Promise<object>

Deletes a screenshot by ID.

License

MIT

Keywords

screenshot

FAQs

Package last updated on 08 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.