Nodejs website screenshots

Nodejs website screenshots

Generate website screenshots with nodejs

This node.js sample code uses the Urlbox node SDK to build an authenticated render link which can be used directly in an img or meta tag to render a screenshot.

Check out our NPM package, and Github repo

// npm install urlbox --save
 
import Urlbox from "urlbox";
 
// Plugin your API key and secret
const urlbox = Urlbox(YOUR_API_KEY, YOUR_API_SECRET);
 
// Set your options
const options = {
  url: "github.com",
  thumb_width: 600,
  format: "jpg",
  quality: 80,
};
 
const imgUrl = urlbox.generateRenderLink(options);
// https://api.urlbox.io/v1/YOUR_API_KEY/TOKEN/jpg?url=github.com&thumb_width=600&quality=80
 
// Now set it as the src in an img tag to render the screenshot
<img src={imgUrl} />;