npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

screenshot-pdf-api

v1.1.0

Published

Official Node.js wrapper for the Screenshot & PDF API. Capture screenshots, generate PDFs, extract metadata, and render HTML to images.

Downloads

181

Readme

screenshot-pdf-api

Official Node.js wrapper for the Screenshot & PDF API. Capture screenshots, generate PDFs, extract metadata, and render HTML to images -- all from a simple API.

Zero dependencies -- uses native fetch (Node 18+).

npm

Get Your API Key

Subscribe on RapidAPI to get your key. Three tiers available:

| Tier | Endpoints | Rate Limit | |------|-----------|------------| | Free | health, screenshot | 100 req/day | | Basic | + pdf, metadata | 1,000 req/day | | Pro | + htmlScreenshot (HTML/CSS render) | 10,000 req/day |

Install

npm install screenshot-pdf-api

Quick Start

import ScreenshotAPI from 'screenshot-pdf-api';
import { writeFileSync } from 'fs';

const api = new ScreenshotAPI('your-rapidapi-key');

// Take a screenshot
const png = await api.screenshot({ url: 'https://example.com' });
writeFileSync('example.png', png);

// Generate a PDF
const pdf = await api.pdf({ url: 'https://example.com' });
writeFileSync('example.pdf', pdf);

CommonJS

const ScreenshotAPI = require('screenshot-pdf-api');

const api = new ScreenshotAPI('your-rapidapi-key');
const png = await api.screenshot({ url: 'https://example.com' });

API Reference

Constructor

// Simple -- just pass your key
const api = new ScreenshotAPI('your-rapidapi-key');

// Advanced options
const api = new ScreenshotAPI({
  apiKey: 'your-rapidapi-key',
  timeout: 60000,  // 60s timeout (default: 30s)
});

Methods

All methods return a Promise and throw ScreenshotAPIError on failure.


api.health()

Check API status and queue depth. No authentication required.

const status = await api.health();
// { status: 'healthy', browser: 'connected', queue: 0, max_concurrent: 3, version: '1.0' }

api.screenshot(params) -- Free tier

Capture a screenshot of any URL. Returns a Buffer containing the image data.

| Param | Type | Default | Description | |-------|------|---------|-------------| | url | string | required | URL to capture | | width | number | 1280 | Viewport width in px | | height | number | 800 | Viewport height in px | | format | string | "png" | png, jpeg, or webp | | quality | number | 85 | Quality 1-100 (jpeg/webp only) | | full_page | boolean | false | Capture full scrollable page | | delay | number | 0 | Wait delay in seconds before capture | | selector | string | null | CSS selector to capture a specific element |

// Basic screenshot
const png = await api.screenshot({ url: 'https://github.com' });
writeFileSync('github.png', png);

// Full-page screenshot as WebP
const webp = await api.screenshot({
  url: 'https://github.com',
  format: 'webp',
  full_page: true,
  quality: 90,
});

// Capture a specific element
const logo = await api.screenshot({
  url: 'https://github.com',
  selector: '.header-logo',
});

api.pdf(params) -- Basic tier

Generate a PDF from any URL. Returns a Buffer containing the PDF data.

| Param | Type | Default | Description | |-------|------|---------|-------------| | url | string | required | URL to convert | | format | string | "A4" | A4, Letter, Legal, A3, A5, Tabloid | | landscape | boolean | false | Landscape orientation | | print_background | boolean | true | Include background graphics | | margin | string | "normal" | normal, none, narrow, wide |

// Default A4 PDF
const pdf = await api.pdf({ url: 'https://example.com' });
writeFileSync('page.pdf', pdf);

// Landscape Letter with no margins
const report = await api.pdf({
  url: 'https://example.com/report',
  format: 'Letter',
  landscape: true,
  margin: 'none',
});

api.metadata(url) -- Basic tier

Extract title, Open Graph tags, favicon, word count, and link counts from a URL.

const meta = await api.metadata('https://github.com');
console.log(meta.data.title);       // "GitHub: Let's build from here"
console.log(meta.data.og_image);    // "https://github.githubassets.com/..."
console.log(meta.data.word_count);  // 1234

api.htmlScreenshot(params) -- Pro tier

Render raw HTML/CSS to an image. Returns a Buffer.

| Param | Type | Default | Description | |-------|------|---------|-------------| | html | string | required | HTML content to render | | width | number | 1280 | Viewport width in px | | height | number | 800 | Viewport height in px | | format | string | "png" | png, jpeg, or webp |

const img = await api.htmlScreenshot({
  html: '<h1 style="color: red;">Hello World</h1>',
  width: 800,
  height: 600,
});
writeFileSync('rendered.png', img);

Error Handling

import ScreenshotAPI, { ScreenshotAPIError } from 'screenshot-pdf-api';

const api = new ScreenshotAPI('your-key');

try {
  const png = await api.screenshot({ url: 'https://example.com' });
} catch (err) {
  if (err instanceof ScreenshotAPIError) {
    console.error(`API Error ${err.status}: ${err.message}`);
    console.error('Response body:', err.body);
  }
}

TypeScript

Full TypeScript support is included out of the box. All types are exported:

import ScreenshotAPI, {
  ScreenshotParams,
  PdfParams,
  MetadataResponse,
  HtmlScreenshotParams,
} from 'screenshot-pdf-api';

const api = new ScreenshotAPI('your-key');
const meta: MetadataResponse = await api.metadata('https://example.com');

Requirements

  • Node.js 18+ (uses native fetch)

License

MIT